Produce a schema-valid OpenAPI specification (closes #1457)

This commit is contained in:
Bernd Bestel
2021-07-05 23:23:59 +02:00
parent 6462dd8af6
commit 54bf7ed659
10 changed files with 136 additions and 135 deletions

View File

@@ -11,7 +11,7 @@ class FilesApiController extends BaseApiController
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->internalSchemas->FileGroups->enum))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
@@ -39,7 +39,7 @@ class FilesApiController extends BaseApiController
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->internalSchemas->FileGroups->enum))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
@@ -69,7 +69,7 @@ class FilesApiController extends BaseApiController
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->internalSchemas->FileGroups->enum))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}
@@ -100,7 +100,7 @@ class FilesApiController extends BaseApiController
{
try
{
if (!in_array($args['group'], $this->getOpenApiSpec()->components->internalSchemas->FileGroups->enum))
if (!in_array($args['group'], $this->getOpenApiSpec()->components->schemas->FileGroups->enum))
{
throw new \Exception('Invalid file group');
}

View File

@@ -216,26 +216,26 @@ class GenericEntityApiController extends BaseApiController
private function IsEntityWithEditRequiresAdmin($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityEditRequiresAdmin->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityEditRequiresAdmin->enum);
}
private function IsEntityWithNoListing($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoListing->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoListing->enum);
}
private function IsEntityWithNoEdit($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoEdit->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoEdit->enum);
}
private function IsEntityWithNoDelete($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoDelete->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntityNoDelete->enum);
}
private function IsValidExposedEntity($entity)
{
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntity->enum);
return in_array($entity, $this->getOpenApiSpec()->components->schemas->ExposedEntity->enum);
}
}

View File

@@ -36,45 +36,45 @@ class OpenApiController extends BaseApiController
$spec->info->description = str_replace('PlaceHolderManageApiKeysUrl', $this->AppContainer->get('UrlManager')->ConstructUrl('/manageapikeys'), $spec->info->description);
$spec->servers[0]->url = $this->AppContainer->get('UrlManager')->ConstructUrl('/api');
$spec->components->internalSchemas->ExposedEntity_IncludingUserEntities = clone $spec->components->internalSchemas->ExposedEntity;
$spec->components->schemas->ExposedEntity_IncludingUserEntities = clone $spec->components->schemas->ExposedEntity;
foreach ($this->getUserfieldsService()->GetEntities() as $userEntity)
{
array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum, $userEntity);
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum, $userEntity);
}
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_NotIncludingNotEditable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoEdit->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotEditable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotEditable->enum, $value);
}
}
$spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities->enum as $value)
$spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity_IncludingUserEntities->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoEdit->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoEdit->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_IncludingUserEntities_NotIncludingNotEditable->enum, $value);
}
}
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoDelete->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoDelete->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotDeletable->enum, $value);
}
}
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->internalSchemas->StringEnumTemplate;
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
$spec->components->schemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->schemas->StringEnumTemplate;
foreach ($spec->components->schemas->ExposedEntity->enum as $value)
{
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoListing->enum))
if (!in_array($value, $spec->components->schemas->ExposedEntityNoListing->enum))
{
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable->enum, $value);
array_push($spec->components->schemas->ExposedEntity_NotIncludingNotListable->enum, $value);
}
}