diff --git a/src/bundle/ApiPlatform/OpenApiFactory.php b/src/bundle/ApiPlatform/OpenApiFactory.php index f4bd1c5c2..5dee70aa6 100644 --- a/src/bundle/ApiPlatform/OpenApiFactory.php +++ b/src/bundle/ApiPlatform/OpenApiFactory.php @@ -178,14 +178,22 @@ private function insertIbexaResponseExample(Operation $operation): Operation $newOperation = $operation; foreach (($operation->getResponses() ?? []) as $responseCode => $response) { - if (!is_array($response) || !array_key_exists('content', $response)) { + if ($response instanceof Response) { + $content = $response->getContent()?->getArrayCopy(); + } elseif (is_array($response) && array_key_exists('content', $response)) { + $content = $response['content']; + } else { continue; } - $newContent = $response['content']; + if ($content === null) { + continue; + } + + $newContent = $content; foreach ($newContent as $mediaType => $responseContent) { - if (!array_key_exists('x-ibexa-example-file', $responseContent)) { + if (!is_array($responseContent) || !array_key_exists('x-ibexa-example-file', $responseContent)) { continue; } @@ -195,12 +203,16 @@ private function insertIbexaResponseExample(Operation $operation): Operation unset($newContent[$mediaType]['x-ibexa-example-file']); } - if ($newContent !== $response['content']) { - $newOperation = $newOperation->withResponse( - $responseCode, - new Response($response['description'] ?? (string)$responseCode, new ArrayObject($newContent)), - ); + if ($newContent === $content) { + continue; } + + $newOperation = $newOperation->withResponse( + $responseCode, + $response instanceof Response + ? $response->withContent(new ArrayObject($newContent)) + : new Response($response['description'] ?? (string)$responseCode, new ArrayObject($newContent)), + ); } return $newOperation; diff --git a/src/lib/Server/Controller/Bookmark/BookmarkCreateController.php b/src/lib/Server/Controller/Bookmark/BookmarkCreateController.php index 47e394e46..c7d2eed2c 100644 --- a/src/lib/Server/Controller/Bookmark/BookmarkCreateController.php +++ b/src/lib/Server/Controller/Bookmark/BookmarkCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\BookmarkService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\LocationService; @@ -50,21 +51,13 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Created.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to given Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the given Location does not exist.', - ], - Response::HTTP_CONFLICT => [ - 'description' => 'Error - Location is already bookmarked.', - ], + Response::HTTP_CREATED => new Model\Response(description: 'Created.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to given Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the given Location does not exist.'), + Response::HTTP_CONFLICT => new Model\Response(description: 'Error - Location is already bookmarked.'), ], ), )] diff --git a/src/lib/Server/Controller/Bookmark/BookmarkDeleteController.php b/src/lib/Server/Controller/Bookmark/BookmarkDeleteController.php index a2416f04d..1c69cf28f 100644 --- a/src/lib/Server/Controller/Bookmark/BookmarkDeleteController.php +++ b/src/lib/Server/Controller/Bookmark/BookmarkDeleteController.php @@ -48,15 +48,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'Deleted - no content.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized for the given Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the given Location does not exist / is not bookmarked.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'Deleted - no content.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized for the given Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the given Location does not exist / is not bookmarked.'), ], ), )] diff --git a/src/lib/Server/Controller/Bookmark/BookmarkIsBookmarkedController.php b/src/lib/Server/Controller/Bookmark/BookmarkIsBookmarkedController.php index 422ef0322..bbf84d172 100644 --- a/src/lib/Server/Controller/Bookmark/BookmarkIsBookmarkedController.php +++ b/src/lib/Server/Controller/Bookmark/BookmarkIsBookmarkedController.php @@ -38,15 +38,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - the given Location is bookmarked.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized for the given Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the given Location is not bookmarked or does not exist.', - ], + Response::HTTP_OK => new Model\Response(description: 'OK - the given Location is bookmarked.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized for the given Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the given Location is not bookmarked or does not exist.'), ], ), )] @@ -70,15 +64,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - the given Location is bookmarked.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized for the given Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the given Location is not bookmarked or does not exist.', - ], + Response::HTTP_OK => new Model\Response(description: 'OK - the given Location is bookmarked.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized for the given Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the given Location is not bookmarked or does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Bookmark/BookmarkListController.php b/src/lib/Server/Controller/Bookmark/BookmarkListController.php index 6ada38452..d4a26ff58 100644 --- a/src/lib/Server/Controller/Bookmark/BookmarkListController.php +++ b/src/lib/Server/Controller/Bookmark/BookmarkListController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\BookmarkService; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Rest\Server\Controller as RestController; @@ -30,9 +31,9 @@ 'Bookmark', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.BookmarkList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/BookmarkListWrapper', @@ -45,11 +46,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/bookmark/GET/BookmarkList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to list bookmarks.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to list bookmarks.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentCreateController.php b/src/lib/Server/Controller/Content/ContentCreateController.php index caaadc734..900cbe3dc 100644 --- a/src/lib/Server/Controller/Content/ContentCreateController.php +++ b/src/lib/Server/Controller/Content/ContentCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException; use Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException; @@ -46,7 +47,7 @@ ], requestBody: new Model\RequestBody( description: 'The ContentCreate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentCreateWrapper', @@ -62,9 +63,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Content - If set, all information for the content item including the embedded current version is returned in XML or JSON format. ContentInfo - If set, all information for the content item (excluding the current version) is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Content - If set, all information for the content item including the embedded current version is returned in XML or JSON format. ContentInfo - If set, all information for the content item (excluding the current version) is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Content+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentWrapper', @@ -89,17 +90,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/POST/ContentInfo.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition or the validation on a field fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this Object in this Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the parent Location specified in the request body does not exist.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition or the validation on a field fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this Object in this Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the parent Location specified in the request body does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentCurrentVersionRedirectController.php b/src/lib/Server/Controller/Content/ContentCurrentVersionRedirectController.php index 47d589a9c..daed6fb6c 100644 --- a/src/lib/Server/Controller/Content/ContentCurrentVersionRedirectController.php +++ b/src/lib/Server/Controller/Content/ContentCurrentVersionRedirectController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\TemporaryRedirect; use Symfony\Component\HttpFoundation\Response; @@ -33,9 +34,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Version in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Version in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Version+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionWrapper', @@ -48,14 +49,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/currentversion/GET/Version.xml.example', ], - ], - ], - Response::HTTP_TEMPORARY_REDIRECT => [ - 'description' => 'Temporary redirect.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the resource does not exist.', - ], + ]), + ), + Response::HTTP_TEMPORARY_REDIRECT => new Model\Response(description: 'Temporary redirect.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the resource does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentCurrentVersionRelationsRedirectController.php b/src/lib/Server/Controller/Content/ContentCurrentVersionRelationsRedirectController.php index 8392c8f52..727a70b7d 100644 --- a/src/lib/Server/Controller/Content/ContentCurrentVersionRelationsRedirectController.php +++ b/src/lib/Server/Controller/Content/ContentCurrentVersionRelationsRedirectController.php @@ -35,15 +35,9 @@ ), ], responses: [ - Response::HTTP_TEMPORARY_REDIRECT => [ - 'description' => 'Temporary redirect.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item was not found.', - ], + Response::HTTP_TEMPORARY_REDIRECT => new Model\Response(description: 'Temporary redirect.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentDeleteController.php b/src/lib/Server/Controller/Content/ContentDeleteController.php index e89bbdc0b..95680e1fe 100644 --- a/src/lib/Server/Controller/Content/ContentDeleteController.php +++ b/src/lib/Server/Controller/Content/ContentDeleteController.php @@ -42,15 +42,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'The content item is deleted.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - content item was not found.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this content item.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'The content item is deleted.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - content item was not found.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this content item.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentDraftCreateFromCurrentVersionController.php b/src/lib/Server/Controller/Content/ContentDraftCreateFromCurrentVersionController.php index 634c0e0a2..dab513701 100644 --- a/src/lib/Server/Controller/Content/ContentDraftCreateFromCurrentVersionController.php +++ b/src/lib/Server/Controller/Content/ContentDraftCreateFromCurrentVersionController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Exceptions\ForbiddenException; @@ -48,12 +49,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Created', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Created', + content: new ArrayObject([ 'application/vnd.ibexa.api.Version+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionWrapper', @@ -66,17 +67,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/GET/Version.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update this content item.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the current version is already a draft.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item was not found.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update this content item.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the current version is already a draft.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentDraftCreateFromVersionController.php b/src/lib/Server/Controller/Content/ContentDraftCreateFromVersionController.php index 8cb8dd77b..4d6f377a7 100644 --- a/src/lib/Server/Controller/Content/ContentDraftCreateFromVersionController.php +++ b/src/lib/Server/Controller/Content/ContentDraftCreateFromVersionController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values; @@ -54,12 +55,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Version+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionWrapper', @@ -72,14 +73,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/GET/Version.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item was not found.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentDraftTranslationDeleteController.php b/src/lib/Server/Controller/Content/ContentDraftTranslationDeleteController.php index 370d0f855..cd53699f9 100644 --- a/src/lib/Server/Controller/Content/ContentDraftTranslationDeleteController.php +++ b/src/lib/Server/Controller/Content/ContentDraftTranslationDeleteController.php @@ -59,24 +59,12 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - removes a translation from a version draft.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this translation.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the version is not in draft state.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item or version number were not found.', - ], - Response::HTTP_NOT_ACCEPTABLE => [ - 'description' => 'Error - the given translation does not exist for the version.', - ], - Response::HTTP_CONFLICT => [ - 'description' => 'Error - the specified translation is the only one the version has or is the main translation.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - removes a translation from a version draft.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this translation.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the version is not in draft state.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item or version number were not found.'), + Response::HTTP_NOT_ACCEPTABLE => new Model\Response(description: 'Error - the given translation does not exist for the version.'), + Response::HTTP_CONFLICT => new Model\Response(description: 'Error - the specified translation is the only one the version has or is the main translation.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentHideController.php b/src/lib/Server/Controller/Content/ContentHideController.php index 765eac9a0..4c183e6a7 100644 --- a/src/lib/Server/Controller/Content/ContentHideController.php +++ b/src/lib/Server/Controller/Content/ContentHideController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; @@ -45,18 +46,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'OK - Object item is hidden.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to change Object item visibility.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content item was not found.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'OK - Object item is hidden.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to change Object item visibility.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentInVersionLoadController.php b/src/lib/Server/Controller/Content/ContentInVersionLoadController.php index 2df4891dd..b3051044c 100644 --- a/src/lib/Server/Controller/Content/ContentInVersionLoadController.php +++ b/src/lib/Server/Controller/Content/ContentInVersionLoadController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; @@ -55,9 +56,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the version list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the version list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Version+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionWrapper', @@ -70,17 +71,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/GET/Version.xml.example', ], - ], - ], - Response::HTTP_NOT_MODIFIED => [ - 'description' => 'Not Modified - the ETag matches the current one.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the ID or version is not found.', - ], + ]), + ), + Response::HTTP_NOT_MODIFIED => new Model\Response(description: 'Not Modified - the ETag matches the current one.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the ID or version is not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentLoadByIdController.php b/src/lib/Server/Controller/Content/ContentLoadByIdController.php index 55d2ff5d2..030bf23fd 100644 --- a/src/lib/Server/Controller/Content/ContentLoadByIdController.php +++ b/src/lib/Server/Controller/Content/ContentLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -47,9 +48,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Content or ContentInfo in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Content or ContentInfo in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Content+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentWrapper', @@ -72,14 +73,10 @@ '$ref' => '#/components/schemas/ContentInfo', ], ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this object. This could also happen if there is no published version yet and another user owns a draft of this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the ID is not found.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this object. This could also happen if there is no published version yet and another user owns a draft of this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the ID is not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentMetadataUpdateController.php b/src/lib/Server/Controller/Content/ContentMetadataUpdateController.php index 38a20a728..fea1360d2 100644 --- a/src/lib/Server/Controller/Content/ContentMetadataUpdateController.php +++ b/src/lib/Server/Controller/Content/ContentMetadataUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Controller as RestController; @@ -58,7 +59,7 @@ ], requestBody: new Model\RequestBody( description: 'The ContentUpdate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentInfoWrapper', @@ -73,9 +74,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, all information for the content item (excluding the current version) is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, all information for the content item (excluding the current version) is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentInfo+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentInfoWrapper', @@ -87,23 +88,13 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/PATCH/ContentInfo.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update this object.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content ID does not exist.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the one provided in the If-Match header.', - ], - Response::HTTP_UNSUPPORTED_MEDIA_TYPE => [ - 'description' => 'Error - the media-type is not one of those specified in headers.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update this object.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content ID does not exist.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the one provided in the If-Match header.'), + Response::HTTP_UNSUPPORTED_MEDIA_TYPE => new Model\Response(description: 'Error - the media-type is not one of those specified in headers.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentRedirectController.php b/src/lib/Server/Controller/Content/ContentRedirectController.php index e5a3ad21d..948f4b135 100644 --- a/src/lib/Server/Controller/Content/ContentRedirectController.php +++ b/src/lib/Server/Controller/Content/ContentRedirectController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Exceptions\BadRequestException; use Ibexa\Rest\Server\Values\TemporaryRedirect; @@ -38,21 +39,17 @@ ), ], responses: [ - Response::HTTP_TEMPORARY_REDIRECT => [ - 'description' => 'Temporary redirect to `GET /content/objects/{contentId}` equivalent.', - 'headers' => [ + Response::HTTP_TEMPORARY_REDIRECT => new Model\Response( + description: 'Temporary redirect to `GET /content/objects/{contentId}` equivalent.', + headers: new ArrayObject([ 'Location' => [ 'description' => 'Contains the prefixed `/content/objects/{contentId}` absolute path of the content item.', 'schema' => ['type' => 'string'], ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the required `remoteId` query parameter is missing.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content with the given remote ID does not exist.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the required `remoteId` query parameter is missing.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content with the given remote ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentRelationCreateController.php b/src/lib/Server/Controller/Content/ContentRelationCreateController.php index 7d3133f52..dee5e851b 100644 --- a/src/lib/Server/Controller/Content/ContentRelationCreateController.php +++ b/src/lib/Server/Controller/Content/ContentRelationCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Values\Content\Relation; @@ -60,7 +61,7 @@ ], requestBody: new Model\RequestBody( description: 'The RelationCreate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RelationCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RelationCreateWrapper', @@ -76,9 +77,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the updated version is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the updated version is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Relation+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RelationWrapper', @@ -91,8 +92,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/relations/POST/Relation.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentRevealController.php b/src/lib/Server/Controller/Content/ContentRevealController.php index d48c4d3a8..ca71dcde9 100644 --- a/src/lib/Server/Controller/Content/ContentRevealController.php +++ b/src/lib/Server/Controller/Content/ContentRevealController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; @@ -45,18 +46,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'OK - Object item is revealed.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to change Object item visibility.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content item was not found.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'OK - Object item is revealed.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to change Object item visibility.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentTranslationDeleteController.php b/src/lib/Server/Controller/Content/ContentTranslationDeleteController.php index dabe44b87..388472a39 100644 --- a/src/lib/Server/Controller/Content/ContentTranslationDeleteController.php +++ b/src/lib/Server/Controller/Content/ContentTranslationDeleteController.php @@ -50,21 +50,11 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete content item (content/remove policy).', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item was not found.', - ], - Response::HTTP_NOT_ACCEPTABLE => [ - 'description' => 'Error - the given translation does not exist for the content item.', - ], - Response::HTTP_CONFLICT => [ - 'description' => 'Error - the specified translation is the only one any version has or is the main translation.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete content item (content/remove policy).'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item was not found.'), + Response::HTTP_NOT_ACCEPTABLE => new Model\Response(description: 'Error - the given translation does not exist for the content item.'), + Response::HTTP_CONFLICT => new Model\Response(description: 'Error - the specified translation is the only one any version has or is the main translation.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionDeleteController.php b/src/lib/Server/Controller/Content/ContentVersionDeleteController.php index 5537b35c6..e45b28aea 100644 --- a/src/lib/Server/Controller/Content/ContentVersionDeleteController.php +++ b/src/lib/Server/Controller/Content/ContentVersionDeleteController.php @@ -51,18 +51,10 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - the version is deleted.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item or version were not found.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this version.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the version is in published state.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - the version is deleted.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item or version were not found.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this version.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the version is in published state.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionRelationDeleteController.php b/src/lib/Server/Controller/Content/ContentVersionRelationDeleteController.php index 46893849b..09de2e082 100644 --- a/src/lib/Server/Controller/Content/ContentVersionRelationDeleteController.php +++ b/src/lib/Server/Controller/Content/ContentVersionRelationDeleteController.php @@ -64,18 +64,10 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - deleted a Relation of the given draft.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this Relation.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the Relation is not of type COMMON or the given version is not a draft.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - content item or the Relation were not found in the given version.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - deleted a Relation of the given draft.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this Relation.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the Relation is not of type COMMON or the given version is not a draft.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - content item or the Relation were not found in the given version.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionRelationLoadByIdController.php b/src/lib/Server/Controller/Content/ContentVersionRelationLoadByIdController.php index 877ebd67e..27f453245 100644 --- a/src/lib/Server/Controller/Content/ContentVersionRelationLoadByIdController.php +++ b/src/lib/Server/Controller/Content/ContentVersionRelationLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Controller as RestController; @@ -52,9 +53,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - loads a Relation for the given content item.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - loads a Relation for the given content item.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Relation+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RelationWrapper', @@ -67,14 +68,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/relations/relation_id/GET/Relation.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item with the given ID or the Relation does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item with the given ID or the Relation does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionUpdateController.php b/src/lib/Server/Controller/Content/ContentVersionUpdateController.php index 75ee355ce..5e8b283ea 100644 --- a/src/lib/Server/Controller/Content/ContentVersionUpdateController.php +++ b/src/lib/Server/Controller/Content/ContentVersionUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException; use Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException; @@ -70,7 +71,7 @@ ], requestBody: new Model\RequestBody( description: 'The VersionUpdate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.VersionUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionUpdateWrapper', @@ -85,9 +86,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated version is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated version is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Version+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionWrapper', @@ -100,23 +101,13 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/PATCH/Version.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update this version.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the version is not allowed to change - i.e. version is not a DRAFT.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content ID or version ID does not exist.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update this version.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the version is not allowed to change - i.e. version is not a DRAFT.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content ID or version ID does not exist.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionsListController.php b/src/lib/Server/Controller/Content/ContentVersionsListController.php index 2e39fb92d..2e632aa50 100644 --- a/src/lib/Server/Controller/Content/ContentVersionsListController.php +++ b/src/lib/Server/Controller/Content/ContentVersionsListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\VersionList; use Symfony\Component\HttpFoundation\Request; @@ -36,9 +37,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the version list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the version list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.VersionList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionListWrapper', @@ -51,11 +52,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/GET/VersionList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read the versions.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read the versions.'), ], ), )] diff --git a/src/lib/Server/Controller/Content/ContentVersionsRelationsListController.php b/src/lib/Server/Controller/Content/ContentVersionsRelationsListController.php index b1fb36b3b..7b4be14f5 100644 --- a/src/lib/Server/Controller/Content/ContentVersionsRelationsListController.php +++ b/src/lib/Server/Controller/Content/ContentVersionsRelationsListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values; @@ -43,9 +44,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Relation is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Relation is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RelationList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RelationListWrapper', @@ -58,14 +59,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/versions/version_no/relations/GET/RelationList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item was not found.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeCreateController.php b/src/lib/Server/Controller/ContentType/ContentTypeCreateController.php index a417ed07f..6757b6dda 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeCreateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeFieldDefinitionValidationException; use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeValidationException; @@ -57,7 +58,7 @@ ], requestBody: new Model\RequestBody( description: 'The content type Create schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeCreateWrapper', @@ -73,9 +74,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Content type created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Content type created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentType+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeWrapper', @@ -87,17 +88,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/content_type_group_id/types/POST/ContentType.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition. Validation on a Field definition fails. Validation of the content type fails, e.g. multiple Fields of a same singular Field Type are provided. Publish is set to true and the input is not complete e.g. no Field definitions are provided.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create this content type.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A content type with same identifier already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition. Validation on a Field definition fails. Validation of the content type fails, e.g. multiple Fields of a same singular Field Type are provided. Publish is set to true and the input is not complete e.g. no Field definitions are provided.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create this content type.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A content type with same identifier already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeCreateViewController.php b/src/lib/Server/Controller/ContentType/ContentTypeCreateViewController.php index 8189717f1..7717cda5a 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeCreateViewController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeCreateViewController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Controller as RestController; @@ -41,7 +42,7 @@ ], requestBody: new Model\RequestBody( description: 'The view input in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeViewInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeViewInputWrapper', @@ -57,9 +58,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'The view in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'The view in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeInfoListWrapper', @@ -72,11 +73,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/GET/ContentTypeInfoList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDeleteController.php b/src/lib/Server/Controller/ContentType/ContentTypeDeleteController.php index 6a73c397c..0ef35cac3 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDeleteController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDeleteController.php @@ -46,18 +46,10 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - content type deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete this content type.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - There are object instances of this content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - content type deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete this content type.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - There are object instances of this content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftCreateController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftCreateController.php index 7cc5727d5..bfa5c3d0f 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftCreateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\BadStateException; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; @@ -53,7 +54,7 @@ ], requestBody: new Model\RequestBody( description: 'The content type Update schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeUpdateWrapper', @@ -69,9 +70,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Draft created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Draft created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeInfo+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeInfoWrapper', @@ -84,17 +85,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/POST/ContentTypeInfo.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create the draft.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A content type with the given new identifier already exists. A draft already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create the draft.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A content type with the given new identifier already exists. A draft already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftDeleteController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftDeleteController.php index 525370069..ca10ac007 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftDeleteController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftDeleteController.php @@ -43,15 +43,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - content type draft deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete this content type draft.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type draft does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - content type draft deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete this content type draft.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type draft does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionAddController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionAddController.php index b551934f4..8d3b59f8e 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionAddController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionAddController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\BadStateException; use Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeFieldDefinitionValidationException; @@ -55,7 +56,7 @@ ], requestBody: new Model\RequestBody( description: 'The Field Definition Create schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinitionCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionCreateWrapper', @@ -70,9 +71,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Field definition created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Field definition created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinition+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionWrapper', @@ -85,17 +86,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/draft/field_definitions/POST/FieldDefinition.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition or validation on the Field definition fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to add a Field definition.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A Field definition with the same identifier already exists in the given content type. The Field definition is of singular type, already existing in the given content type. The Field definition you want to add is of a type that can\'t be added to a content type that already has content instances.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition or validation on the Field definition fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to add a Field definition.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A Field definition with the same identifier already exists in the given content type. The Field definition is of singular type, already existing in the given content type. The Field definition you want to add is of a type that can\'t be added to a content type that already has content instances.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionDeleteController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionDeleteController.php index 7864b7f6e..061fdb3fa 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionDeleteController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionDeleteController.php @@ -55,15 +55,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - Field definition deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete this content type.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - There is no draft of the content type assigned to the authenticated user.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - Field definition deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete this content type.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - There is no draft of the content type assigned to the authenticated user.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionListController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionListController.php index a641d32bd..6ec6f4a34 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionListController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\FieldDefinitionList; @@ -34,9 +35,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - return a list of Field definitions.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - return a list of Field definitions.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinitionList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionsWrapper', @@ -47,11 +48,9 @@ '$ref' => '#/components/schemas/FieldDefinitions', ], ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type draft does not exist.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type draft does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionLoadByIdController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionLoadByIdController.php index be015b966..da61b878e 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionLoadByIdController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Controller as RestController; @@ -44,9 +45,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Field definition.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Field definition.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinition+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionWrapper', @@ -59,14 +60,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/draft/field_definitions/field_definition_id/GET/FieldDefinition.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read the content type draft.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type or draft does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read the content type draft.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type or draft does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionUpdateController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionUpdateController.php index 049d65957..971d002ba 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionUpdateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftFieldDefinitionUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Rest\Exceptions; @@ -60,7 +61,7 @@ ], requestBody: new Model\RequestBody( description: 'The Field definition update schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinitionUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionUpdateWrapper', @@ -75,9 +76,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - attributes updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - attributes updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinition+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionWrapper', @@ -90,17 +91,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/draft/field_definitions/field_definition_id/PATCH/FieldDefinition.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to update the Field definition.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A Field definition with the given identifier already exists in the given content type.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to update the Field definition.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A Field definition with the given identifier already exists in the given content type.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftLoadController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftLoadController.php index 32790a425..fd6143048 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftLoadController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftLoadController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\RestContentType; @@ -34,9 +35,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the content type.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the content type.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentType+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeWrapper', @@ -49,14 +50,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/draft/PUBLISH/ContentType.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist or does not have a draft.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist or does not have a draft.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeDraftUpdateController.php b/src/lib/Server/Controller/ContentType/ContentTypeDraftUpdateController.php index 014dadd91..678c1a6df 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeDraftUpdateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeDraftUpdateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Rest\Message; @@ -53,7 +54,7 @@ ], requestBody: new Model\RequestBody( description: 'The content type update schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeUpdateWrapper', @@ -69,9 +70,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'Draft metadata updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'Draft metadata updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeInfo+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeInfoWrapper', @@ -84,20 +85,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/draft/PATCH/ContentTypeInfo.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to update the draft.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A content type with the given new identifier already exists.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - There is no draft for this content type.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to update the draft.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A content type with the given new identifier already exists.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - There is no draft for this content type.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionListController.php b/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionListController.php index 30996e574..4d3371d84 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionListController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -35,9 +36,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - return a list of Field definitions.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - return a list of Field definitions.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinitionList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionsWrapper', @@ -48,11 +49,9 @@ '$ref' => '#/components/schemas/FieldDefinitions', ], ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionLoadByIdController.php b/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionLoadByIdController.php index 716804949..dbb958aa2 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionLoadByIdController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeFieldDefinitionLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Rest\Exceptions; @@ -45,9 +46,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Field definition.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Field definition.', + content: new ArrayObject([ 'application/vnd.ibexa.api.FieldDefinition+json' => [ 'schema' => [ '$ref' => '#/components/schemas/FieldDefinitionWrapper', @@ -60,14 +61,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/field_definition_id/GET/FieldDefinition.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read the content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read the content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupCreateController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupCreateController.php index bfba3e852..18ab22ac7 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupCreateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Rest\Message; @@ -43,7 +44,7 @@ ], requestBody: new Model\RequestBody( description: 'The content type group input schema encoded in XML or JSON.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupInputWrapper', @@ -59,9 +60,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Content type group created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Content type group created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupWrapper', @@ -74,17 +75,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/POST/ContentTypeGroup.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create this content type group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A content type group with the same identifier already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create this content type group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A content type group with the same identifier already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupDeleteController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupDeleteController.php index c96c35f97..9c5bef0ff 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupDeleteController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupDeleteController.php @@ -44,18 +44,10 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - content type group deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete this content type group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - The content type group is not empty.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type group does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - content type group deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete this content type group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - The content type group is not empty.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupListController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupListController.php index f5dea372b..1c18ba526 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupListController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -35,9 +36,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the content type group list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the content type group list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupRefList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupRefListWrapper', @@ -50,14 +51,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/groups/GET/ContentTypeGroupRefList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupLoadByIdController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupLoadByIdController.php index 27d6410c0..7dbfd5ca4 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupLoadByIdController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup; @@ -44,9 +45,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the content type group.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the content type group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeListWrapper', @@ -59,14 +60,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/content_type_group_id/GET/ContentTypeGroup.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this content type group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type group does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this content type group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupUpdateController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupUpdateController.php index bffb892a3..90996e8a1 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupUpdateController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -63,7 +64,7 @@ ], requestBody: new Model\RequestBody( description: 'The content type group input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupInputWrapper', @@ -79,9 +80,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'Content type group updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'Content type group updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupWrapper', @@ -94,20 +95,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/content_type_group_id/PATCH/ContentTypeGroup.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create this content type group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A content type group with the given identifier already exists.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - The current ETag does not match the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create this content type group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A content type group with the given identifier already exists.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - The current ETag does not match the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeGroupsListController.php b/src/lib/Server/Controller/ContentType/ContentTypeGroupsListController.php index 90a6451a9..67c439cf6 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeGroupsListController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeGroupsListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -26,9 +27,9 @@ 'Type Groups', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list of content type groups.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list of content type groups.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupListWrapper', @@ -41,17 +42,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/GET/ContentTypeGroupList.xml.example', ], - ], - ], - Response::HTTP_TEMPORARY_REDIRECT => [ - 'description' => 'Temporary redirect.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read content types.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type group with the given identifier does not exist.', - ], + ]), + ), + Response::HTTP_TEMPORARY_REDIRECT => new Model\Response(description: 'Temporary redirect.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read content types.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type group with the given identifier does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeLinkToGroupController.php b/src/lib/Server/Controller/ContentType/ContentTypeLinkToGroupController.php index 33b3c6be6..d017864bd 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeLinkToGroupController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeLinkToGroupController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Controller as RestController; @@ -59,12 +60,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated content type group list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated content type group list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupRefList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupRefListWrapper', @@ -77,17 +78,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/groups/POST/ContentTypeGroupRefList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to add a group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - The content type is already assigned to the group.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to add a group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - The content type is already assigned to the group.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeListController.php b/src/lib/Server/Controller/ContentType/ContentTypeListController.php index 1787067ef..97b5de0f5 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeListController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; @@ -32,9 +33,9 @@ 'Type', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list of content types.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list of content types.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeInfoList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeInfoListWrapper', @@ -57,11 +58,9 @@ '$ref' => '#/components/schemas/ContentTypeList', ], ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read the content types.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read the content types.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeListForGroupController.php b/src/lib/Server/Controller/ContentType/ContentTypeListForGroupController.php index 0355aaaac..47d90da84 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeListForGroupController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeListForGroupController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -39,9 +40,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list on content types.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list on content types.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeInfoList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeInfoListWrapper', @@ -66,11 +67,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/typegroups/content_type_group_id/types/GET/ContentTypeList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read the content types.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read the content types.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeLoadByIdController.php b/src/lib/Server/Controller/ContentType/ContentTypeLoadByIdController.php index 8415612b9..3dd6fa19a 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeLoadByIdController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Controller as RestController; @@ -44,9 +45,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the content type.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the content type.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentType+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeWrapper', @@ -59,14 +60,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/GET/ContentType.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content type does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content type does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ContentType/ContentTypeUnlinkFromGroupController.php b/src/lib/Server/Controller/ContentType/ContentTypeUnlinkFromGroupController.php index 175cfa95d..1965da9e1 100644 --- a/src/lib/Server/Controller/ContentType/ContentTypeUnlinkFromGroupController.php +++ b/src/lib/Server/Controller/ContentType/ContentTypeUnlinkFromGroupController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Controller as RestController; @@ -53,9 +54,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated content type group list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated content type group list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentTypeGroupRefList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentTypeGroupRefListWrapper', @@ -68,17 +69,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/types/content_type_id/groups/id/DELETE/ContentTypeGroupRefList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete this content type.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - content type cannot be unlinked from the only remaining group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The resource does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete this content type.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - content type cannot be unlinked from the only remaining group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The resource does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/JWT.php b/src/lib/Server/Controller/JWT.php index 9ad54d68a..268e692b6 100644 --- a/src/lib/Server/Controller/JWT.php +++ b/src/lib/Server/Controller/JWT.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -26,7 +27,7 @@ ], requestBody: new Model\RequestBody( description: 'The credentials in JWTInput JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.JWTInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/JWTInputWrapper', @@ -36,20 +37,18 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the JWT in JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the JWT in JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.JWT+json' => [ 'schema' => [ '$ref' => '#/components/schemas/JWTWrapper', ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/token/jwt/POST/JWT.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - Unauthorized', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - Unauthorized'), ], ), )] diff --git a/src/lib/Server/Controller/Language/LanguageListController.php b/src/lib/Server/Controller/Language/LanguageListController.php index c641ca566..76f77d9c0 100644 --- a/src/lib/Server/Controller/Language/LanguageListController.php +++ b/src/lib/Server/Controller/Language/LanguageListController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LanguageService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\LanguageList; @@ -28,9 +29,9 @@ 'Language', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.LanguageList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LanguageListWrapper', @@ -43,8 +44,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/GET/LanguageList.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Language/LanguageLoadByIdController.php b/src/lib/Server/Controller/Language/LanguageLoadByIdController.php index ba4b6b2f4..78899a039 100644 --- a/src/lib/Server/Controller/Language/LanguageLoadByIdController.php +++ b/src/lib/Server/Controller/Language/LanguageLoadByIdController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LanguageService; use Ibexa\Contracts\Core\Repository\Values\Content\Language as ApiLanguage; use Ibexa\Rest\Server\Controller as RestController; @@ -36,9 +37,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the language is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the language is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Language+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LanguageWrapper', @@ -51,8 +52,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/languages/code/GET/Language.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationChildrenListController.php b/src/lib/Server/Controller/Location/LocationChildrenListController.php index a0cb5aa5d..b15971fdd 100644 --- a/src/lib/Server/Controller/Location/LocationChildrenListController.php +++ b/src/lib/Server/Controller/Location/LocationChildrenListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -33,9 +34,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the new Location list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the new Location list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.LocationList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationListWrapper', @@ -47,14 +48,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/locations/path/children/GET/LocationList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item with the given ID does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item with the given ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationCreateController.php b/src/lib/Server/Controller/Location/LocationCreateController.php index 9128a8ee5..8911403f3 100644 --- a/src/lib/Server/Controller/Location/LocationCreateController.php +++ b/src/lib/Server/Controller/Location/LocationCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Exceptions\ForbiddenException; @@ -50,7 +51,7 @@ ], requestBody: new Model\RequestBody( description: 'The LocationCreate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.LocationCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationCreateWrapper', @@ -66,9 +67,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the new Location is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the new Location is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Location+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationWrapper', @@ -81,17 +82,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/locations/POST/Location.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this Location.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - a Location under the given parent ID already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this Location.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - a Location under the given parent ID already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationForContentListController.php b/src/lib/Server/Controller/Location/LocationForContentListController.php index e2e23d502..08b7fc7ca 100644 --- a/src/lib/Server/Controller/Location/LocationForContentListController.php +++ b/src/lib/Server/Controller/Location/LocationForContentListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -42,9 +43,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Location list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Location list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.LocationList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationListWrapper', @@ -57,14 +58,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/locations/GET/LocationList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this content item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the content item with the given ID does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this content item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the content item with the given ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationLoadByPathController.php b/src/lib/Server/Controller/Location/LocationLoadByPathController.php index d223286c2..520a889e9 100644 --- a/src/lib/Server/Controller/Location/LocationLoadByPathController.php +++ b/src/lib/Server/Controller/Location/LocationLoadByPathController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; @@ -42,9 +43,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the new Location is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the new Location is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Location+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationWrapper', @@ -57,14 +58,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/locations/path/GET/Location.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to read this Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Location with the given path does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to read this Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Location with the given path does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationRedirectController.php b/src/lib/Server/Controller/Location/LocationRedirectController.php index 14e3fc2a7..58b03fed9 100644 --- a/src/lib/Server/Controller/Location/LocationRedirectController.php +++ b/src/lib/Server/Controller/Location/LocationRedirectController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Exceptions\BadRequestException; use Ibexa\Rest\Server\Values\TemporaryRedirect; use Symfony\Component\HttpFoundation\Request; @@ -24,9 +25,9 @@ 'Location', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the LocationList in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the LocationList in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.LocationList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationWrapper', @@ -39,14 +40,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/locations/GET/LocationList.xml.example', ], - ], - ], - Response::HTTP_TEMPORARY_REDIRECT => [ - 'description' => 'Temporary redirect to the main resource URL.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Location with the given ID (remote ID or URL Alias) does not exist.', - ], + ]), + ), + Response::HTTP_TEMPORARY_REDIRECT => new Model\Response(description: 'Temporary redirect to the main resource URL.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Location with the given ID (remote ID or URL Alias) does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationSubtreeDeleteController.php b/src/lib/Server/Controller/Location/LocationSubtreeDeleteController.php index 74d6f783c..d9f1a22b2 100644 --- a/src/lib/Server/Controller/Location/LocationSubtreeDeleteController.php +++ b/src/lib/Server/Controller/Location/LocationSubtreeDeleteController.php @@ -41,15 +41,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this subtree.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Location with the given ID does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this subtree.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Location with the given ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Location/LocationUpdateController.php b/src/lib/Server/Controller/Location/LocationUpdateController.php index 0ade250c3..0c74ebbb5 100644 --- a/src/lib/Server/Controller/Location/LocationUpdateController.php +++ b/src/lib/Server/Controller/Location/LocationUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Values\RestLocation; use Symfony\Component\HttpFoundation\Request; @@ -55,7 +56,7 @@ ], requestBody: new Model\RequestBody( description: 'The LocationUpdate schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.LocationUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationUpdateStructWrapper', @@ -71,9 +72,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Location is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Location is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Location+json' => [ 'schema' => [ '$ref' => '#/components/schemas/LocationWrapper', @@ -86,14 +87,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/locations/location_id/PATCH/Location.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update this Location.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Location with the given ID does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update this Location.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Location with the given ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateCreateController.php b/src/lib/Server/Controller/ObjectState/ObjectStateCreateController.php index a2b05d20c..1e9eabf66 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateCreateController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\ObjectStateService; @@ -53,7 +54,7 @@ ], requestBody: new Model\RequestBody( description: 'The Object state input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateCreateWrapper', @@ -69,9 +70,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Object state created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Object state created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectState+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateWrapper', @@ -84,17 +85,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/objectstates/POST/ObjectState.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create an Object state.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - An Object state with the same identifier already exists in the given group.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create an Object state.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - An Object state with the same identifier already exists in the given group.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateDeleteController.php b/src/lib/Server/Controller/ObjectState/ObjectStateDeleteController.php index 939948526..a1b1f4c78 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateDeleteController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateDeleteController.php @@ -52,15 +52,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - Object state deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete an Object state.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The Object state does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - Object state deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete an Object state.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The Object state does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateGroupCreateController.php b/src/lib/Server/Controller/ObjectState/ObjectStateGroupCreateController.php index 613585243..ad816efb6 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateGroupCreateController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateGroupCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\ObjectStateService; @@ -44,7 +45,7 @@ ], requestBody: new Model\RequestBody( description: 'The Object state group input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroupCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupCreateWrapper', @@ -60,9 +61,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Object state group created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Object state group created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupWrapper', @@ -75,17 +76,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/POST/ObjectStateGroup.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create an Object state group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - An Object state group with the same identifier already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create an Object state group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - An Object state group with the same identifier already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateGroupDeleteController.php b/src/lib/Server/Controller/ObjectState/ObjectStateGroupDeleteController.php index 714a736a7..b78c65e54 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateGroupDeleteController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateGroupDeleteController.php @@ -44,15 +44,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - Object state group deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete an Object state group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The Object state group does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - Object state group deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete an Object state group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The Object state group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateGroupListController.php b/src/lib/Server/Controller/ObjectState/ObjectStateGroupListController.php index 0c790ddeb..89cb121a7 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateGroupListController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateGroupListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -39,9 +40,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list of Object state groups.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list of Object state groups.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroupList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupListWrapper', @@ -54,11 +55,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/GET/ObjectStateGroupList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read Object state groups.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read Object state groups.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateGroupLoadByIdController.php b/src/lib/Server/Controller/ObjectState/ObjectStateGroupLoadByIdController.php index 8ca06ddf4..469e1c8e2 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateGroupLoadByIdController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateGroupLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -45,9 +46,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Object state group.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Object state group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupWrapper', @@ -60,14 +61,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/GET/ObjectStateGroup.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this Object state group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The Object state group does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this Object state group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The Object state group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateGroupUpdateController.php b/src/lib/Server/Controller/ObjectState/ObjectStateGroupUpdateController.php index 2879cf67b..89a97aea6 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateGroupUpdateController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateGroupUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\ObjectStateService; @@ -60,7 +61,7 @@ ], requestBody: new Model\RequestBody( description: 'The Object state group input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroupUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupUpdateWrapper', @@ -76,9 +77,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Object stated group updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Object stated group updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateGroup+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateGroupWrapper', @@ -91,20 +92,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/PATCH/ObjectStateGroup.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to update an Object state group.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - An Object state group with the provided identifier already exists.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - The current ETag does not match the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to update an Object state group.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - An Object state group with the provided identifier already exists.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - The current ETag does not match the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateListController.php b/src/lib/Server/Controller/ObjectState/ObjectStateListController.php index 7b2f948a0..0712a9acb 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateListController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -47,9 +48,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list of Object states.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list of Object states.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateListWrapper', @@ -62,11 +63,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/objectstates/GET/ObjectStateList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read Object states.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read Object states.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateLoadByIdController.php b/src/lib/Server/Controller/ObjectState/ObjectStateLoadByIdController.php index 9b4785fc5..70a7ec6bb 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateLoadByIdController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -53,9 +54,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Object state.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Object state.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectState+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateWrapper', @@ -68,14 +69,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/objectstates/object_state_id/GET/ObjectState.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this Object state.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The Object state does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this Object state.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The Object state does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStateUpdateController.php b/src/lib/Server/Controller/ObjectState/ObjectStateUpdateController.php index d15c2bec4..2befc3e74 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStateUpdateController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStateUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\ObjectStateService; @@ -69,7 +70,7 @@ ], requestBody: new Model\RequestBody( description: 'The Object state input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectStateUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateUpdateWrapper', @@ -85,9 +86,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Object State updated', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Object State updated', + content: new ArrayObject([ 'application/vnd.ibexa.api.ObjectState+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ObjectStateWrapper', @@ -100,20 +101,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objectstategroups/object_state_group_id/objectstates/object_state_id/PATCH/ObjectState.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to update the Object state.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - An Object state with the provided identifier already exists in this group.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - The current ETag does not match the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to update the Object state.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - An Object state with the provided identifier already exists in this group.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - The current ETag does not match the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStatesForContentListController.php b/src/lib/Server/Controller/ObjectState/ObjectStatesForContentListController.php index ea0f07a66..3e3fc7c03 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStatesForContentListController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStatesForContentListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\ObjectStateService; @@ -48,9 +49,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the Object state.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the Object state.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentObjectStates+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentObjectStates', @@ -63,11 +64,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/objectstates/GET/ContentObjectStates.xml.example', ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The content item does not exist.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The content item does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/ObjectState/ObjectStatesForContentUpdateController.php b/src/lib/Server/Controller/ObjectState/ObjectStatesForContentUpdateController.php index 23417ea51..22f4dc7aa 100644 --- a/src/lib/Server/Controller/ObjectState/ObjectStatesForContentUpdateController.php +++ b/src/lib/Server/Controller/ObjectState/ObjectStatesForContentUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ObjectStateService; use Ibexa\Rest\Message; @@ -60,7 +61,7 @@ ], requestBody: new Model\RequestBody( description: 'The content item Object states input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentObjectStates+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentObjectStatesWrapper', @@ -76,9 +77,9 @@ ]), ), responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'OK - Object state updated.', - 'content' => [ + Response::HTTP_NO_CONTENT => new Model\Response( + description: 'OK - Object state updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.ContentObjectStates+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ContentObjectStatesWrapper', @@ -91,20 +92,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/objects/content_id/objectstates/PATCH/ContentObjectStates.response.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to set an Object state.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - The input contains multiple Object states of the same Object state group.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - The current ETag does not match the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to set an Object state.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - The input contains multiple Object states of the same Object state group.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - The current ETag does not match the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignToUserController.php b/src/lib/Server/Controller/Role/RoleAssignToUserController.php index 937d236de..78e31ce64 100644 --- a/src/lib/Server/Controller/Role/RoleAssignToUserController.php +++ b/src/lib/Server/Controller/Role/RoleAssignToUserController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Exceptions\BadRequestException; @@ -48,7 +49,7 @@ ], requestBody: new Model\RequestBody( description: 'The RoleAssignInput schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignInputWrapper', @@ -64,9 +65,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -79,14 +80,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/roles/POST/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - validation of limitation in RoleAssignInput fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to assign this Role.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - validation of limitation in RoleAssignInput fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to assign this Role.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignToUserGroupController.php b/src/lib/Server/Controller/Role/RoleAssignToUserGroupController.php index 5aaed075c..68edee0c7 100644 --- a/src/lib/Server/Controller/Role/RoleAssignToUserGroupController.php +++ b/src/lib/Server/Controller/Role/RoleAssignToUserGroupController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Exceptions\BadRequestException; @@ -48,7 +49,7 @@ ], requestBody: new Model\RequestBody( description: 'The RoleAssignInput schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignInputWrapper', @@ -64,9 +65,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -79,14 +80,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/roles/POST/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - validation of limitation in RoleAssignInput fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to assign this Role.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - validation of limitation in RoleAssignInput fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to assign this Role.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupListController.php b/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupListController.php index ab593d2a2..703feb6bf 100644 --- a/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupListController.php +++ b/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values\RoleAssignmentList; use Symfony\Component\HttpFoundation\Response; @@ -34,9 +35,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -49,11 +50,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/roles/GET/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupLoadByIdController.php b/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupLoadByIdController.php index c1135092e..d8b4b95fc 100644 --- a/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupLoadByIdController.php +++ b/src/lib/Server/Controller/Role/RoleAssignmentForUserGroupLoadByIdController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Values\RestUserGroupRoleAssignment; use Symfony\Component\HttpFoundation\Request; @@ -44,9 +45,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a Role assignment of the given User Group.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a Role assignment of the given User Group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignment+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentWrapper', @@ -59,11 +60,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/roles/role_id/GET/RoleAssignment.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignmentForUserListController.php b/src/lib/Server/Controller/Role/RoleAssignmentForUserListController.php index 7d022c9e1..5f1d7fa73 100644 --- a/src/lib/Server/Controller/Role/RoleAssignmentForUserListController.php +++ b/src/lib/Server/Controller/Role/RoleAssignmentForUserListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values\RoleAssignmentList; use Symfony\Component\HttpFoundation\Response; @@ -34,9 +35,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -49,11 +50,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/roles/GET/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleAssignmentForUserLoadByIdController.php b/src/lib/Server/Controller/Role/RoleAssignmentForUserLoadByIdController.php index 28f3276f5..73a8a0e47 100644 --- a/src/lib/Server/Controller/Role/RoleAssignmentForUserLoadByIdController.php +++ b/src/lib/Server/Controller/Role/RoleAssignmentForUserLoadByIdController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Rest\Server\Values\RestUserRoleAssignment; use Symfony\Component\HttpFoundation\Request; @@ -44,9 +45,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Role assignment to the given User Group.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Role assignment to the given User Group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignment+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentWrapper', @@ -59,11 +60,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/roles/role_id/GET/RoleAssignment.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleCreateController.php b/src/lib/Server/Controller/Role/RoleCreateController.php index c6ea1fa90..e40b542d3 100644 --- a/src/lib/Server/Controller/Role/RoleCreateController.php +++ b/src/lib/Server/Controller/Role/RoleCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Contracts\Rest\Exceptions; use Ibexa\Core\Base\Exceptions\ForbiddenException; @@ -47,7 +48,7 @@ ], requestBody: new Model\RequestBody( description: 'The RoleInput schema encoded in XML or JSON.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleInputWrapper', @@ -63,9 +64,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the new user is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the new user is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Role+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleWrapper', @@ -78,14 +79,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/POST/Role.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create a Role or a Role draft.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create a Role or a Role draft.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleDeleteController.php b/src/lib/Server/Controller/Role/RoleDeleteController.php index 09d1eca2d..03bf60fab 100644 --- a/src/lib/Server/Controller/Role/RoleDeleteController.php +++ b/src/lib/Server/Controller/Role/RoleDeleteController.php @@ -43,12 +43,8 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the User is not authorized to delete this Role.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the User is not authorized to delete this Role.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleDraftCreateController.php b/src/lib/Server/Controller/Role/RoleDraftCreateController.php index a2a98c696..e1e975beb 100644 --- a/src/lib/Server/Controller/Role/RoleDraftCreateController.php +++ b/src/lib/Server/Controller/Role/RoleDraftCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Core\Base\Exceptions\ForbiddenException; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; @@ -50,12 +51,12 @@ ], requestBody: new Model\RequestBody( description: 'No payload required', - content: new \ArrayObject(), + content: new ArrayObject(), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the new user is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the new user is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleDraft+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleDraftWrapper', @@ -68,11 +69,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/POST/RoleDraft.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create a Role or a Role draft', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create a Role or a Role draft'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleDraftDeleteController.php b/src/lib/Server/Controller/Role/RoleDraftDeleteController.php index a128c2aac..ed0d05f23 100644 --- a/src/lib/Server/Controller/Role/RoleDraftDeleteController.php +++ b/src/lib/Server/Controller/Role/RoleDraftDeleteController.php @@ -43,12 +43,8 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this Role.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this Role.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleDraftLoadByRoleIdController.php b/src/lib/Server/Controller/Role/RoleDraftLoadByRoleIdController.php index bb51da8be..1cdeb94a0 100644 --- a/src/lib/Server/Controller/Role/RoleDraftLoadByRoleIdController.php +++ b/src/lib/Server/Controller/Role/RoleDraftLoadByRoleIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Values\User\RoleDraft; use Symfony\Component\HttpFoundation\Response; @@ -42,9 +43,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Role draft by original Role ID.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Role draft by original Role ID.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Role+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleWrapper', @@ -57,14 +58,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/draft/GET/Role.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - there is no draft or Role with the given ID.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - there is no draft or Role with the given ID.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleDraftUpdateController.php b/src/lib/Server/Controller/Role/RoleDraftUpdateController.php index 9cf2006b9..369c780f5 100644 --- a/src/lib/Server/Controller/Role/RoleDraftUpdateController.php +++ b/src/lib/Server/Controller/Role/RoleDraftUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Values\User\RoleDraft; use Ibexa\Rest\Message; @@ -56,7 +57,7 @@ ], requestBody: new Model\RequestBody( description: 'The RoleInput schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleInputWrapper', @@ -72,9 +73,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Role draft updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Role draft updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Role+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleWrapper', @@ -87,20 +88,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/draft/PATCH/Role.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update the Role.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - there is no draft or Role with the given ID.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update the Role.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - there is no draft or Role with the given ID.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleListController.php b/src/lib/Server/Controller/Role/RoleListController.php index da7baa936..148d1de90 100644 --- a/src/lib/Server/Controller/Role/RoleListController.php +++ b/src/lib/Server/Controller/Role/RoleListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException as APINotFoundException; use Ibexa\Rest\Server\Values\RoleList; use Symfony\Component\HttpFoundation\Request; @@ -26,9 +27,9 @@ 'User Role', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - list of all Roles.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - list of all Roles.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleListWrapper', @@ -41,11 +42,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/GET/RoleList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleLoadByIdController.php b/src/lib/Server/Controller/Role/RoleLoadByIdController.php index a83c266d8..bf7512979 100644 --- a/src/lib/Server/Controller/Role/RoleLoadByIdController.php +++ b/src/lib/Server/Controller/Role/RoleLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\User\Role; use Symfony\Component\HttpFoundation\Response; @@ -41,9 +42,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Role for the given ID.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Role for the given ID.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Role+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleWrapper', @@ -56,14 +57,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/GET/Role.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePoliciesForUserListController.php b/src/lib/Server/Controller/Role/RolePoliciesForUserListController.php index be367c1f4..5d1bcd97d 100644 --- a/src/lib/Server/Controller/Role/RolePoliciesForUserListController.php +++ b/src/lib/Server/Controller/Role/RolePoliciesForUserListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values\PolicyList; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -25,9 +26,9 @@ 'User Policy', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Policies which are applied to a given User.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Policies which are applied to a given User.', + content: new ArrayObject([ 'application/vnd.ibexa.api.PolicyList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyListWrapper', @@ -40,11 +41,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/policies/GET/PolicyList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyCreateController.php b/src/lib/Server/Controller/Role/RolePolicyCreateController.php index 6ae3026ad..ff2188ec2 100644 --- a/src/lib/Server/Controller/Role/RolePolicyCreateController.php +++ b/src/lib/Server/Controller/Role/RolePolicyCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Rest\Message; @@ -49,7 +50,7 @@ ], requestBody: new Model\RequestBody( description: 'If set, the updated Policy is returned in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.PolicyCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyCreateWrapper', @@ -64,9 +65,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the updated Policy is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the updated Policy is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Policy+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyWrapper', @@ -79,17 +80,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/policies/POST/Policy.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition or validation of limitation in PolicyCreate fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create the Policy.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role does not exist.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition or validation of limitation in PolicyCreate fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create the Policy.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyDeleteAllFromRoleController.php b/src/lib/Server/Controller/Role/RolePolicyDeleteAllFromRoleController.php index 37933bf69..3723d3866 100644 --- a/src/lib/Server/Controller/Role/RolePolicyDeleteAllFromRoleController.php +++ b/src/lib/Server/Controller/Role/RolePolicyDeleteAllFromRoleController.php @@ -43,12 +43,8 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - all Policies of the given Role are deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this content type.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - all Policies of the given Role are deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this content type.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyDeleteController.php b/src/lib/Server/Controller/Role/RolePolicyDeleteController.php index f81ca3f3f..18ead3beb 100644 --- a/src/lib/Server/Controller/Role/RolePolicyDeleteController.php +++ b/src/lib/Server/Controller/Role/RolePolicyDeleteController.php @@ -45,15 +45,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - the given Policy is deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this content type.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role or Policy does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - the given Policy is deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this content type.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role or Policy does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyListController.php b/src/lib/Server/Controller/Role/RolePolicyListController.php index 5aafbd44d..e6e89cf81 100644 --- a/src/lib/Server/Controller/Role/RolePolicyListController.php +++ b/src/lib/Server/Controller/Role/RolePolicyListController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values\PolicyList; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -33,9 +34,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Policy list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Policy list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.PolicyList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyListWrapper', @@ -48,14 +49,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/policies/GET/PolicyList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyLoadByIdController.php b/src/lib/Server/Controller/Role/RolePolicyLoadByIdController.php index 98aee5a7a..a838a5e7c 100644 --- a/src/lib/Server/Controller/Role/RolePolicyLoadByIdController.php +++ b/src/lib/Server/Controller/Role/RolePolicyLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\User\Policy; use Ibexa\Contracts\Rest\Exceptions; use Symfony\Component\HttpFoundation\Request; @@ -43,9 +44,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Policy is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Policy is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Policy+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyWrapper', @@ -58,14 +59,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/policies/id/GET/Policy.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Roles.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role or Policy does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Roles.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role or Policy does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RolePolicyUpdateController.php b/src/lib/Server/Controller/Role/RolePolicyUpdateController.php index 55def0d5a..8d1d50d84 100644 --- a/src/lib/Server/Controller/Role/RolePolicyUpdateController.php +++ b/src/lib/Server/Controller/Role/RolePolicyUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\LimitationValidationException; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Values\User\Policy; @@ -60,7 +61,7 @@ ], requestBody: new Model\RequestBody( description: 'If set, the updated Policy is returned in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.PolicyUpdate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyUpdateWrapper', @@ -75,9 +76,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated Policy is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated Policy is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Policy+json' => [ 'schema' => [ '$ref' => '#/components/schemas/PolicyWrapper', @@ -90,20 +91,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/policies/id/PATCH/Policy.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition or validation of limitation in PolicyUpdate fails.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update the Policy.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Role does not exist.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition or validation of limitation in PolicyUpdate fails.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update the Policy.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Role does not exist.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleUnassignFromUserController.php b/src/lib/Server/Controller/Role/RoleUnassignFromUserController.php index 4c228b481..06200fd28 100644 --- a/src/lib/Server/Controller/Role/RoleUnassignFromUserController.php +++ b/src/lib/Server/Controller/Role/RoleUnassignFromUserController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; @@ -51,9 +52,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -66,11 +67,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/roles/role_id/DELETE/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this content type.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this content type.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleUnassignFromUserGroupController.php b/src/lib/Server/Controller/Role/RoleUnassignFromUserGroupController.php index f23594681..41b8556a6 100644 --- a/src/lib/Server/Controller/Role/RoleUnassignFromUserGroupController.php +++ b/src/lib/Server/Controller/Role/RoleUnassignFromUserGroupController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; @@ -51,9 +52,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the updated Role assignment list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the updated Role assignment list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleAssignmentList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleAssignmentListWrapper', @@ -66,11 +67,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/roles/role_id/DELETE/RoleAssignmentList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this Role assignment.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this Role assignment.'), ], ), )] diff --git a/src/lib/Server/Controller/Role/RoleUpdateController.php b/src/lib/Server/Controller/Role/RoleUpdateController.php index d315db239..38cc06165 100644 --- a/src/lib/Server/Controller/Role/RoleUpdateController.php +++ b/src/lib/Server/Controller/Role/RoleUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\User\Role; use Ibexa\Rest\Message; use Symfony\Component\HttpFoundation\Request; @@ -55,7 +56,7 @@ ], requestBody: new Model\RequestBody( description: 'The RoleInput schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.RoleInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleInputWrapper', @@ -71,9 +72,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Role updated', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Role updated', + content: new ArrayObject([ 'application/vnd.ibexa.api.Role+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RoleWrapper', @@ -86,17 +87,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/roles/id/PATCH/Role.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update the Role.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the provided one in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update the Role.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the provided one in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Root.php b/src/lib/Server/Controller/Root.php index ae01c564b..1cbad0f5c 100644 --- a/src/lib/Server/Controller/Root.php +++ b/src/lib/Server/Controller/Root.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Rest\Exceptions\NotFoundException; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Service\RootResourceBuilderInterface; @@ -25,9 +26,9 @@ 'Root', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the list is return in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the list is return in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Root+json' => [ 'schema' => [ '$ref' => '#/components/schemas/RootWrapper', @@ -40,8 +41,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/GET/Root.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Section/SectionCreateController.php b/src/lib/Server/Controller/Section/SectionCreateController.php index 169c7c3e8..48d11c93f 100644 --- a/src/lib/Server/Controller/Section/SectionCreateController.php +++ b/src/lib/Server/Controller/Section/SectionCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\SectionService; use Ibexa\Rest\Message; @@ -42,7 +43,7 @@ ], requestBody: new Model\RequestBody( description: 'The Section input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.SectionInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionInputWrapper', @@ -58,9 +59,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'If set, the new Section is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'If set, the new Section is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Section+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionWrapper', @@ -73,8 +74,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/sections/POST/Section.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Section/SectionDeleteController.php b/src/lib/Server/Controller/Section/SectionDeleteController.php index 2c2ce2a80..b33177adb 100644 --- a/src/lib/Server/Controller/Section/SectionDeleteController.php +++ b/src/lib/Server/Controller/Section/SectionDeleteController.php @@ -43,15 +43,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - given Section is deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this Section.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Section does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - given Section is deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this Section.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Section does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Section/SectionListController.php b/src/lib/Server/Controller/Section/SectionListController.php index a8bdb24e3..b5eac986b 100644 --- a/src/lib/Server/Controller/Section/SectionListController.php +++ b/src/lib/Server/Controller/Section/SectionListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\SectionService; use Ibexa\Contracts\Core\Repository\Values\Content\Section; use Ibexa\Rest\Server\Controller as RestController; @@ -39,9 +40,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Section list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Section list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.SectionList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionListWrapper', @@ -54,12 +55,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/sections/GET/SectionList.xml.example', ], - ], - ], + ]), + ), //Response::HTTP_NOT_FOUND => [], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read the Section.', - ], + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read the Section.'), ], ), )] diff --git a/src/lib/Server/Controller/Section/SectionLoadByIdController.php b/src/lib/Server/Controller/Section/SectionLoadByIdController.php index a529fa136..ac2b3da99 100644 --- a/src/lib/Server/Controller/Section/SectionLoadByIdController.php +++ b/src/lib/Server/Controller/Section/SectionLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\SectionService; use Ibexa\Contracts\Core\Repository\Values\Content\Section; use Ibexa\Rest\Server\Controller as RestController; @@ -43,9 +44,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the Section is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the Section is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Section+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionWrapper', @@ -58,14 +59,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/sections/section_id/GET/Section.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read this Section.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The Section does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read this Section.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The Section does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Section/SectionUpdateController.php b/src/lib/Server/Controller/Section/SectionUpdateController.php index 63815c944..6125c625d 100644 --- a/src/lib/Server/Controller/Section/SectionUpdateController.php +++ b/src/lib/Server/Controller/Section/SectionUpdateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\SectionService; use Ibexa\Contracts\Core\Repository\Values\Content\Section; @@ -61,7 +62,7 @@ ], requestBody: new Model\RequestBody( description: 'The Section input schema encoded in XML or JSON.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.SectionInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionInputWrapper', @@ -77,9 +78,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Section updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Section updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Section+json' => [ 'schema' => [ '$ref' => '#/components/schemas/SectionWrapper', @@ -92,20 +93,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/sections/section_id/PATCH/Section.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this Section.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - a Section with the given identifier already exists.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this Section.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - a Section with the given identifier already exists.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/Services.php b/src/lib/Server/Controller/Services.php index 8a6eab166..94db1f35a 100644 --- a/src/lib/Server/Controller/Services.php +++ b/src/lib/Server/Controller/Services.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values\CountryList; use Symfony\Component\DependencyInjection\Attribute\Autowire; @@ -24,9 +25,9 @@ 'Services', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the country list is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the country list is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.CountriesList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/CountryListWrapper', @@ -38,8 +39,8 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/services/countries/GET/CountriesList.xml.example', ], - ], - ], + ]), + ), ], ), )] diff --git a/src/lib/Server/Controller/Session/SessionCheckController.php b/src/lib/Server/Controller/Session/SessionCheckController.php index 786e9661e..3ba10a395 100644 --- a/src/lib/Server/Controller/Session/SessionCheckController.php +++ b/src/lib/Server/Controller/Session/SessionCheckController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values\UserSession; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -43,9 +44,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'User is currently logged in and has a valid session.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'User is currently logged in and has a valid session.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Session+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/Session', @@ -58,11 +59,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/sessions/session_id/refresh/POST/Session.json.example', ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'User does not have a valid session, or it has expired.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'User does not have a valid session, or it has expired.'), ], ), )] diff --git a/src/lib/Server/Controller/Session/SessionCreateController.php b/src/lib/Server/Controller/Session/SessionCreateController.php index 3ae2ef0be..e7c1470f9 100644 --- a/src/lib/Server/Controller/Session/SessionCreateController.php +++ b/src/lib/Server/Controller/Session/SessionCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Rest\Exceptions\UnauthorizedException; use Ibexa\Rest\Server\Exceptions; use Ibexa\Rest\Server\Values; @@ -68,7 +69,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.SessionInput+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/SessionInput', @@ -84,9 +85,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'Session already exists.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'Session already exists.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Session+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/Session', @@ -99,11 +100,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/sessions/session_id/refresh/POST/Session.json.example', ], - ], - ], - Response::HTTP_CREATED => [ - 'description' => 'Session is created.', - 'content' => [ + ]), + ), + Response::HTTP_CREATED => new Model\Response( + description: 'Session is created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Session+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/Session', @@ -116,17 +117,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/sessions/session_id/refresh/POST/Session.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the authorization failed.', - ], - Response::HTTP_CONFLICT => [ - 'description' => 'Error - header contained a session cookie but different user was authorized.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the authorization failed.'), + Response::HTTP_CONFLICT => new Model\Response(description: 'Error - header contained a session cookie but different user was authorized.'), ], ), )] diff --git a/src/lib/Server/Controller/Session/SessionDeleteController.php b/src/lib/Server/Controller/Session/SessionDeleteController.php index 4a646e2e0..64a49d5e1 100644 --- a/src/lib/Server/Controller/Session/SessionDeleteController.php +++ b/src/lib/Server/Controller/Session/SessionDeleteController.php @@ -51,12 +51,8 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'OK - session deleted.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the session does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'OK - session deleted.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the session does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/Session/SessionRefreshController.php b/src/lib/Server/Controller/Session/SessionRefreshController.php index f93bf9b6f..a937b7326 100644 --- a/src/lib/Server/Controller/Session/SessionRefreshController.php +++ b/src/lib/Server/Controller/Session/SessionRefreshController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -61,8 +62,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - session refreshed.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Session+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/Session', @@ -75,14 +77,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/sessions/session_id/refresh/POST/Session.json.example', ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the session does not exist.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the session does not exist.'), ], requestBody: new Model\RequestBody( - content: new \ArrayObject(), + content: new ArrayObject(), ), ), )] diff --git a/src/lib/Server/Controller/Trash/TrashEmptyController.php b/src/lib/Server/Controller/Trash/TrashEmptyController.php index 5bd692e0e..f368afd80 100644 --- a/src/lib/Server/Controller/Trash/TrashEmptyController.php +++ b/src/lib/Server/Controller/Trash/TrashEmptyController.php @@ -38,12 +38,8 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - Trash emptied.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to empty all items from Trash.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - Trash emptied.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to empty all items from Trash.'), ], ), )] diff --git a/src/lib/Server/Controller/Trash/TrashItemDeleteController.php b/src/lib/Server/Controller/Trash/TrashItemDeleteController.php index 9f372ddad..8e7e180a1 100644 --- a/src/lib/Server/Controller/Trash/TrashItemDeleteController.php +++ b/src/lib/Server/Controller/Trash/TrashItemDeleteController.php @@ -44,15 +44,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - item deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete the provided item.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The provided item does not exist in Trash.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - item deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete the provided item.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The provided item does not exist in Trash.'), ], ), )] diff --git a/src/lib/Server/Controller/Trash/TrashItemListController.php b/src/lib/Server/Controller/Trash/TrashItemListController.php index 2316f7203..69e409cc2 100644 --- a/src/lib/Server/Controller/Trash/TrashItemListController.php +++ b/src/lib/Server/Controller/Trash/TrashItemListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Contracts\Core\Repository\Values\Content\Query; @@ -30,9 +31,9 @@ 'Trash', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the list of items in the Trash.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the list of items in the Trash.', + content: new ArrayObject([ 'application/vnd.ibexa.api.Trash+json' => [ 'schema' => [ '$ref' => '#/components/schemas/TrashWrapper', @@ -45,11 +46,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/trash/GET/Trash.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read the Trash.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read the Trash.'), ], ), )] diff --git a/src/lib/Server/Controller/Trash/TrashItemLoadByIdController.php b/src/lib/Server/Controller/Trash/TrashItemLoadByIdController.php index a8da394ef..93eb13f86 100644 --- a/src/lib/Server/Controller/Trash/TrashItemLoadByIdController.php +++ b/src/lib/Server/Controller/Trash/TrashItemLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\TrashService; use Ibexa\Rest\Server\Controller as RestController; @@ -35,9 +36,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'If set, the item in Trash is returned in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'If set, the item in Trash is returned in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.TrashItem+json' => [ 'schema' => [ '$ref' => '#/components/schemas/TrashItemWrapper', @@ -50,14 +51,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/trash/trash_itemid/GET/TrashItem.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read the item in Trash.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - An item in Trash with the provided ID does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read the item in Trash.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - An item in Trash with the provided ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/URLAlias/URLAliasCreateController.php b/src/lib/Server/Controller/URLAlias/URLAliasCreateController.php index 3a67e891b..01199ad43 100644 --- a/src/lib/Server/Controller/URLAlias/URLAliasCreateController.php +++ b/src/lib/Server/Controller/URLAlias/URLAliasCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\URLAliasService; @@ -44,7 +45,7 @@ ], requestBody: new Model\RequestBody( description: 'The URL alias input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlAliasCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlAliasCreateWrapper', @@ -60,9 +61,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'URL alias created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'URL alias created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlAlias+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlAliasWrapper', @@ -75,17 +76,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlaliases/POST/UrlAlias.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create a URL alias.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A URL alias with the same identifier already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create a URL alias.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A URL alias with the same identifier already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/URLAlias/URLAliasDeleteController.php b/src/lib/Server/Controller/URLAlias/URLAliasDeleteController.php index 310ee6eb4..f7e3e1e3c 100644 --- a/src/lib/Server/Controller/URLAlias/URLAliasDeleteController.php +++ b/src/lib/Server/Controller/URLAlias/URLAliasDeleteController.php @@ -44,15 +44,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - URL alias deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete a URL alias.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The URL alias does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - URL alias deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete a URL alias.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The URL alias does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/URLAlias/URLAliasListGlobalController.php b/src/lib/Server/Controller/URLAlias/URLAliasListGlobalController.php index 00a5c3cd8..e9822aee6 100644 --- a/src/lib/Server/Controller/URLAlias/URLAliasListGlobalController.php +++ b/src/lib/Server/Controller/URLAlias/URLAliasListGlobalController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Rest\Server\Controller as RestController; @@ -27,9 +28,9 @@ 'Url Alias', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the list of URL aliases.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the list of URL aliases.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlAliasRefList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlAliasRefListWrapper', @@ -42,11 +43,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlaliases/GET/UrlAliasRefList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read URL aliases.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read URL aliases.'), ], ), )] diff --git a/src/lib/Server/Controller/URLAlias/URLAliasListLocationController.php b/src/lib/Server/Controller/URLAlias/URLAliasListLocationController.php index 678c60898..43b7585f9 100644 --- a/src/lib/Server/Controller/URLAlias/URLAliasListLocationController.php +++ b/src/lib/Server/Controller/URLAlias/URLAliasListLocationController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Rest\Server\Controller as RestController; @@ -38,9 +39,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the list of URL aliases.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the list of URL aliases.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlAliasRefList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlAliasRefListWrapper', @@ -52,14 +53,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/locations/path/urlaliases/GET/UrlAliasRefList.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The user has no permission to read URL aliases.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The Location was not found.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The user has no permission to read URL aliases.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The Location was not found.'), ], ), )] diff --git a/src/lib/Server/Controller/URLAlias/URLAliasLoadByIdController.php b/src/lib/Server/Controller/URLAlias/URLAliasLoadByIdController.php index b0b779a03..5b83ef314 100644 --- a/src/lib/Server/Controller/URLAlias/URLAliasLoadByIdController.php +++ b/src/lib/Server/Controller/URLAlias/URLAliasLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\URLAliasService; use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias as ApiUrlAlias; @@ -35,9 +36,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the URL alias.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the URL alias.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlAlias+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlAliasWrapper', @@ -50,14 +51,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlaliases/url_alias_id/GET/UrlAlias.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read URL aliases.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The URL alias does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read URL aliases.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The URL alias does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/URLWildcard/URLWildcardCreateController.php b/src/lib/Server/Controller/URLWildcard/URLWildcardCreateController.php index 2f3d58a15..afa5c7dc7 100644 --- a/src/lib/Server/Controller/URLWildcard/URLWildcardCreateController.php +++ b/src/lib/Server/Controller/URLWildcard/URLWildcardCreateController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; use Ibexa\Contracts\Core\Repository\URLWildcardService; use Ibexa\Rest\Message; @@ -43,7 +44,7 @@ ], requestBody: new Model\RequestBody( description: 'The URL Wildcard input schema encoded in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlWildcardCreate+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlWildcardCreateWrapper', @@ -59,9 +60,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'URL wildcard created.', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'URL wildcard created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlWildcard+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlWildcardWrapper', @@ -74,17 +75,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlwildcards/POST/UrlWildcard.xml.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - The input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to create a URL wildcard.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - A URL wildcard with the same identifier already exists.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - The input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to create a URL wildcard.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - A URL wildcard with the same identifier already exists.'), ], ), )] diff --git a/src/lib/Server/Controller/URLWildcard/URLWildcardDeleteController.php b/src/lib/Server/Controller/URLWildcard/URLWildcardDeleteController.php index 02442688f..06f8b76b7 100644 --- a/src/lib/Server/Controller/URLWildcard/URLWildcardDeleteController.php +++ b/src/lib/Server/Controller/URLWildcard/URLWildcardDeleteController.php @@ -43,15 +43,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content - URL wildcard deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to delete a URL wildcard.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The URL wildcard does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content - URL wildcard deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to delete a URL wildcard.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The URL wildcard does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/URLWildcard/URLWildcardListController.php b/src/lib/Server/Controller/URLWildcard/URLWildcardListController.php index 191959a60..c2b489216 100644 --- a/src/lib/Server/Controller/URLWildcard/URLWildcardListController.php +++ b/src/lib/Server/Controller/URLWildcard/URLWildcardListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\URLWildcardService; use Ibexa\Rest\Server\Controller as RestController; use Ibexa\Rest\Server\Values; @@ -26,9 +27,9 @@ 'Url Wildcard', ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns a list of URL wildcards.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns a list of URL wildcards.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlWildcardList+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlWildcardListWrapper', @@ -41,11 +42,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlwildcards/GET/UrlWildcardList.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user has no permission to read URL wildcards.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user has no permission to read URL wildcards.'), ], ), )] diff --git a/src/lib/Server/Controller/URLWildcard/URLWildcardLoadByIdController.php b/src/lib/Server/Controller/URLWildcard/URLWildcardLoadByIdController.php index f01060760..ea715fa75 100644 --- a/src/lib/Server/Controller/URLWildcard/URLWildcardLoadByIdController.php +++ b/src/lib/Server/Controller/URLWildcard/URLWildcardLoadByIdController.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\URLWildcardService; use Ibexa\Contracts\Core\Repository\Values\Content\URLWildcard; use Ibexa\Rest\Server\Controller as RestController; @@ -34,9 +35,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - returns the URL wildcard.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - returns the URL wildcard.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UrlWildcard+json' => [ 'schema' => [ '$ref' => '#/components/schemas/UrlWildcardWrapper', @@ -49,14 +50,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/content/urlwildcards/wildcard_id/GET/UrlWildcard.xml.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - The user is not authorized to read URL wildcards.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - The URL wildcard does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - The user is not authorized to read URL wildcards.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - The URL wildcard does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserAssignToUserGroupController.php b/src/lib/Server/Controller/User/UserAssignToUserGroupController.php index 6e075d157..389f6e69e 100644 --- a/src/lib/Server/Controller/User/UserAssignToUserGroupController.php +++ b/src/lib/Server/Controller/User/UserAssignToUserGroupController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions; use Ibexa\Rest\Server\Exceptions; use Ibexa\Rest\Server\Values; @@ -47,8 +48,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - the User has been assigned to the User Group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupRefList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupRefList', @@ -61,20 +63,14 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/groups/group_id/UserGroupRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to assign User Groups.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the new User Group does not exist or the User is already in this group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to assign User Groups.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the new User Group does not exist or the User is already in this group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User does not exist.'), ], requestBody: new Model\RequestBody( - content: new \ArrayObject(), + content: new ArrayObject(), ), ), )] diff --git a/src/lib/Server/Controller/User/UserCreateController.php b/src/lib/Server/Controller/User/UserCreateController.php index d2fc144cb..81e6c2c88 100644 --- a/src/lib/Server/Controller/User/UserCreateController.php +++ b/src/lib/Server/Controller/User/UserCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Exceptions\ForbiddenException; @@ -58,7 +59,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UserCreate+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserCreate', @@ -74,8 +75,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Created - the User has been created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.User+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/User', @@ -88,20 +90,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/PATCH/User.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this User.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - a User with the same login already exists.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the Group with the given ID does not exist.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this User.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - a User with the same login already exists.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the Group with the given ID does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserDeleteController.php b/src/lib/Server/Controller/User/UserDeleteController.php index 41e87cc70..820cdb98c 100644 --- a/src/lib/Server/Controller/User/UserDeleteController.php +++ b/src/lib/Server/Controller/User/UserDeleteController.php @@ -33,18 +33,10 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No Content.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this User.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the user is the same as the authenticated User.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User does not exist.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No Content.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this User.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the user is the same as the authenticated User.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserDraftListController.php b/src/lib/Server/Controller/User/UserDraftListController.php index 8ccc95699..ec48b7b38 100644 --- a/src/lib/Server/Controller/User/UserDraftListController.php +++ b/src/lib/Server/Controller/User/UserDraftListController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\DraftList\ContentDraftListItemInterface; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; use Ibexa\Rest\Server\Values; @@ -46,9 +47,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - List the draft versions', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - List the draft versions', + content: new ArrayObject([ 'application/vnd.ibexa.api.VersionList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/VersionList', @@ -59,11 +60,9 @@ '$ref' => '#/components/schemas/VersionListWrapper', ], ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the current user is not authorized to list the drafts of the given user.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the current user is not authorized to list the drafts of the given user.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupCreateController.php b/src/lib/Server/Controller/User/UserGroupCreateController.php index c8b6b8752..e06752c37 100644 --- a/src/lib/Server/Controller/User/UserGroupCreateController.php +++ b/src/lib/Server/Controller/User/UserGroupCreateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Values; use LogicException; @@ -47,7 +48,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupCreate+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupCreate', @@ -63,9 +64,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'description' => 'Created - the User Group has been created', - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Created - the User Group has been created', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroup+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroup', @@ -78,14 +79,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/subgroups/POST/UserGroup.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this User Group.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this User Group.'), ], ), )] @@ -127,7 +124,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupCreate+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupCreate', @@ -143,8 +140,9 @@ ]), ), responses: [ - Response::HTTP_CREATED => [ - 'content' => [ + Response::HTTP_CREATED => new Model\Response( + description: 'Created - the User Group has been created.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroup+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroup', @@ -157,14 +155,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/subgroups/POST/UserGroup.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to create this User Group.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to create this User Group.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupDeleteController.php b/src/lib/Server/Controller/User/UserGroupDeleteController.php index b0800ae7a..4b3f469b2 100644 --- a/src/lib/Server/Controller/User/UserGroupDeleteController.php +++ b/src/lib/Server/Controller/User/UserGroupDeleteController.php @@ -35,15 +35,9 @@ ), ], responses: [ - Response::HTTP_NO_CONTENT => [ - 'description' => 'No content - the given User Group is deleted.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to delete this content type.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the User Group is not empty.', - ], + Response::HTTP_NO_CONTENT => new Model\Response(description: 'No content - the given User Group is deleted.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to delete this content type.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the User Group is not empty.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupListController.php b/src/lib/Server/Controller/User/UserGroupListController.php index f31376483..987f3031a 100644 --- a/src/lib/Server/Controller/User/UserGroupListController.php +++ b/src/lib/Server/Controller/User/UserGroupListController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\User\UserGroupRoleAssignment; use Ibexa\Rest\Server\Values; @@ -40,8 +41,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - list of User Groups.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupList', @@ -66,11 +68,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/groups/group_id/UserGroupRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read User Groups.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read User Groups.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupLoadByPathController.php b/src/lib/Server/Controller/User/UserGroupLoadByPathController.php index a46b13595..f48927696 100644 --- a/src/lib/Server/Controller/User/UserGroupLoadByPathController.php +++ b/src/lib/Server/Controller/User/UserGroupLoadByPathController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Rest\Exceptions\NotFoundException; use Ibexa\Rest\Server\Values; @@ -53,9 +54,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - loads User Groups.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - loads User Groups.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroup+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroup', @@ -68,14 +69,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/subgroups/POST/UserGroup.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read User Groups.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User Group does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read User Groups.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User Group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupOfRootLoadController.php b/src/lib/Server/Controller/User/UserGroupOfRootLoadController.php index de115c55c..e919d2e15 100644 --- a/src/lib/Server/Controller/User/UserGroupOfRootLoadController.php +++ b/src/lib/Server/Controller/User/UserGroupOfRootLoadController.php @@ -26,9 +26,7 @@ parameters: [ ], responses: [ - Response::HTTP_MOVED_PERMANENTLY => [ - 'description' => 'Moved permanently.', - ], + Response::HTTP_MOVED_PERMANENTLY => new Model\Response(description: 'Moved permanently.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupUpdateController.php b/src/lib/Server/Controller/User/UserGroupUpdateController.php index 378eb05ee..a961c1295 100644 --- a/src/lib/Server/Controller/User/UserGroupUpdateController.php +++ b/src/lib/Server/Controller/User/UserGroupUpdateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Request; @@ -63,7 +64,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupUpdate+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupUpdate', @@ -79,9 +80,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - updated User Group.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - updated User Group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroup+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroup', @@ -94,17 +95,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/path/subgroups/POST/UserGroup.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update the User Group.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - if the current ETag does not match with the one provided in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update the User Group.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - if the current ETag does not match with the one provided in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupUsersListController.php b/src/lib/Server/Controller/User/UserGroupUsersListController.php index 59a84b123..7330d6047 100644 --- a/src/lib/Server/Controller/User/UserGroupUsersListController.php +++ b/src/lib/Server/Controller/User/UserGroupUsersListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Values; use Ibexa\Rest\Value as RestValue; @@ -45,9 +46,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - the Users of the Group with the given ID.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - the Users of the Group with the given ID.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserList', @@ -70,14 +71,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/groups/id/users/GET/UserRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read User Groups.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User Group does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read User Groups.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User Group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserGroupsOfUserListController.php b/src/lib/Server/Controller/User/UserGroupsOfUserListController.php index 66dc5112d..f291d0d7e 100644 --- a/src/lib/Server/Controller/User/UserGroupsOfUserListController.php +++ b/src/lib/Server/Controller/User/UserGroupsOfUserListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Values; use Ibexa\Rest\Value as RestValue; @@ -45,8 +46,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - list of the User Groups the User belongs to.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupRefList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupRefList', @@ -59,14 +61,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/groups/group_id/UserGroupRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read User Groups.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the user does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read User Groups.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the user does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserListController.php b/src/lib/Server/Controller/User/UserListController.php index c926568ab..e7af0a71c 100644 --- a/src/lib/Server/Controller/User/UserListController.php +++ b/src/lib/Server/Controller/User/UserListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Symfony\Component\HttpFoundation\Response; #[Get( @@ -32,9 +33,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - Loads Users either for a given remote ID or Role.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - Loads Users either for a given remote ID or Role.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserList', @@ -58,11 +59,9 @@ '$ref' => '#/components/schemas/UserRefListWrapper', ], ], - ], - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'If there are no visible Users matching the filter.', - ], + ]), + ), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'If there are no visible Users matching the filter.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserLoadByIdController.php b/src/lib/Server/Controller/User/UserLoadByIdController.php index 3b07f02a1..3a5dc5e7e 100644 --- a/src/lib/Server/Controller/User/UserLoadByIdController.php +++ b/src/lib/Server/Controller/User/UserLoadByIdController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Core\Base\Exceptions\UnauthorizedException; use Ibexa\Rest\Server\Values; @@ -54,9 +55,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - the User with the given ID.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - the User with the given ID.', + content: new ArrayObject([ 'application/vnd.ibexa.api.User+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserList', @@ -69,14 +70,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/GET/User.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Users.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Users.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserRedirectToCurrentUserController.php b/src/lib/Server/Controller/User/UserRedirectToCurrentUserController.php index 893ee44c8..d43284306 100644 --- a/src/lib/Server/Controller/User/UserRedirectToCurrentUserController.php +++ b/src/lib/Server/Controller/User/UserRedirectToCurrentUserController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Server\Values; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; @@ -37,9 +38,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - the User with the given ID.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - the User with the given ID.', + content: new ArrayObject([ 'application/vnd.ibexa.api.User+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserList', @@ -52,11 +53,9 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/GET/User.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read Users. For example, Anonymous user can\'t load oneself.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read Users. For example, Anonymous user can\'t load oneself.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserSubGroupListController.php b/src/lib/Server/Controller/User/UserSubGroupListController.php index d8c9b1275..2578db953 100644 --- a/src/lib/Server/Controller/User/UserSubGroupListController.php +++ b/src/lib/Server/Controller/User/UserSubGroupListController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Get; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Rest\Server\Values; use Ibexa\Rest\Value as RestValue; @@ -45,9 +46,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - list of the subgroups.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - list of the subgroups.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupList', @@ -72,14 +73,10 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/groups/group_id/UserGroupRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user has no permission to read User Groups.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User Group does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user has no permission to read User Groups.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User Group does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserUnassignFromUserGroupController.php b/src/lib/Server/Controller/User/UserUnassignFromUserGroupController.php index 330a49850..0a0f45484 100644 --- a/src/lib/Server/Controller/User/UserUnassignFromUserGroupController.php +++ b/src/lib/Server/Controller/User/UserUnassignFromUserGroupController.php @@ -10,6 +10,7 @@ use ApiPlatform\Metadata\Delete; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions; use Ibexa\Rest\Server\Exceptions; use Ibexa\Rest\Server\Values; @@ -52,8 +53,9 @@ ), ], responses: [ - Response::HTTP_OK => [ - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - the User has been unassigned from the User Group.', + content: new ArrayObject([ 'application/vnd.ibexa.api.UserGroupRefList+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserGroupRefList', @@ -66,17 +68,11 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/groups/group_id/UserGroupRefList.json.example', ], - ], - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to unassign User Groups.', - ], - Response::HTTP_FORBIDDEN => [ - 'description' => 'Error - the User is not in the given group.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User does not exist.', - ], + ]), + ), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to unassign User Groups.'), + Response::HTTP_FORBIDDEN => new Model\Response(description: 'Error - the User is not in the given group.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User does not exist.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserUpdateController.php b/src/lib/Server/Controller/User/UserUpdateController.php index 80941b7d6..df8705128 100644 --- a/src/lib/Server/Controller/User/UserUpdateController.php +++ b/src/lib/Server/Controller/User/UserUpdateController.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Patch; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Rest\Message; use Ibexa\Rest\Server\Values; use LogicException; @@ -64,7 +65,7 @@ ), ], requestBody: new Model\RequestBody( - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.UserUpdate+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/UserUpdate', @@ -80,9 +81,9 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - User updated.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'OK - User updated.', + content: new ArrayObject([ 'application/vnd.ibexa.api.User+xml' => [ 'schema' => [ '$ref' => '#/components/schemas/User', @@ -95,20 +96,12 @@ ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/user/users/user_id/PATCH/User.json.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], - Response::HTTP_UNAUTHORIZED => [ - 'description' => 'Error - the user is not authorized to update the User.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - the User does not exist.', - ], - Response::HTTP_PRECONDITION_FAILED => [ - 'description' => 'Error - the current ETag does not match with the provided one in the If-Match header.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), + Response::HTTP_UNAUTHORIZED => new Model\Response(description: 'Error - the user is not authorized to update the User.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - the User does not exist.'), + Response::HTTP_PRECONDITION_FAILED => new Model\Response(description: 'Error - the current ETag does not match with the provided one in the If-Match header.'), ], ), )] diff --git a/src/lib/Server/Controller/User/UserVerifyController.php b/src/lib/Server/Controller/User/UserVerifyController.php index 1ef4c8637..d55fe7f67 100644 --- a/src/lib/Server/Controller/User/UserVerifyController.php +++ b/src/lib/Server/Controller/User/UserVerifyController.php @@ -26,12 +26,8 @@ parameters: [ ], responses: [ - Response::HTTP_OK => [ - 'description' => 'OK - verifies if there are Users matching the given filter.', - ], - Response::HTTP_NOT_FOUND => [ - 'description' => 'Error - there are no visible Users matching the filter.', - ], + Response::HTTP_OK => new Model\Response(description: 'OK - verifies if there are Users matching the given filter.'), + Response::HTTP_NOT_FOUND => new Model\Response(description: 'Error - there are no visible Users matching the filter.'), ], ), )] diff --git a/src/lib/Server/Controller/Views.php b/src/lib/Server/Controller/Views.php index 9f96422fb..eab9c3b88 100644 --- a/src/lib/Server/Controller/Views.php +++ b/src/lib/Server/Controller/Views.php @@ -11,6 +11,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Factory\OpenApiFactory; use ApiPlatform\OpenApi\Model; +use ArrayObject; use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; use Ibexa\Contracts\Core\Repository\SearchService; use Ibexa\Contracts\Core\Repository\Values\Content\Language; @@ -46,7 +47,7 @@ ], requestBody: new Model\RequestBody( description: 'The view input in XML or JSON format.', - content: new \ArrayObject([ + content: new ArrayObject([ 'application/vnd.ibexa.api.ViewInput+json' => [ 'schema' => [ '$ref' => '#/components/schemas/ViewInputWrapper', @@ -62,20 +63,18 @@ ]), ), responses: [ - Response::HTTP_OK => [ - 'description' => 'The view in XML or JSON format.', - 'content' => [ + Response::HTTP_OK => new Model\Response( + description: 'The view in XML or JSON format.', + content: new ArrayObject([ 'application/vnd.ibexa.api.View+xml; version=1.1' => [ 'schema' => [ '$ref' => '#/components/schemas/View', ], 'x-ibexa-example-file' => '@IbexaRestBundle/Resources/api_platform/examples/views/POST/View.xml.v11.example', ], - ], - ], - Response::HTTP_BAD_REQUEST => [ - 'description' => 'Error - the input does not match the input schema definition.', - ], + ]), + ), + Response::HTTP_BAD_REQUEST => new Model\Response(description: 'Error - the input does not match the input schema definition.'), ], ), )] diff --git a/tests/bundle/ApiPlatform/OpenApiFactoryTest.php b/tests/bundle/ApiPlatform/OpenApiFactoryTest.php index 42f2c8bd4..b9f0b78f3 100644 --- a/tests/bundle/ApiPlatform/OpenApiFactoryTest.php +++ b/tests/bundle/ApiPlatform/OpenApiFactoryTest.php @@ -14,6 +14,7 @@ use ApiPlatform\OpenApi\Model\PathItem; use ApiPlatform\OpenApi\Model\Paths; use ApiPlatform\OpenApi\Model\RequestBody; +use ApiPlatform\OpenApi\Model\Response; use ApiPlatform\OpenApi\OpenApi; use ArrayObject; use Ibexa\Bundle\Rest\ApiPlatform\EditionBadge\EditionBadgeFactoryInterface; @@ -206,6 +207,103 @@ public function testThrowsExceptionWhenRequestExampleJsonIsInvalid(): void } } + public function testInjectsResponseExamplesFromFileIntoResponseObjects(): void + { + // Given: A response object with JSON and XML examples referenced by file + $response = new Response( + description: 'Session created.', + content: new ArrayObject([ + 'application/json' => [ + 'schema' => ['$ref' => '#/components/schemas/Session'], + 'x-ibexa-example-file' => '@TestBundle/examples/response.json', + ], + 'application/xml' => [ + 'schema' => ['$ref' => '#/components/schemas/Session'], + 'x-ibexa-example-file' => '@TestBundle/examples/response.xml', + ], + ]), + headers: new ArrayObject(['Location' => ['schema' => ['type' => 'string']]]), + ); + + $result = $this->processOpenApiWithResponse($response); + + // Then: Both examples are injected and the rest of the response is kept + $processedResponse = $this->getProcessedResponse($result); + self::assertSame('Session created.', $processedResponse->getDescription()); + self::assertEquals( + new ArrayObject(['Location' => ['schema' => ['type' => 'string']]]), + $processedResponse->getHeaders(), + ); + + $content = $processedResponse->getContent(); + self::assertNotNull($content); + + $jsonContent = $content['application/json']; + self::assertSame(['$ref' => '#/components/schemas/Session'], $jsonContent['schema']); + self::assertEquals([ + 'token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + 'user' => ['id' => 14, 'login' => 'admin'], + ], $jsonContent['example']); + self::assertArrayNotHasKey('x-ibexa-example-file', $jsonContent); + + $xmlContent = $content['application/xml']; + self::assertIsString($xmlContent['example']); + self::assertStringContainsString('', $xmlContent['example']); + self::assertArrayNotHasKey('x-ibexa-example-file', $xmlContent); + } + + public function testKeepsResponseObjectsWithoutExampleFileUnchanged(): void + { + $response = new Response( + description: 'OK - list returned.', + content: new ArrayObject([ + 'application/json' => ['schema' => ['$ref' => '#/components/schemas/List']], + ]), + ); + + $result = $this->processOpenApiWithResponse($response); + + self::assertSame($response, $this->getProcessedResponse($result)); + } + + private function processOpenApiWithResponse(Response $response): OpenApi + { + $operation = new Operation( + responses: [ + '201' => $response, + ] + ); + + $paths = new Paths(); + $paths->addPath('/test', new PathItem(post: $operation)); + + $openApi = new OpenApi( + info: new Info(title: 'Test API', version: '1.0'), + servers: [], + paths: $paths + ); + + $this->decoratedFactory + ->expects(self::once()) + ->method('__invoke') + ->willReturn($openApi); + + return ($this->factory)([]); + } + + private function getProcessedResponse(OpenApi $result): Response + { + $processedPath = $result->getPaths()->getPath('/test'); + self::assertNotNull($processedPath); + $processedOperation = $processedPath->getPost(); + self::assertNotNull($processedOperation); + $responses = $processedOperation->getResponses(); + self::assertNotNull($responses); + self::assertInstanceOf(Response::class, $responses['201']); + + return $responses['201']; + } + /** * @param array> $content */ @@ -219,7 +317,7 @@ private function processOpenApiWithRequestBody(array $content, OpenApiFactory $f $operation = new Operation( requestBody: $requestBody, responses: [ - '200' => ['description' => 'Success'], + '200' => new Response(description: 'Success'), ] );