Skip to content

Commit 92805b0

Browse files
committed
add swagger and api surface
1 parent 2aa78af commit 92805b0

8 files changed

Lines changed: 336 additions & 0 deletions

File tree

16.1 KB
Binary file not shown.

www/storage/assets/img/feather-sprite.svg

Lines changed: 1 addition & 0 deletions
Loading

www/storage/index.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
ini_set("log_errors", 1);
3+
ini_set('session.cookie_httponly', 1);
4+
ini_set('expose_php', 'off');
5+
6+
require_once(__DIR__ . "/../../config.php");
7+
require_once(__DIR__ . "/../../vendor/autoload.php");
8+
9+
use Pdsinterop\PhpSolid\Middleware;
10+
use Pdsinterop\PhpSolid\Routes\SolidStorageProvider;
11+
12+
$request = explode("?", $_SERVER['REQUEST_URI'], 2)[0];
13+
$method = $_SERVER['REQUEST_METHOD'];
14+
15+
Middleware::cors();
16+
17+
switch($method) {
18+
case "GET":
19+
switch ($request) {
20+
default:
21+
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not found");
22+
break;
23+
}
24+
break;
25+
case "POST":
26+
switch ($request) {
27+
case "/api/storage/new":
28+
case "/api/storage/new/":
29+
StorageServer::respondToStorageNew();
30+
break;
31+
default:
32+
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not found");
33+
break;
34+
}
35+
break;
36+
case "OPTIONS":
37+
break;
38+
case "PUT":
39+
default:
40+
header($_SERVER['SERVER_PROTOCOL'] . " 405 Method not allowed");
41+
break;
42+
}

www/storage/swagger/index.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- HTML for static distribution bundle build -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Swagger UI</title>
7+
<link rel="stylesheet" type="text/css" href="swagger-ui.css" >
8+
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
9+
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
10+
<style>
11+
html
12+
{
13+
box-sizing: border-box;
14+
overflow: -moz-scrollbars-vertical;
15+
overflow-y: scroll;
16+
}
17+
18+
*,
19+
*:before,
20+
*:after
21+
{
22+
box-sizing: inherit;
23+
}
24+
25+
body
26+
{
27+
margin:0;
28+
background: #fafafa;
29+
}
30+
</style>
31+
</head>
32+
33+
<body>
34+
<div id="swagger-ui"></div>
35+
36+
<script src="swagger-ui-bundle.js"> </script>
37+
<script src="swagger-ui-standalone-preset.js"> </script>
38+
<script>
39+
window.onload = function() {
40+
41+
// Begin Swagger UI call region
42+
const ui = SwaggerUIBundle({
43+
"dom_id": "#swagger-ui",
44+
deepLinking: true,
45+
presets: [
46+
SwaggerUIBundle.presets.apis,
47+
SwaggerUIStandalonePreset
48+
],
49+
plugins: [
50+
SwaggerUIBundle.plugins.DownloadUrl
51+
],
52+
layout: "StandaloneLayout",
53+
validatorUrl: false,
54+
url: "swagger.json",
55+
})
56+
57+
// End Swagger UI call region
58+
59+
60+
window.ui = ui
61+
}
62+
</script>
63+
</body>
64+
</html>

www/storage/swagger/swagger-ui-bundle.js

Lines changed: 126 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/storage/swagger/swagger-ui-standalone-preset.js

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/storage/swagger/swagger-ui.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/storage/swagger/swagger.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"description": "API documentation for PHP Solid Storage Provider",
5+
"version": "0.1",
6+
"title": "PHP Solid Storage Provider API",
7+
"license": {
8+
"name": "Copyright PDSInterop",
9+
"url": "http://solid.local/api/v1/LICENSE"
10+
}
11+
},
12+
"servers" : [
13+
{
14+
"url" : "/",
15+
"description" : "Test here"
16+
}
17+
],
18+
"tags": [
19+
{
20+
"name": "Storage creation",
21+
"description": "Endpoints related to account creation",
22+
"externalDocs": {
23+
"description": "Read more",
24+
"url": "http://docs.solid.local/storage/api/v1/#storage-creation"
25+
}
26+
}
27+
],
28+
"paths": {
29+
"/api/storage/new": {
30+
"post": {
31+
"tags": [
32+
"Storage creation"
33+
],
34+
"summary": "Create a new storage pod",
35+
"description": "This is the second step in account creation. After having a verification token for the e-mail address, this call allows creation of an account",
36+
"requestBody" : {
37+
"content" : {
38+
"application/x-www-form-urlencoded" : {
39+
"schema" : {
40+
"type" : "object",
41+
"example" : {
42+
"webId" : "https://id-123123.solid.local/#me"
43+
}
44+
}
45+
}
46+
}
47+
},
48+
"responses": {
49+
"201": {
50+
"description": "Successful operation",
51+
"content" : {
52+
"application/json" : {
53+
"schema": {
54+
"type": "object",
55+
"example": {
56+
"storageId": "https://storage-264e30d9-bc83-4ff7-a3b5-68d12125cdd7.solid.local/"
57+
}
58+
}
59+
}
60+
}
61+
},
62+
"400": {
63+
"description": "Bad request",
64+
"content" : {
65+
"application/json" : {
66+
"schema": {
67+
"type": "object",
68+
"example": {}
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)