From 3c5f48da6a113caf488f2d4fabfca639d449dd2a Mon Sep 17 00:00:00 2001 From: mattamon Date: Thu, 23 May 2024 12:56:29 +0200 Subject: [PATCH] Unify responses --- src/Asset/Controller/CollectionController.php | 15 +++++---------- .../Controller/CustomSettingsController.php | 11 ++++++----- src/Asset/Controller/Data/TextController.php | 16 ++++++---------- src/Asset/Controller/GetController.php | 11 ++++++----- .../Controller/AuthorizationController.php | 7 +++++-- .../Controller/CollectionController.php | 10 +++++----- src/DataObject/Controller/GetController.php | 11 ++++++----- .../Controller/CollectionController.php | 11 ++++++----- src/Property/Controller/CollectionController.php | 10 +++++----- src/Property/Controller/CreateController.php | 10 +++++----- src/Property/Controller/DeleteController.php | 11 ++++++----- .../Controller/Element/CollectionController.php | 11 ++++++----- .../Controller/Element/UpdateController.php | 11 ++++++----- src/Property/Controller/UpdateController.php | 11 ++++++----- src/Setting/Controller/GetController.php | 6 +++--- .../Controller/TranslationController.php | 9 +++++---- src/Version/Controller/CleanupController.php | 11 ++++++----- src/Version/Controller/CollectionController.php | 11 ++++++----- src/Version/Controller/DeleteController.php | 11 ++++++----- src/Version/Controller/GetController.php | 11 ++++++----- src/Version/Controller/PublishController.php | 11 ++++++----- .../Controller/DetailsCollectionController.php | 11 ++++++----- .../Controller/SubmitActionController.php | 11 ++++++----- 23 files changed, 129 insertions(+), 119 deletions(-) diff --git a/src/Asset/Controller/CollectionController.php b/src/Asset/Controller/CollectionController.php index 06a2442a8..adc6a7a46 100644 --- a/src/Asset/Controller/CollectionController.php +++ b/src/Asset/Controller/CollectionController.php @@ -33,14 +33,11 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PathIncludeParentParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PathParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementTypes; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; @@ -88,11 +85,9 @@ public function __construct( description: 'Paginated assets with total count as header param', content: new CollectionJson(new AnyOfAsset()) )] - #[BadRequestResponse] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function getAssets(#[MapQueryString] ElementParameters $parameters): JsonResponse { $filterService = $this->filterServiceProvider->create(OpenSearchFilterInterface::SERVICE_TYPE); diff --git a/src/Asset/Controller/CustomSettingsController.php b/src/Asset/Controller/CustomSettingsController.php index fe7e12153..06d947cb9 100644 --- a/src/Asset/Controller/CustomSettingsController.php +++ b/src/Asset/Controller/CustomSettingsController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomSettingsHydratorInterface; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -32,6 +33,7 @@ use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementPermissions; use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementTypes; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait; use Pimcore\Model\Asset; use Symfony\Component\HttpFoundation\JsonResponse; @@ -69,11 +71,10 @@ public function __construct( description: 'Array of custom settings', content: new CustomSettingsJson() )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getAssetCustomSettingsById(int $id): JsonResponse { /** @var Asset $asset */ diff --git a/src/Asset/Controller/Data/TextController.php b/src/Asset/Controller/Data/TextController.php index 226e2e548..44018f49e 100644 --- a/src/Asset/Controller/Data/TextController.php +++ b/src/Asset/Controller/Data/TextController.php @@ -22,13 +22,10 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\DataJson; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; -use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; @@ -65,11 +62,10 @@ public function __construct( description: 'UTF8 encoded text data', content: new DataJson('UTF 8 encoded text data') )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getTextData(int $id): JsonResponse { $element = $this->getElement($this->serviceResolver, 'asset', $id); diff --git a/src/Asset/Controller/GetController.php b/src/Asset/Controller/GetController.php index 2d94f91bb..add733919 100644 --- a/src/Asset/Controller/GetController.php +++ b/src/Asset/Controller/GetController.php @@ -21,6 +21,7 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\DataIndex\AssetSearchServiceInterface; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -28,6 +29,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -60,11 +62,10 @@ public function __construct( description: 'One of asset types', content: new OneOfAssetJson() )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getAssetById(int $id): JsonResponse { return $this->jsonResponse($this->assetSearchService->getAssetById($id)); diff --git a/src/Authorization/Controller/AuthorizationController.php b/src/Authorization/Controller/AuthorizationController.php index 3e3209245..75305ee58 100644 --- a/src/Authorization/Controller/AuthorizationController.php +++ b/src/Authorization/Controller/AuthorizationController.php @@ -26,6 +26,7 @@ use Pimcore\Bundle\StudioBackendBundle\Authorization\Service\TokenServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; @@ -33,6 +34,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Security\User\User; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; @@ -68,8 +70,9 @@ public function __construct( description: 'Token, lifetime and user identifier', content: new JsonContent(ref: Token::class) )] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function login(#[MapRequestPayload] Credentials $credentials): JsonResponse { /** @var User $user */ diff --git a/src/DataObject/Controller/CollectionController.php b/src/DataObject/Controller/CollectionController.php index 1e4f31b74..e5195838a 100644 --- a/src/DataObject/Controller/CollectionController.php +++ b/src/DataObject/Controller/CollectionController.php @@ -34,6 +34,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PathIncludeParentParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PathParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -41,6 +42,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; @@ -85,11 +87,9 @@ public function __construct( description: 'Paginated data objects with total count as header param', content: new CollectionJson(new DataObjectCollection()) )] - #[BadRequestResponse] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function getDataObjects(#[MapQueryString] DataObjectParameters $parameters): JsonResponse { $filterService = $this->filterServiceProvider->create(OpenSearchFilterInterface::SERVICE_TYPE); diff --git a/src/DataObject/Controller/GetController.php b/src/DataObject/Controller/GetController.php index 8c71cd1c8..867f707c8 100644 --- a/src/DataObject/Controller/GetController.php +++ b/src/DataObject/Controller/GetController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\DataIndex\DataObjectSearchServiceInterface; use Pimcore\Bundle\StudioBackendBundle\DataObject\Schema\DataObject; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -29,6 +30,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -60,11 +62,10 @@ public function __construct( description: 'Data object response', content: new JsonContent(ref: DataObject::class) )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getAssetById(int $id): JsonResponse { return $this->jsonResponse($this->dataObjectSearchService->getDataObjectById($id)); diff --git a/src/Dependency/Controller/CollectionController.php b/src/Dependency/Controller/CollectionController.php index 749449bed..bc5e9b066 100644 --- a/src/Dependency/Controller/CollectionController.php +++ b/src/Dependency/Controller/CollectionController.php @@ -27,6 +27,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageSizeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; @@ -35,6 +36,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; @@ -77,11 +79,10 @@ public function __construct( description: 'Paginated dependencies with total count as header param', content: new CollectionJson(new DependencyCollection()) )] - #[NotFoundResponse] - #[UnauthorizedResponse] - #[BadRequestResponse] - #[MethodNotAllowedResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getDependencies(#[MapQueryString] DependencyParameters $parameters): JsonResponse { $collection = $this->hydratorService->getDependencies( diff --git a/src/Property/Controller/CollectionController.php b/src/Property/Controller/CollectionController.php index dfafd2eaf..bb138c229 100644 --- a/src/Property/Controller/CollectionController.php +++ b/src/Property/Controller/CollectionController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Content\ItemsJson; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\ElementTypeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\FilterParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -32,6 +33,7 @@ use Pimcore\Bundle\StudioBackendBundle\Property\Request\PropertiesParameters; use Pimcore\Bundle\StudioBackendBundle\Property\Schema\PredefinedProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; @@ -70,11 +72,9 @@ public function __construct( description: 'Predefined properties filtered based on type and query parameters', content: new ItemsJson(PredefinedProperty::class) )] - #[BadRequestResponse] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function getProperties( #[MapQueryString] PropertiesParameters $parameters = new PropertiesParameters() ): JsonResponse { diff --git a/src/Property/Controller/CreateController.php b/src/Property/Controller/CreateController.php index de00431ab..460b0c5b7 100644 --- a/src/Property/Controller/CreateController.php +++ b/src/Property/Controller/CreateController.php @@ -20,6 +20,7 @@ use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\Exception\NotWriteableException; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -29,6 +30,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Property\Schema\PredefinedProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -60,11 +62,9 @@ public function __construct( description: 'Created predefined property', content: new JsonContent(ref: PredefinedProperty::class, type: 'object') )] - #[BadRequestResponse] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function createProperty(): JsonResponse { return $this->jsonResponse($this->propertyService->createPredefinedProperty()); diff --git a/src/Property/Controller/DeleteController.php b/src/Property/Controller/DeleteController.php index da3a777ea..b17671f4e 100644 --- a/src/Property/Controller/DeleteController.php +++ b/src/Property/Controller/DeleteController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\Exception\PropertyNotFoundException; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\IdJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -30,6 +31,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -63,11 +65,10 @@ public function __construct( description: 'Id of deleted property', content: new IdJson('ID of deleted property') )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function deleteProperty(string $id): JsonResponse { $this->propertyService->deletePredefinedProperty($id); diff --git a/src/Property/Controller/Element/CollectionController.php b/src/Property/Controller/Element/CollectionController.php index 91644b48f..85450a96c 100644 --- a/src/Property/Controller/Element/CollectionController.php +++ b/src/Property/Controller/Element/CollectionController.php @@ -21,6 +21,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Content\ItemsJson; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\ElementTypeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -30,6 +31,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Property\Schema\ElementProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -61,11 +63,10 @@ public function __construct( description: 'Element Properties data as json', content: new ItemsJson(ElementProperty::class) )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getProperties(string $elementType, int $id): JsonResponse { return $this->jsonResponse( diff --git a/src/Property/Controller/Element/UpdateController.php b/src/Property/Controller/Element/UpdateController.php index 2f3af7d25..c966bd999 100644 --- a/src/Property/Controller/Element/UpdateController.php +++ b/src/Property/Controller/Element/UpdateController.php @@ -21,6 +21,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Content\ItemsJson; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\ElementTypeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -32,6 +33,7 @@ use Pimcore\Bundle\StudioBackendBundle\Property\Request\UpdateElementProperties; use Pimcore\Bundle\StudioBackendBundle\Property\Schema\ElementProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\Routing\Attribute\Route; @@ -65,11 +67,10 @@ public function __construct( description: 'Updated Element Properties data as json', content: new ItemsJson(ElementProperty::class) )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function updateProperties( string $elementType, int $id, diff --git a/src/Property/Controller/UpdateController.php b/src/Property/Controller/UpdateController.php index 3a4ae6354..bb7407dbd 100644 --- a/src/Property/Controller/UpdateController.php +++ b/src/Property/Controller/UpdateController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\Exception\PropertyNotFoundException; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -33,6 +34,7 @@ use Pimcore\Bundle\StudioBackendBundle\Property\Schema\PredefinedProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Schema\UpdatePredefinedProperty; use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\Routing\Attribute\Route; @@ -67,11 +69,10 @@ public function __construct( description: 'Updated predefined property', content: new JsonContent(ref: PredefinedProperty::class, type: 'object') )] - #[BadRequestResponse] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function updateProperty( string $id, #[MapRequestPayload] UpdatePredefinedProperty $updatePredefinedProperty diff --git a/src/Setting/Controller/GetController.php b/src/Setting/Controller/GetController.php index 0a5d215e7..dd23ab8f1 100644 --- a/src/Setting/Controller/GetController.php +++ b/src/Setting/Controller/GetController.php @@ -19,12 +19,14 @@ use OpenApi\Attributes\Get; use OpenApi\Attributes\JsonContent; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Setting\Service\SettingsServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -56,9 +58,7 @@ public function __construct( description: 'System settings', content: new JsonContent(type: 'object', additionalProperties: true) )] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses] public function getSystemSettings(): JsonResponse { return $this->jsonResponse($this->settingsService->getSettings()); diff --git a/src/Translation/Controller/TranslationController.php b/src/Translation/Controller/TranslationController.php index 0364f8632..a31fbe230 100644 --- a/src/Translation/Controller/TranslationController.php +++ b/src/Translation/Controller/TranslationController.php @@ -19,6 +19,7 @@ use OpenApi\Attributes\JsonContent; use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; @@ -28,6 +29,7 @@ use Pimcore\Bundle\StudioBackendBundle\Translation\Attributes\Request\TranslationRequestBody; use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\Translation; use Pimcore\Bundle\StudioBackendBundle\Translation\Service\TranslatorServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; use Symfony\Component\Routing\Attribute\Route; @@ -62,10 +64,9 @@ public function __construct( description: 'Key value pairs for given keys and locale', content: new JsonContent(ref: Translation::class) )] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function getTranslations( #[MapRequestPayload] Translation $translation, ): JsonResponse { diff --git a/src/Version/Controller/CleanupController.php b/src/Version/Controller/CleanupController.php index a38e34d52..4785491d3 100644 --- a/src/Version/Controller/CleanupController.php +++ b/src/Version/Controller/CleanupController.php @@ -22,6 +22,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\IdParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\TimestampParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\IdsJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -29,6 +30,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Version\Repository\VersionRepositoryInterface; use Pimcore\Bundle\StudioBackendBundle\Version\Request\VersionCleanupParameters; use Symfony\Component\HttpFoundation\JsonResponse; @@ -65,11 +67,10 @@ public function __construct( description: 'IDs of deleted versions', content: new IdsJson('IDs of deleted versions') )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function cleanupVersions(#[MapQueryString] VersionCleanupParameters $parameters): JsonResponse { return $this->jsonResponse(['ids' => $this->repository->cleanupVersions($parameters)]); diff --git a/src/Version/Controller/CollectionController.php b/src/Version/Controller/CollectionController.php index f62a19c90..e11504637 100644 --- a/src/Version/Controller/CollectionController.php +++ b/src/Version/Controller/CollectionController.php @@ -23,6 +23,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageSizeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; @@ -31,6 +32,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Pimcore\Bundle\StudioBackendBundle\Version\Attributes\Response\Property\VersionCollection; use Pimcore\Bundle\StudioBackendBundle\Version\Request\VersionParameters; @@ -73,11 +75,10 @@ public function __construct( description: 'Paginated versions with total count as header param', content: new CollectionJson(new VersionCollection()) )] - #[NotFoundResponse] - #[UnauthorizedResponse] - #[BadRequestResponse] - #[MethodNotAllowedResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getVersions(#[MapQueryString] VersionParameters $parameters): JsonResponse { $collection = $this->hydratorService->getVersions( diff --git a/src/Version/Controller/DeleteController.php b/src/Version/Controller/DeleteController.php index 1f5321e16..e1767bb4a 100644 --- a/src/Version/Controller/DeleteController.php +++ b/src/Version/Controller/DeleteController.php @@ -20,6 +20,7 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\IdJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -29,6 +30,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementPermissions; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Version\Repository\VersionRepositoryInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; @@ -62,11 +64,10 @@ public function __construct( description: 'ID of deleted version', content: new IdJson('ID of deleted version') )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function deleteVersion(int $id): JsonResponse { $user = $this->securityService->getCurrentUser(); diff --git a/src/Version/Controller/GetController.php b/src/Version/Controller/GetController.php index 974026626..b059918e8 100644 --- a/src/Version/Controller/GetController.php +++ b/src/Version/Controller/GetController.php @@ -19,6 +19,7 @@ use OpenApi\Attributes\Get; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -27,6 +28,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Version\Attributes\Response\Content\OneOfVersionJson; use Pimcore\Bundle\StudioBackendBundle\Version\Service\VersionDetailServiceInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -61,11 +63,10 @@ public function __construct( description: 'Version data as json', content: new OneOfVersionJson() )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getVersions(int $id): JsonResponse { return $this->jsonResponse( diff --git a/src/Version/Controller/PublishController.php b/src/Version/Controller/PublishController.php index d62ac3619..738970c09 100644 --- a/src/Version/Controller/PublishController.php +++ b/src/Version/Controller/PublishController.php @@ -20,6 +20,7 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\IdJson; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -28,6 +29,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Version\Service\VersionServiceInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; @@ -61,11 +63,10 @@ public function __construct( description: 'ID of published version', content: new IdJson('ID of published version') )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function publishVersion(int $id): JsonResponse { $user = $this->securityService->getCurrentUser(); diff --git a/src/Workflow/Controller/DetailsCollectionController.php b/src/Workflow/Controller/DetailsCollectionController.php index f23577eb8..c1ecd8958 100644 --- a/src/Workflow/Controller/DetailsCollectionController.php +++ b/src/Workflow/Controller/DetailsCollectionController.php @@ -21,6 +21,7 @@ use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\ElementTypeParameter; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\IdParameter; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\BadRequestResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; @@ -29,6 +30,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Pimcore\Bundle\StudioBackendBundle\Workflow\Attributes\Response\Property\WorkflowDetailsCollection; use Pimcore\Bundle\StudioBackendBundle\Workflow\Request\WorkflowDetailsParameters; @@ -72,11 +74,10 @@ public function __construct( type: 'object' ) )] - #[NotFoundResponse] - #[UnauthorizedResponse] - #[BadRequestResponse] - #[MethodNotAllowedResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function getDetails(#[MapQueryString] WorkflowDetailsParameters $parameters): JsonResponse { $user = $this->securityService->getCurrentUser(); diff --git a/src/Workflow/Controller/SubmitActionController.php b/src/Workflow/Controller/SubmitActionController.php index a10609d0f..34c048959 100644 --- a/src/Workflow/Controller/SubmitActionController.php +++ b/src/Workflow/Controller/SubmitActionController.php @@ -19,6 +19,7 @@ use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Request\WorkflowActionRequestBody; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; @@ -27,6 +28,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Workflow\Attributes\Response\Content\WorkflowActionSubmissionJson; use Pimcore\Bundle\StudioBackendBundle\Workflow\Schema\SubmitAction; use Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowActionServiceInterface; @@ -67,11 +69,10 @@ public function __construct( description: 'Json encoded name of workflow, name and type of submitted action', content: new WorkflowActionSubmissionJson() )] - #[UnauthorizedResponse] - #[NotFoundResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::NOT_FOUND, + ])] public function publishVersion( #[MapRequestPayload] SubmitAction $parameters ): JsonResponse