From 52b860cfb5aac5a1cc5e0063a908a751bc2d4abe Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Tue, 14 Oct 2025 17:24:18 -0300 Subject: [PATCH] feat: Extend Swagger Coverage for controller `OAuth2SummitBadgeTypeApiController` --- .../OAuth2SummitBadgeTypeApiController.php | 579 ++++++++++++++++-- app/Swagger/SummitRegistrationSchemas.php | 87 +++ 2 files changed, 619 insertions(+), 47 deletions(-) diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitBadgeTypeApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitBadgeTypeApiController.php index 3f37aba7a..dcd40bfad 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitBadgeTypeApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitBadgeTypeApiController.php @@ -1,4 +1,7 @@ - []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'page', + in: 'query', + required: false, + schema: new OA\Schema(type: 'integer', default: 1), + description: 'Page number' + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + required: false, + schema: new OA\Schema(type: 'integer', default: 10), + description: 'Items per page' + ), + new OA\Parameter( + name: 'filter', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Filter operators: name=@/==, is_default==' + ), + new OA\Parameter( + name: 'order', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Order by fields: id, name' + ), + new OA\Parameter( + name: 'expand', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to expand: access_levels, badge_features, allowed_view_types' + ), + new OA\Parameter( + name: 'relations', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to include: access_levels, badge_features, allowed_view_types' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/PaginatedSummitBadgeTypesResponse") + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] + public function getAllBySummit($summit_id) { + return $this->traitGetAllBySummit($summit_id); + } + + #[OA\Get( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}", + description: "Get a specific badge type", + summary: "Get badge type", + operationId: "getSummitBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'expand', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to expand: access_levels, badge_features, allowed_view_types' + ), + new OA\Parameter( + name: 'relations', + in: 'query', + required: false, + explode: false, + schema: new OA\Schema(type: 'string'), + description: 'Relations to include: access_levels, badge_features, allowed_view_types' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] + public function get($summit_id, $badge_type_id) { + return $this->traitGet($summit_id, $badge_type_id); + } - use AddSummitChildElement; + #[OA\Post( + path: "/api/v1/summits/{id}/badge-types", + description: "Create a new badge type", + summary: "Create badge type", + operationId: "addSummitBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeTypeCreateRequest") + ), + responses: [ + new OA\Response( + response: 201, + description: "Created", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] + public function add($summit_id) { + return $this->traitAdd($summit_id); + } - use UpdateSummitChildElement; + #[OA\Put( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}", + description: "Update an existing badge type", + summary: "Update badge type", + operationId: "updateSummitBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ) + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeTypeUpdateRequest") + ), + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] + public function update($summit_id, $badge_type_id) { + return $this->traitUpdate($summit_id, $badge_type_id); + } - use DeleteSummitChildElement; + #[OA\Delete( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}", + description: "Delete a badge type", + summary: "Delete badge type", + operationId: "deleteSummitBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ) + ], + responses: [ + new OA\Response(response: 204, description: 'No Content'), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] + public function delete($summit_id, $badge_type_id) { + return $this->traitDelete($summit_id, $badge_type_id); + } /** * @param array $payload @@ -181,12 +444,49 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I return $this->service->updateBadgeType($summit, $child_id, $payload); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $access_level_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Put( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/access-levels/{access_level_id}", + description: "Add an access level to a badge type", + summary: "Add access level to badge type", + operationId: "addAccessLevelToBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'access_level_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The access level id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function addAccessLevelToBadgeType($summit_id, $badge_type_id, $access_level_id){ return $this->processRequest(function() use( $summit_id, $badge_type_id, $access_level_id){ @@ -203,12 +503,49 @@ public function addAccessLevelToBadgeType($summit_id, $badge_type_id, $access_le }); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $access_level_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Delete( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/access-levels/{access_level_id}", + description: "Remove an access level from a badge type", + summary: "Remove access level from badge type", + operationId: "removeAccessLevelFromBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'access_level_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The access level id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function removeAccessLevelFromBadgeType($summit_id, $badge_type_id, $access_level_id){ return $this->processRequest(function() use($summit_id, $badge_type_id, $access_level_id){ $summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id); @@ -223,12 +560,49 @@ public function removeAccessLevelFromBadgeType($summit_id, $badge_type_id, $acce }); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $feature_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Put( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/features/{feature_id}", + description: "Add a feature to a badge type", + summary: "Add feature to badge type", + operationId: "addFeatureToBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'feature_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The feature id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function addFeatureToBadgeType($summit_id, $badge_type_id, $feature_id){ return $this->processRequest(function() use($summit_id, $badge_type_id, $feature_id){ @@ -244,12 +618,49 @@ public function addFeatureToBadgeType($summit_id, $badge_type_id, $feature_id){ }); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $feature_id - * @return \Illuminate\Http\JsonResponse|mixed - */ + #[OA\Delete( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/features/{feature_id}", + description: "Remove a feature from a badge type", + summary: "Remove feature from badge type", + operationId: "removeFeatureFromBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'feature_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The feature id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function removeFeatureFromBadgeType($summit_id, $badge_type_id, $feature_id){ return $this->processRequest(function() use ($summit_id, $badge_type_id, $feature_id){ $summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id); @@ -264,12 +675,49 @@ public function removeFeatureFromBadgeType($summit_id, $badge_type_id, $feature_ }); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $view_type_id - * @return mixed - */ + #[OA\Put( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/view-types/{badge_view_type_id}", + description: "Add a view type to a badge type", + summary: "Add view type to badge type", + operationId: "addViewTypeToBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'badge_view_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge view type id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function addViewTypeToBadgeType($summit_id, $badge_type_id, $view_type_id){ return $this->processRequest(function() use($summit_id, $badge_type_id, $view_type_id){ @@ -285,12 +733,49 @@ public function addViewTypeToBadgeType($summit_id, $badge_type_id, $view_type_id }); } - /** - * @param $summit_id - * @param $badge_type_id - * @param $view_type_id - * @return mixed - */ + #[OA\Delete( + path: "/api/v1/summits/{id}/badge-types/{badge_type_id}/view-types/{badge_view_type_id}", + description: "Remove a view type from a badge type", + summary: "Remove view type from badge type", + operationId: "removeViewTypeFromBadgeType", + tags: ['Badge Types'], + security: [['summit_oauth2' => []]], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The summit id' + ), + new OA\Parameter( + name: 'badge_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge type id' + ), + new OA\Parameter( + name: 'badge_view_type_id', + in: 'path', + required: true, + schema: new OA\Schema(type: 'integer'), + description: 'The badge view type id' + ) + ], + responses: [ + new OA\Response( + response: 200, + description: "OK", + content: new OA\JsonContent(ref: "#/components/schemas/SummitBadgeType") + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function removeViewTypeFromBadgeType($summit_id, $badge_type_id, $view_type_id){ return $this->processRequest(function() use ($summit_id, $badge_type_id, $view_type_id){ $summit = SummitFinderStrategyFactory::build($this->getSummitRepository(), $this->getResourceServerContext())->find($summit_id); @@ -306,4 +791,4 @@ public function removeViewTypeFromBadgeType($summit_id, $badge_type_id, $view_ty }); } -} \ No newline at end of file +} diff --git a/app/Swagger/SummitRegistrationSchemas.php b/app/Swagger/SummitRegistrationSchemas.php index 6b3e2f895..e7a2ea07c 100644 --- a/app/Swagger/SummitRegistrationSchemas.php +++ b/app/Swagger/SummitRegistrationSchemas.php @@ -4,4 +4,91 @@ use OpenApi\Attributes as OA; +// Badge Types + +#[OA\Schema( + schema: "SummitBadgeType", + description: "Summit badge type", + type: "object", + properties: [ + new OA\Property(property: "id", type: "integer", example: 1), + new OA\Property(property: "created", type: "integer", description: "Unix timestamp", example: 1640995200), + new OA\Property(property: "last_edited", type: "integer", description: "Unix timestamp", example: 1640995200), + new OA\Property(property: "name", type: "string", example: "Attendee"), + new OA\Property(property: "description", type: "string", example: "Standard attendee badge"), + new OA\Property(property: "template_content", type: "string", nullable: true, example: "Badge template content"), + new OA\Property(property: "is_default", type: "boolean", example: false), + new OA\Property(property: "summit_id", type: "integer", example: 1), + new OA\Property( + property: "access_levels", + type: "array", + items: new OA\Items(type: ["integer", "SummitAccessLevelType"]), + ), + new OA\Property( + property: "badge_features", + type: "array", + items: new OA\Items(type: ["integer", "SummitBadgeFeatureType"]), + ), + new OA\Property( + property: "allowed_view_types", + type: "array", + items: new OA\Items(type: ["integer", "SummitBadgeViewType"]), + ), + ], +)] +class SummitBadgeType +{ +} + +#[OA\Schema( + schema: "PaginatedSummitBadgeTypesResponse", + description: "Paginated list of summit badge types", + allOf: [ + new OA\Schema(ref: "#/components/schemas/PaginateDataSchemaResponse"), + new OA\Schema( + properties: [ + new OA\Property( + property: "data", + type: "array", + items: new OA\Items(ref: "#/components/schemas/SummitBadgeType") + ) + ] + ) + ] +)] +class PaginatedSummitBadgeTypesResponse +{ +} + +#[OA\Schema( + schema: "SummitBadgeTypeCreateRequest", + description: "Request to create a summit badge type", + required: ["name", "description", "is_default"], + type: "object", + properties: [ + new OA\Property(property: "name", type: "string", example: "Attendee"), + new OA\Property(property: "description", type: "string", example: "Standard attendee badge"), + new OA\Property(property: "template_content", type: "string", nullable: true, example: "Badge template content"), + new OA\Property(property: "is_default", type: "boolean", example: false), + ] +)] +class SummitBadgeTypeCreateRequest +{ +} + +#[OA\Schema( + schema: "SummitBadgeTypeUpdateRequest", + description: "Request to update a summit badge type", + type: "object", + properties: [ + new OA\Property(property: "name", type: "string", nullable: true, example: "Attendee"), + new OA\Property(property: "description", type: "string", nullable: true, example: "Standard attendee badge"), + new OA\Property(property: "template_content", type: "string", nullable: true, example: "Badge template content"), + new OA\Property(property: "is_default", type: "boolean", nullable: true, example: false), + ] +)] +class SummitBadgeTypeUpdateRequest +{ +} + //