mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Finish API documentation and token auth (references #5)
This commit is contained in:
@@ -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]";
|
||||
}
|
||||
}
|
||||
|
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user