From 28dad357cb32e7033c96c122c0b20f82e7de3009 Mon Sep 17 00:00:00 2001 From: matiasperrone-exo Date: Tue, 17 Feb 2026 21:39:35 +0000 Subject: [PATCH] feat: Add OpenAPI documentation annotations for OAuth2GroupApiController v1 routes --- .../Api/OAuth2/OAuth2GroupApiController.php | 50 +++++++++++++++++++ app/Swagger/Models/GroupSchema.php | 24 +++++++++ .../OAuth2GroupApiControllerSchemas.php | 26 ++++++++++ ...OAuth2GroupApiControllerSecuritySchema.php | 23 +++++++++ 4 files changed, 123 insertions(+) create mode 100644 app/Swagger/Models/GroupSchema.php create mode 100644 app/Swagger/OAuth2GroupApiControllerSchemas.php create mode 100644 app/Swagger/Security/OAuth2GroupApiControllerSecuritySchema.php diff --git a/app/Http/Controllers/Api/OAuth2/OAuth2GroupApiController.php b/app/Http/Controllers/Api/OAuth2/OAuth2GroupApiController.php index e3288265..3684b000 100644 --- a/app/Http/Controllers/Api/OAuth2/OAuth2GroupApiController.php +++ b/app/Http/Controllers/Api/OAuth2/OAuth2GroupApiController.php @@ -16,6 +16,8 @@ use App\libs\Auth\Repositories\IGroupRepository; use App\ModelSerializers\SerializerRegistry; use OAuth2\IResourceServerContext; +use OpenApi\Attributes as OA; +use Symfony\Component\HttpFoundation\Response; use Utils\Services\ILogService; /** @@ -26,6 +28,54 @@ final class OAuth2GroupApiController extends OAuth2ProtectedController { use GetAllTrait; + #[OA\Get( + path: '/api/v1/groups', + operationId: 'getGroups', + summary: 'Get all groups', + description: 'Retrieves a paginated list of groups with optional filtering and ordering.', + tags: ['Groups'], + parameters: [ + new OA\Parameter( + name: 'page', + in: 'query', + description: 'Page number for pagination', + required: false, + schema: new OA\Schema(type: 'integer', minimum: 1, default: 1, example: 1) + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + description: 'Number of items per page', + required: false, + schema: new OA\Schema(type: 'integer', minimum: 5, maximum: 100, default: 5, example: 10) + ), + new OA\Parameter( + name: 'filter', + in: 'query', + description: 'Filter criteria. Supported filters: slug== (exact match). Example: filter=slug==administrators', + required: false, + schema: new OA\Schema(type: 'string', example: 'slug==administrators') + ), + new OA\Parameter( + name: 'order', + in: 'query', + description: 'Ordering criteria. Supported fields: id, name, slug. Use + for ascending, - for descending. Example: +name or -id', + required: false, + schema: new OA\Schema(type: 'string', example: '+name') + ) + ], + responses: [ + new OA\Response( + response: Response::HTTP_OK, + description: 'Successful response with paginated groups', + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedGroupResponseSchema') + ), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: 'Not Found'), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: 'Validation failed'), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: 'Server error') + ] + )] + /** * OAuth2UserApiController constructor. * @param IGroupRepository $repository diff --git a/app/Swagger/Models/GroupSchema.php b/app/Swagger/Models/GroupSchema.php new file mode 100644 index 00000000..72c7039c --- /dev/null +++ b/app/Swagger/Models/GroupSchema.php @@ -0,0 +1,24 @@ + 'Read all groups'] + ), + ] +)] +class OAuth2GroupApiControllerSecuritySchema +{ +} \ No newline at end of file