From c0d67a9c4e6abe101747dd67b4e9cc81a8208da5 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Tue, 10 Dec 2024 14:41:12 +0100 Subject: [PATCH 1/3] add some missing internal error responses --- src/Role/Controller/CloneController.php | 1 + src/Role/Controller/CreateFolderController.php | 1 + src/Role/Controller/CreateRoleController.php | 1 + src/Role/Controller/DeleteFolderController.php | 1 + src/Role/Controller/DeleteRoleController.php | 1 + src/Role/Controller/GetRoleController.php | 1 + src/Role/Controller/RoleTreeController.php | 5 ++++- src/Role/Controller/UpdateRoleController.php | 1 + src/User/Controller/CloneController.php | 1 + src/User/Controller/CreateUserController.php | 1 + src/User/Controller/CreateUserFolderController.php | 1 + src/User/Controller/DeleteUserFolderController.php | 1 + src/User/Controller/UpdateUserController.php | 1 + 13 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Role/Controller/CloneController.php b/src/Role/Controller/CloneController.php index 9d14d768..999d7b4a 100644 --- a/src/Role/Controller/CloneController.php +++ b/src/Role/Controller/CloneController.php @@ -71,6 +71,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function cloneRole(int $id, #[MapRequestPayload] RoleCloneParameter $roleClone): JsonResponse { diff --git a/src/Role/Controller/CreateFolderController.php b/src/Role/Controller/CreateFolderController.php index 7d9ac688..bb5a33fe 100644 --- a/src/Role/Controller/CreateFolderController.php +++ b/src/Role/Controller/CreateFolderController.php @@ -66,6 +66,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function createRoleFolder(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/Role/Controller/CreateRoleController.php b/src/Role/Controller/CreateRoleController.php index 2a104e4f..6c0a045a 100644 --- a/src/Role/Controller/CreateRoleController.php +++ b/src/Role/Controller/CreateRoleController.php @@ -66,6 +66,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function createRole(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/Role/Controller/DeleteFolderController.php b/src/Role/Controller/DeleteFolderController.php index e382172d..1733608e 100644 --- a/src/Role/Controller/DeleteFolderController.php +++ b/src/Role/Controller/DeleteFolderController.php @@ -59,6 +59,7 @@ public function __construct( #[IdParameter(type: 'folder')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function deleteRoleFolder(int $id): Response { diff --git a/src/Role/Controller/DeleteRoleController.php b/src/Role/Controller/DeleteRoleController.php index 744d140c..7a5ea0d8 100644 --- a/src/Role/Controller/DeleteRoleController.php +++ b/src/Role/Controller/DeleteRoleController.php @@ -60,6 +60,7 @@ public function __construct( #[IdParameter(type: 'role')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function deleteRole(int $id): Response { diff --git a/src/Role/Controller/GetRoleController.php b/src/Role/Controller/GetRoleController.php index 2e9ecf81..2e556879 100644 --- a/src/Role/Controller/GetRoleController.php +++ b/src/Role/Controller/GetRoleController.php @@ -67,6 +67,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function getRoleById(int $id): JsonResponse { diff --git a/src/Role/Controller/RoleTreeController.php b/src/Role/Controller/RoleTreeController.php index 71a4d829..fd337428 100644 --- a/src/Role/Controller/RoleTreeController.php +++ b/src/Role/Controller/RoleTreeController.php @@ -28,6 +28,7 @@ use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Schema\TreeNode; use Pimcore\Bundle\StudioBackendBundle\Role\Service\RoleServiceInterface; +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions; use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait; use Symfony\Component\HttpFoundation\Response; @@ -71,7 +72,9 @@ public function __construct( description: 'role_get_tree_success_response', content: new CollectionJson(new GenericCollection(TreeNode::class)) )] - #[DefaultResponses] + #[DefaultResponses([ + HttpResponseCodes::INTERNAL_SERVER_ERROR + ])] public function getRoleTree(#[MapQueryString] MappedParentIdParameter $roleTreeListingParameter): Response { $roles = $this->roleService->getRoleTreeCollection($roleTreeListingParameter); diff --git a/src/Role/Controller/UpdateRoleController.php b/src/Role/Controller/UpdateRoleController.php index da7e0303..610cbb2c 100644 --- a/src/Role/Controller/UpdateRoleController.php +++ b/src/Role/Controller/UpdateRoleController.php @@ -74,6 +74,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function updateRoleById(int $id, #[MapRequestPayload] UpdateRoleParameter $roleUpdate): JsonResponse { diff --git a/src/User/Controller/CloneController.php b/src/User/Controller/CloneController.php index ec492424..fbc0593a 100644 --- a/src/User/Controller/CloneController.php +++ b/src/User/Controller/CloneController.php @@ -74,6 +74,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function cloneUser(int $id, #[MapRequestPayload] UserCloneParameter $userClone): JsonResponse { diff --git a/src/User/Controller/CreateUserController.php b/src/User/Controller/CreateUserController.php index e9a3a372..fb3573ae 100644 --- a/src/User/Controller/CreateUserController.php +++ b/src/User/Controller/CreateUserController.php @@ -69,6 +69,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function createUser(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/User/Controller/CreateUserFolderController.php b/src/User/Controller/CreateUserFolderController.php index 60422991..35eaea15 100644 --- a/src/User/Controller/CreateUserFolderController.php +++ b/src/User/Controller/CreateUserFolderController.php @@ -69,6 +69,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function createUserFolder(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/User/Controller/DeleteUserFolderController.php b/src/User/Controller/DeleteUserFolderController.php index 02475bde..bc33ac4c 100644 --- a/src/User/Controller/DeleteUserFolderController.php +++ b/src/User/Controller/DeleteUserFolderController.php @@ -63,6 +63,7 @@ public function __construct( #[IdParameter(type: 'user-folder')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function deleteUserFolder(int $id): Response { diff --git a/src/User/Controller/UpdateUserController.php b/src/User/Controller/UpdateUserController.php index f40d66b6..930250c3 100644 --- a/src/User/Controller/UpdateUserController.php +++ b/src/User/Controller/UpdateUserController.php @@ -79,6 +79,7 @@ public function __construct( #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, HttpResponseCodes::FORBIDDEN, + HttpResponseCodes::INTERNAL_SERVER_ERROR ])] public function updateUsers(int $id, #[MapRequestPayload] UpdateUserParameter $userUpdate): JsonResponse { From 6153c3a806a10963d7dc65ca2c4e84d6805e8d45 Mon Sep 17 00:00:00 2001 From: lukmzig Date: Tue, 10 Dec 2024 14:45:02 +0100 Subject: [PATCH 2/3] add some missing internal error responses --- src/Asset/Controller/GetController.php | 3 ++- .../Grid/Configuration/GetAvailableColumnsController.php | 3 ++- .../Grid/Configuration/GetConfigurationController.php | 3 ++- .../Grid/Configuration/ListSavedConfigurationsController.php | 1 + src/Asset/Controller/Image/ThumbnailDownloadController.php | 3 ++- src/Asset/Controller/TreeController.php | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Asset/Controller/GetController.php b/src/Asset/Controller/GetController.php index e1601d5b..99686f6b 100644 --- a/src/Asset/Controller/GetController.php +++ b/src/Asset/Controller/GetController.php @@ -64,8 +64,9 @@ public function __construct( content: new OneOfAssetJson() )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::UNAUTHORIZED, ])] public function getAssetById(int $id): JsonResponse { diff --git a/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php b/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php index 41ed6747..82d6ba9f 100644 --- a/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php +++ b/src/Asset/Controller/Grid/Configuration/GetAvailableColumnsController.php @@ -75,8 +75,9 @@ public function __construct( ) )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::UNAUTHORIZED, ])] public function getAvailableAssetGridColumns(): JsonResponse { diff --git a/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php b/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php index 39df175c..865bed4a 100644 --- a/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php +++ b/src/Asset/Controller/Grid/Configuration/GetConfigurationController.php @@ -72,8 +72,9 @@ public function __construct( content: new JsonContent(ref: DetailedConfiguration::class) )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::UNAUTHORIZED, ])] public function getAssetGridConfiguration( int $folderId, diff --git a/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php b/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php index 33abb845..25bc66f0 100644 --- a/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php +++ b/src/Asset/Controller/Grid/Configuration/ListSavedConfigurationsController.php @@ -72,6 +72,7 @@ public function __construct( content: new CollectionJson(new GenericCollection(Configuration::class)) )] #[DefaultResponses([ + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::UNAUTHORIZED, HttpResponseCodes::NOT_FOUND, ])] diff --git a/src/Asset/Controller/Image/ThumbnailDownloadController.php b/src/Asset/Controller/Image/ThumbnailDownloadController.php index e4017552..201e2392 100644 --- a/src/Asset/Controller/Image/ThumbnailDownloadController.php +++ b/src/Asset/Controller/Image/ThumbnailDownloadController.php @@ -82,8 +82,9 @@ public function __construct( headers: [new ContentDisposition()] )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::UNAUTHORIZED, ])] public function downloadImageByThumbnail(int $id, string $thumbnailName): BinaryFileResponse { diff --git a/src/Asset/Controller/TreeController.php b/src/Asset/Controller/TreeController.php index a0fb4728..26d68593 100644 --- a/src/Asset/Controller/TreeController.php +++ b/src/Asset/Controller/TreeController.php @@ -88,8 +88,9 @@ public function __construct( content: new CollectionJson(new AnyOfAsset()) )] #[DefaultResponses([ - HttpResponseCodes::UNAUTHORIZED, + HttpResponseCodes::BAD_REQUEST, HttpResponseCodes::NOT_FOUND, + HttpResponseCodes::UNAUTHORIZED, ])] public function getAssetTree(#[MapQueryString] ElementParameters $parameters): JsonResponse { From bb5f7863a459b94385194575f7069fbe0e3fac7d Mon Sep 17 00:00:00 2001 From: lukmzig Date: Tue, 10 Dec 2024 13:47:38 +0000 Subject: [PATCH 3/3] Apply php-cs-fixer changes --- src/Role/Controller/CloneController.php | 2 +- src/Role/Controller/CreateFolderController.php | 2 +- src/Role/Controller/CreateRoleController.php | 2 +- src/Role/Controller/DeleteFolderController.php | 2 +- src/Role/Controller/DeleteRoleController.php | 2 +- src/Role/Controller/GetRoleController.php | 2 +- src/Role/Controller/RoleTreeController.php | 2 +- src/Role/Controller/UpdateRoleController.php | 2 +- src/User/Controller/CloneController.php | 2 +- src/User/Controller/CreateUserController.php | 2 +- src/User/Controller/CreateUserFolderController.php | 2 +- src/User/Controller/DeleteUserFolderController.php | 2 +- src/User/Controller/UpdateUserController.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Role/Controller/CloneController.php b/src/Role/Controller/CloneController.php index 999d7b4a..3cf23551 100644 --- a/src/Role/Controller/CloneController.php +++ b/src/Role/Controller/CloneController.php @@ -71,7 +71,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function cloneRole(int $id, #[MapRequestPayload] RoleCloneParameter $roleClone): JsonResponse { diff --git a/src/Role/Controller/CreateFolderController.php b/src/Role/Controller/CreateFolderController.php index bb5a33fe..4b9e14ed 100644 --- a/src/Role/Controller/CreateFolderController.php +++ b/src/Role/Controller/CreateFolderController.php @@ -66,7 +66,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function createRoleFolder(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/Role/Controller/CreateRoleController.php b/src/Role/Controller/CreateRoleController.php index 6c0a045a..bb2d7aca 100644 --- a/src/Role/Controller/CreateRoleController.php +++ b/src/Role/Controller/CreateRoleController.php @@ -66,7 +66,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function createRole(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/Role/Controller/DeleteFolderController.php b/src/Role/Controller/DeleteFolderController.php index 1733608e..8e14587a 100644 --- a/src/Role/Controller/DeleteFolderController.php +++ b/src/Role/Controller/DeleteFolderController.php @@ -59,7 +59,7 @@ public function __construct( #[IdParameter(type: 'folder')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function deleteRoleFolder(int $id): Response { diff --git a/src/Role/Controller/DeleteRoleController.php b/src/Role/Controller/DeleteRoleController.php index 7a5ea0d8..12345b7a 100644 --- a/src/Role/Controller/DeleteRoleController.php +++ b/src/Role/Controller/DeleteRoleController.php @@ -60,7 +60,7 @@ public function __construct( #[IdParameter(type: 'role')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function deleteRole(int $id): Response { diff --git a/src/Role/Controller/GetRoleController.php b/src/Role/Controller/GetRoleController.php index 2e556879..b81b890f 100644 --- a/src/Role/Controller/GetRoleController.php +++ b/src/Role/Controller/GetRoleController.php @@ -67,7 +67,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function getRoleById(int $id): JsonResponse { diff --git a/src/Role/Controller/RoleTreeController.php b/src/Role/Controller/RoleTreeController.php index fd337428..79fbef62 100644 --- a/src/Role/Controller/RoleTreeController.php +++ b/src/Role/Controller/RoleTreeController.php @@ -73,7 +73,7 @@ public function __construct( content: new CollectionJson(new GenericCollection(TreeNode::class)) )] #[DefaultResponses([ - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function getRoleTree(#[MapQueryString] MappedParentIdParameter $roleTreeListingParameter): Response { diff --git a/src/Role/Controller/UpdateRoleController.php b/src/Role/Controller/UpdateRoleController.php index 610cbb2c..16c9ca13 100644 --- a/src/Role/Controller/UpdateRoleController.php +++ b/src/Role/Controller/UpdateRoleController.php @@ -74,7 +74,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function updateRoleById(int $id, #[MapRequestPayload] UpdateRoleParameter $roleUpdate): JsonResponse { diff --git a/src/User/Controller/CloneController.php b/src/User/Controller/CloneController.php index fbc0593a..6c62ff76 100644 --- a/src/User/Controller/CloneController.php +++ b/src/User/Controller/CloneController.php @@ -74,7 +74,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function cloneUser(int $id, #[MapRequestPayload] UserCloneParameter $userClone): JsonResponse { diff --git a/src/User/Controller/CreateUserController.php b/src/User/Controller/CreateUserController.php index fb3573ae..0cfa5345 100644 --- a/src/User/Controller/CreateUserController.php +++ b/src/User/Controller/CreateUserController.php @@ -69,7 +69,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function createUser(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/User/Controller/CreateUserFolderController.php b/src/User/Controller/CreateUserFolderController.php index 35eaea15..264090cc 100644 --- a/src/User/Controller/CreateUserFolderController.php +++ b/src/User/Controller/CreateUserFolderController.php @@ -69,7 +69,7 @@ public function __construct( )] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function createUserFolder(#[MapRequestPayload] CreateParameter $createParameter): JsonResponse { diff --git a/src/User/Controller/DeleteUserFolderController.php b/src/User/Controller/DeleteUserFolderController.php index bc33ac4c..3dcf35f8 100644 --- a/src/User/Controller/DeleteUserFolderController.php +++ b/src/User/Controller/DeleteUserFolderController.php @@ -63,7 +63,7 @@ public function __construct( #[IdParameter(type: 'user-folder')] #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function deleteUserFolder(int $id): Response { diff --git a/src/User/Controller/UpdateUserController.php b/src/User/Controller/UpdateUserController.php index 930250c3..f3e0d806 100644 --- a/src/User/Controller/UpdateUserController.php +++ b/src/User/Controller/UpdateUserController.php @@ -79,7 +79,7 @@ public function __construct( #[DefaultResponses([ HttpResponseCodes::NOT_FOUND, HttpResponseCodes::FORBIDDEN, - HttpResponseCodes::INTERNAL_SERVER_ERROR + HttpResponseCodes::INTERNAL_SERVER_ERROR, ])] public function updateUsers(int $id, #[MapRequestPayload] UpdateUserParameter $userUpdate): JsonResponse {