Finish API documentation and token auth (references #5)

This commit is contained in:
Bernd Bestel
2018-04-21 19:18:00 +02:00
parent 9bd6aac09c
commit 99b2a84667
40 changed files with 1617 additions and 128 deletions

View File

@@ -4,8 +4,16 @@ namespace Grocy\Helpers;
class UrlManager
{
public function __construct(string $basePath) {
$this->BasePath = $basePath;
public function __construct(string $basePath)
{
if ($basePath === '/')
{
$this->BasePath = $this->GetBaseUrl();
}
else
{
$this->BasePath = $basePath;
}
}
protected $BasePath;
@@ -14,4 +22,9 @@ class UrlManager
{
return rtrim($this->BasePath, '/') . $relativePath;
}
private function GetBaseUrl()
{
return (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
}
}

View File

@@ -1,47 +0,0 @@
{
"openapi": "3.0.0",
"info": {
"title": "grocy REST API",
"description": "xxx",
"version": "xxx"
},
"servers": [
{
"url": "xxx"
}
],
"paths": {
"/get-objects/{entity}": {
"get": {
"description": "Returns all objects of the given entity",
"parameters": [
{
"in": "path",
"name": "entity",
"required": true,
"description": "A valid entity name",
"schema": {
"$ref": "#/components/schemas/Entity"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
"schemas": {
"Entity": {
"type": "string",
"enum": [
"product",
"habit"
]
}
}
}
}