mirror of
https://github.com/grocy/grocy.git
synced 2026-04-04 20:06:16 +02:00
Replace generic entity get by id with specific ones
A change linke in a previous commit but for getting/deleting/changing entities.
This commit is contained in:
parent
6599da09e7
commit
641be7ee30
|
|
@ -162,6 +162,38 @@ class OpenApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
unset($spec->paths->{"/objects/{entity}"});
|
unset($spec->paths->{"/objects/{entity}"});
|
||||||
|
|
||||||
|
foreach(array_unique(array_merge($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum,
|
||||||
|
$spec->components->schemas->ExposedEntity_NotIncludingNotDeletable->enum,
|
||||||
|
$spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum)) as $value) {
|
||||||
|
$singleEntityPath = unserialize(serialize(clone $spec->paths->{"/objects/{entity}/{objectId}"}));
|
||||||
|
|
||||||
|
$type = null;
|
||||||
|
if(array_key_exists((string)$value, $entity_types)) {
|
||||||
|
$type = (object) array('$ref' => "#/components/schemas/" . $entity_types[$value]);
|
||||||
|
} else {
|
||||||
|
$type = (object) array("type" => "object");
|
||||||
|
}
|
||||||
|
|
||||||
|
$singleEntityPath->get->responses->{"200"}->content->
|
||||||
|
{"application/json"}->schema = $type;
|
||||||
|
$singleEntityPath->put->requestBody->content->
|
||||||
|
{"application/json"}->schema = $type;
|
||||||
|
|
||||||
|
if(!in_array($value, $spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum)) {
|
||||||
|
unset($singleEntityPath->get);
|
||||||
|
}
|
||||||
|
if(!in_array($value, $spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum)) {
|
||||||
|
unset($singleEntityPath->put);
|
||||||
|
}
|
||||||
|
if(!in_array($value, $spec->components->schemas->ExposedEntity_NotIncludingNotDeletable->enum)) {
|
||||||
|
unset($singleEntityPath->delete);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: update summary
|
||||||
|
$spec->paths->{"/objects/" . $value . '/{objectId}'} = $singleEntityPath;
|
||||||
|
}
|
||||||
|
unset($spec->paths->{"/objects/{entity}/{objectId}"});
|
||||||
|
|
||||||
sort($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum);
|
sort($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum);
|
||||||
|
|
||||||
return $this->ApiResponse($response, $spec);
|
return $this->ApiResponse($response, $spec);
|
||||||
|
|
|
||||||
|
|
@ -399,15 +399,6 @@
|
||||||
"Generic entity interactions"
|
"Generic entity interactions"
|
||||||
],
|
],
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
|
||||||
"in": "path",
|
|
||||||
"name": "entity",
|
|
||||||
"required": true,
|
|
||||||
"description": "A valid entity name",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/ExposedEntity_NotIncludingNotListable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "objectId",
|
"name": "objectId",
|
||||||
|
|
@ -483,15 +474,6 @@
|
||||||
"Generic entity interactions"
|
"Generic entity interactions"
|
||||||
],
|
],
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
|
||||||
"in": "path",
|
|
||||||
"name": "entity",
|
|
||||||
"required": true,
|
|
||||||
"description": "A valid entity name",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/ExposedEntity_NotIncludingNotEditable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "objectId",
|
"name": "objectId",
|
||||||
|
|
@ -560,15 +542,6 @@
|
||||||
"Generic entity interactions"
|
"Generic entity interactions"
|
||||||
],
|
],
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
|
||||||
"in": "path",
|
|
||||||
"name": "entity",
|
|
||||||
"required": true,
|
|
||||||
"description": "A valid entity name",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/ExposedEntity_NotIncludingNotDeletable"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "objectId",
|
"name": "objectId",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user