Skip to content

Commit 5c100aa

Browse files
chore: Add PR requested changes bullets 1 and 3
1 parent 16a5eb6 commit 5c100aa

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

app/Http/Controllers/Api/OAuth2/OAuth2GroupApiController.php

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php namespace App\Http\Controllers\Api\OAuth2;
1+
<?php
2+
namespace App\Http\Controllers\Api\OAuth2;
23
/**
34
* Copyright 2025 OpenStack Foundation
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,56 +26,6 @@
2526
* Class OAuth2GroupApiController
2627
* @package App\Http\Controllers\Api\OAuth2
2728
*/
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-
)]
7829
final class OAuth2GroupApiController extends OAuth2ProtectedController
7930
{
8031
use GetAllTrait;
@@ -90,12 +41,61 @@ public function __construct
9041
IGroupRepository $repository,
9142
IResourceServerContext $resource_server_context,
9243
ILogService $log_service,
93-
)
94-
{
44+
) {
9545
parent::__construct($resource_server_context, $log_service);
9646
$this->repository = $repository;
9747
}
9848

49+
#[OA\Get(
50+
path: '/api/v1/groups',
51+
operationId: 'getGroups',
52+
summary: 'Get all groups',
53+
description: 'Retrieves a paginated list of groups with optional filtering and ordering. No route-level middleware enforcement; requires valid OAuth2 bearer token only.',
54+
security: [['OAuth2GroupsSecurity' => [IGroupScopes::ReadAll]]],
55+
tags: ['Groups'],
56+
parameters: [
57+
new OA\Parameter(
58+
name: 'page',
59+
in: 'query',
60+
description: 'Page number for pagination',
61+
required: false,
62+
schema: new OA\Schema(type: 'integer', minimum: 1, default: 1, example: 1)
63+
),
64+
new OA\Parameter(
65+
name: 'per_page',
66+
in: 'query',
67+
description: 'Number of items per page',
68+
required: false,
69+
schema: new OA\Schema(type: 'integer', minimum: 5, maximum: 100, default: 5, example: 10)
70+
),
71+
new OA\Parameter(
72+
name: 'filter',
73+
in: 'query',
74+
description: 'Filter criteria. Supported filters: slug== (exact match). Example: filter=slug==administrators',
75+
required: false,
76+
schema: new OA\Schema(type: 'string', example: 'slug==administrators')
77+
),
78+
new OA\Parameter(
79+
name: 'order',
80+
in: 'query',
81+
description: 'Ordering criteria. Supported fields: id, name, slug. Use + for ascending, - for descending. Example: +name or -id',
82+
required: false,
83+
schema: new OA\Schema(type: 'string', example: '+name')
84+
)
85+
],
86+
responses: [
87+
new OA\Response(
88+
response: Response::HTTP_OK,
89+
description: 'Successful response with paginated groups',
90+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedGroupResponse')
91+
),
92+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: 'Unauthorized'),
93+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: 'Forbidden - insufficient scope'),
94+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: 'Not Found'),
95+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: 'Validation failed, invalid filter or order parameter'),
96+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: 'Server error')
97+
]
98+
)]
9999
protected function getAllSerializerType(): string
100100
{
101101
return SerializerRegistry::SerializerType_Public;

0 commit comments

Comments
 (0)