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..c084a2565 100644 --- a/src/Asset/Controller/CustomSettingsController.php +++ b/src/Asset/Controller/CustomSettingsController.php @@ -22,16 +22,13 @@ 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\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\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 +66,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..8fcb2946b 100644 --- a/src/Asset/Controller/GetController.php +++ b/src/Asset/Controller/GetController.php @@ -21,13 +21,10 @@ 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\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 Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -60,11 +57,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..4798e68d1 100644 --- a/src/Authorization/Controller/AuthorizationController.php +++ b/src/Authorization/Controller/AuthorizationController.php @@ -26,13 +26,11 @@ 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\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\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 +66,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 */ @@ -95,10 +94,9 @@ public function login(#[MapRequestPayload] Credentials $credentials): JsonRespon description: 'Token, lifetime and user identifier', content: new JsonContent(ref: Token::class) )] - #[UnauthorizedResponse] - #[MethodNotAllowedResponse] - #[UnsupportedMediaTypeResponse] - #[UnprocessableContentResponse] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function refresh(#[MapRequestPayload] Refresh $refresh): JsonResponse { $tokenInfo = $this->tokenService->refreshToken($refresh->getToken()); diff --git a/src/DataObject/Controller/CollectionController.php b/src/DataObject/Controller/CollectionController.php index 1e4f31b74..793c738cd 100644 --- a/src/DataObject/Controller/CollectionController.php +++ b/src/DataObject/Controller/CollectionController.php @@ -34,13 +34,10 @@ 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\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; @@ -85,11 +82,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..7871d4adc 100644 --- a/src/DataObject/Controller/GetController.php +++ b/src/DataObject/Controller/GetController.php @@ -22,13 +22,10 @@ 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\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 Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; @@ -60,11 +57,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..69a0611c5 100644 --- a/src/Dependency/Controller/CollectionController.php +++ b/src/Dependency/Controller/CollectionController.php @@ -27,14 +27,11 @@ 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\Error\BadRequestResponse; -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\DefaultResponses; 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 +74,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..e3408e8b6 100644 --- a/src/Property/Controller/CollectionController.php +++ b/src/Property/Controller/CollectionController.php @@ -22,16 +22,13 @@ 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\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\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 +67,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..ff65575e9 100644 --- a/src/Property/Controller/CreateController.php +++ b/src/Property/Controller/CreateController.php @@ -20,15 +20,12 @@ use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\Exception\NotWriteableException; -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\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 +57,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..bf2d51b31 100644 --- a/src/Property/Controller/DeleteController.php +++ b/src/Property/Controller/DeleteController.php @@ -22,14 +22,11 @@ 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\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\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 +60,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..e92bb31d8 100644 --- a/src/Property/Controller/Element/CollectionController.php +++ b/src/Property/Controller/Element/CollectionController.php @@ -21,15 +21,12 @@ 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\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\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 +58,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..46cb063f6 100644 --- a/src/Property/Controller/Element/UpdateController.php +++ b/src/Property/Controller/Element/UpdateController.php @@ -21,17 +21,14 @@ 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\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\Property\Attributes\Request\ElementPropertyRequestBody; 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 +62,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..92b1f5da2 100644 --- a/src/Property/Controller/UpdateController.php +++ b/src/Property/Controller/UpdateController.php @@ -22,17 +22,14 @@ 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\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\Property\Attributes\Request\PredefinedPropertyRequestBody; 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 +64,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..60c39442f 100644 --- a/src/Setting/Controller/GetController.php +++ b/src/Setting/Controller/GetController.php @@ -19,9 +19,7 @@ use OpenApi\Attributes\Get; use OpenApi\Attributes\JsonContent; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; -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\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\Setting\Service\SettingsServiceInterface; @@ -56,9 +54,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..0e3057b41 100644 --- a/src/Translation/Controller/TranslationController.php +++ b/src/Translation/Controller/TranslationController.php @@ -19,15 +19,13 @@ use OpenApi\Attributes\JsonContent; use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; -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\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 +60,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..e13e382f8 100644 --- a/src/Version/Controller/CleanupController.php +++ b/src/Version/Controller/CleanupController.php @@ -22,13 +22,10 @@ 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\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\Version\Repository\VersionRepositoryInterface; use Pimcore\Bundle\StudioBackendBundle\Version\Request\VersionCleanupParameters; use Symfony\Component\HttpFoundation\JsonResponse; @@ -65,11 +62,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..05ed878c8 100644 --- a/src/Version/Controller/CollectionController.php +++ b/src/Version/Controller/CollectionController.php @@ -23,14 +23,11 @@ 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\Error\BadRequestResponse; -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\DefaultResponses; 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 +70,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..33f7a17b2 100644 --- a/src/Version/Controller/DeleteController.php +++ b/src/Version/Controller/DeleteController.php @@ -20,15 +20,12 @@ 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\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\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 +59,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..44968af12 100644 --- a/src/Version/Controller/GetController.php +++ b/src/Version/Controller/GetController.php @@ -19,14 +19,11 @@ 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\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\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 +58,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..de6db93d2 100644 --- a/src/Version/Controller/PublishController.php +++ b/src/Version/Controller/PublishController.php @@ -20,14 +20,11 @@ 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\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\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 +58,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..f85841f81 100644 --- a/src/Workflow/Controller/DetailsCollectionController.php +++ b/src/Workflow/Controller/DetailsCollectionController.php @@ -21,14 +21,11 @@ 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\Error\BadRequestResponse; -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\DefaultResponses; 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 +69,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..535b31bbe 100644 --- a/src/Workflow/Controller/SubmitActionController.php +++ b/src/Workflow/Controller/SubmitActionController.php @@ -19,14 +19,11 @@ 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\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\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 +64,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