|
14 | 14 |
|
15 | 15 | use App\Http\Controllers\GetAllTrait; |
16 | 16 | use App\libs\Auth\Repositories\IGroupRepository; |
| 17 | +use App\libs\OAuth2\IGroupScopes; |
17 | 18 | use App\ModelSerializers\SerializerRegistry; |
18 | 19 | use OAuth2\IResourceServerContext; |
| 20 | +use OpenApi\Attributes as OA; |
| 21 | +use Symfony\Component\HttpFoundation\Response; |
19 | 22 | use Utils\Services\ILogService; |
20 | 23 |
|
21 | 24 | /** |
22 | 25 | * Class OAuth2GroupApiController |
23 | 26 | * @package App\Http\Controllers\Api\OAuth2 |
24 | 27 | */ |
| 28 | +#[OA\Get( |
| 29 | + path: '/api/v1/groups', |
| 30 | + operationId: 'getGroups', |
| 31 | + summary: 'Get all groups', |
| 32 | + description: 'Retrieves a paginated list of groups with optional filtering and ordering.', |
| 33 | + security: [['OAuth2GroupsSecurity' => [IGroupScopes::ReadAll]]], |
| 34 | + tags: ['Groups'], |
| 35 | + parameters: [ |
| 36 | + new OA\Parameter( |
| 37 | + name: 'page', |
| 38 | + in: 'query', |
| 39 | + description: 'Page number for pagination', |
| 40 | + required: false, |
| 41 | + schema: new OA\Schema(type: 'integer', minimum: 1, default: 1, example: 1) |
| 42 | + ), |
| 43 | + new OA\Parameter( |
| 44 | + name: 'per_page', |
| 45 | + in: 'query', |
| 46 | + description: 'Number of items per page', |
| 47 | + required: false, |
| 48 | + schema: new OA\Schema(type: 'integer', minimum: 5, maximum: 100, default: 5, example: 10) |
| 49 | + ), |
| 50 | + new OA\Parameter( |
| 51 | + name: 'filter', |
| 52 | + in: 'query', |
| 53 | + description: 'Filter criteria. Supported filters: slug== (exact match). Example: filter=slug==administrators', |
| 54 | + required: false, |
| 55 | + schema: new OA\Schema(type: 'string', example: 'slug==administrators') |
| 56 | + ), |
| 57 | + new OA\Parameter( |
| 58 | + name: 'order', |
| 59 | + in: 'query', |
| 60 | + description: 'Ordering criteria. Supported fields: id, name, slug. Use + for ascending, - for descending. Example: +name or -id', |
| 61 | + required: false, |
| 62 | + schema: new OA\Schema(type: 'string', example: '+name') |
| 63 | + ) |
| 64 | + ], |
| 65 | + responses: [ |
| 66 | + new OA\Response( |
| 67 | + response: Response::HTTP_OK, |
| 68 | + description: 'Successful response with paginated groups', |
| 69 | + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedGroupResponse') |
| 70 | + ), |
| 71 | + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: 'Unauthorized'), |
| 72 | + new OA\Response(response: Response::HTTP_FORBIDDEN, description: 'Forbidden - insufficient scope'), |
| 73 | + new OA\Response(response: Response::HTTP_NOT_FOUND, description: 'Not Found'), |
| 74 | + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: 'Validation failed, invalid filter or order parameter'), |
| 75 | + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: 'Server error') |
| 76 | + ] |
| 77 | +)] |
25 | 78 | final class OAuth2GroupApiController extends OAuth2ProtectedController |
26 | 79 | { |
27 | 80 | use GetAllTrait; |
28 | 81 |
|
29 | 82 | /** |
30 | | - * OAuth2UserApiController constructor. |
| 83 | + * OAuth2GroupApiController constructor. |
31 | 84 | * @param IGroupRepository $repository |
32 | 85 | * @param IResourceServerContext $resource_server_context |
33 | 86 | * @param ILogService $log_service |
|
0 commit comments