Skip to content

Commit 8f63195

Browse files
committed
fix: Incorrect responses
1 parent e77db3b commit 8f63195

1 file changed

Lines changed: 76 additions & 46 deletions

File tree

app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitBadgeFeatureTypeApiController.php

Lines changed: 76 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* limitations under the License.
1616
**/
1717
use App\Models\Foundation\Summit\Repositories\ISummitBadgeFeatureTypeRepository;
18+
use App\Models\Foundation\Main\IGroup;
1819
use App\Security\SummitScopes;
1920
use App\Services\Model\ISummitBadgeFeatureTypeService;
2021
use Illuminate\Http\Request as LaravelRequest;
22+
use Illuminate\Http\Response;
2123
use Illuminate\Support\Facades\Log;
2224
use models\exceptions\EntityNotFoundException;
2325
use models\exceptions\ValidationException;
@@ -29,6 +31,27 @@
2931
use ModelSerializers\SerializerRegistry;
3032
use OpenApi\Attributes as OA;
3133
use Exception;
34+
35+
36+
#[OA\SecurityScheme(
37+
type: 'oauth2',
38+
securityScheme: 'badge_feature_types_oauth2',
39+
flows: [
40+
new OA\Flow(
41+
authorizationUrl: L5_SWAGGER_CONST_AUTH_URL,
42+
tokenUrl: L5_SWAGGER_CONST_TOKEN_URL,
43+
flow: 'authorizationCode',
44+
scopes: [
45+
SummitScopes::ReadAllSummitData => 'Read All Summit Data',
46+
SummitScopes::ReadSummitData => 'Read Summit Data',
47+
SummitScopes::WriteSummitData => 'Write Summit Data',
48+
],
49+
),
50+
],
51+
)
52+
]
53+
class BadgeFeatureTypesOauth2Schema{}
54+
3255
/**
3356
* Class OAuth2SummitBadgeFeatureTypeApiController
3457
* @package App\Http\Controllers
@@ -74,7 +97,14 @@ public function __construct
7497
path: '/api/v1/summits/{id}/badge-feature-types',
7598
summary: 'Get all badge feature types for a summit',
7699
description: 'Retrieves a paginated list of badge feature types for a specific summit. Badge feature types define visual elements and features that can be applied to attendee badges (e.g., speaker ribbons, sponsor logos, special access indicators).',
77-
security: [['oauth2_security_scope' => [
100+
x: [
101+
'required-groups' => [
102+
IGroup::SummitAdministrators,
103+
IGroup::SuperAdmins,
104+
IGroup::Administrators
105+
]
106+
],
107+
security: [['badge_feature_types_oauth2' => [
78108
SummitScopes::ReadSummitData,
79109
SummitScopes::ReadAllSummitData,
80110
]]],
@@ -127,12 +157,12 @@ public function __construct
127157
description: 'Badge feature types retrieved successfully',
128158
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedSummitBadgeFeatureTypesResponse')
129159
),
130-
new OA\Response(response: 400, ref: '#/components/responses/400'),
131-
new OA\Response(response: 401, ref: '#/components/responses/401'),
132-
new OA\Response(response: 403, ref: '#/components/responses/403'),
133-
new OA\Response(response: 404, ref: '#/components/responses/404'),
134-
new OA\Response(response: 412, ref: '#/components/responses/412'),
135-
new OA\Response(response: 500, ref: '#/components/responses/500'),
160+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
161+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
162+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
163+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
164+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
165+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
136166
]
137167
)]
138168

@@ -144,7 +174,7 @@ public function __construct
144174
SummitScopes::ReadSummitData,
145175
SummitScopes::ReadAllSummitData,
146176
]]],
147-
tags: ['Badge Feature Types'],
177+
tags: ['Badges Feature Types'],
148178
parameters: [
149179
new OA\Parameter(
150180
name: 'id',
@@ -167,12 +197,12 @@ public function __construct
167197
description: 'Badge feature type retrieved successfully',
168198
content: new OA\JsonContent(ref: '#/components/schemas/SummitBadgeFeatureType')
169199
),
170-
new OA\Response(response: 400, ref: '#/components/responses/400'),
171-
new OA\Response(response: 401, ref: '#/components/responses/401'),
172-
new OA\Response(response: 403, ref: '#/components/responses/403'),
173-
new OA\Response(response: 404, ref: '#/components/responses/404'),
174-
new OA\Response(response: 412, ref: '#/components/responses/412'),
175-
new OA\Response(response: 500, ref: '#/components/responses/500'),
200+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
201+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
202+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
203+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
204+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
205+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
176206
]
177207
)]
178208

@@ -201,13 +231,13 @@ public function __construct
201231
description: 'Badge feature type created successfully',
202232
content: new OA\JsonContent(ref: '#/components/schemas/SummitBadgeFeatureType')
203233
),
204-
new OA\Response(response: 400, ref: '#/components/responses/400'),
205-
new OA\Response(response: 401, ref: '#/components/responses/401'),
206-
new OA\Response(response: 403, ref: '#/components/responses/403'),
207-
new OA\Response(response: 404, ref: '#/components/responses/404'),
208-
new OA\Response(response: 412, ref: '#/components/responses/412'),
209-
new OA\Response(response: 422, ref: '#/components/responses/422'),
210-
new OA\Response(response: 500, ref: '#/components/responses/500'),
234+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
235+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
236+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
237+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
238+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
239+
new OA\Response(response: Response::HTTP_UNPROCESSABLE_ENTITY, description: "Unprocessable Entity"),
240+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
211241
]
212242
)]
213243

@@ -243,13 +273,13 @@ public function __construct
243273
description: 'Badge feature type updated successfully',
244274
content: new OA\JsonContent(ref: '#/components/schemas/SummitBadgeFeatureType')
245275
),
246-
new OA\Response(response: 400, ref: '#/components/responses/400'),
247-
new OA\Response(response: 401, ref: '#/components/responses/401'),
248-
new OA\Response(response: 403, ref: '#/components/responses/403'),
249-
new OA\Response(response: 404, ref: '#/components/responses/404'),
250-
new OA\Response(response: 412, ref: '#/components/responses/412'),
251-
new OA\Response(response: 422, ref: '#/components/responses/422'),
252-
new OA\Response(response: 500, ref: '#/components/responses/500'),
276+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
277+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
278+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
279+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
280+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
281+
new OA\Response(response: Response::HTTP_UNPROCESSABLE_ENTITY, description: "Unprocessable Entity"),
282+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
253283
]
254284
)]
255285

@@ -280,12 +310,12 @@ public function __construct
280310
response: 204,
281311
description: 'Badge feature type deleted successfully'
282312
),
283-
new OA\Response(response: 400, ref: '#/components/responses/400'),
284-
new OA\Response(response: 401, ref: '#/components/responses/401'),
285-
new OA\Response(response: 403, ref: '#/components/responses/403'),
286-
new OA\Response(response: 404, ref: '#/components/responses/404'),
287-
new OA\Response(response: 412, ref: '#/components/responses/412'),
288-
new OA\Response(response: 500, ref: '#/components/responses/500'),
313+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
314+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
315+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
316+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
317+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
318+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
289319
]
290320
)]
291321

@@ -340,12 +370,12 @@ public function __construct
340370
]
341371
)
342372
),
343-
new OA\Response(response: 400, ref: '#/components/responses/400'),
344-
new OA\Response(response: 401, ref: '#/components/responses/401'),
345-
new OA\Response(response: 403, ref: '#/components/responses/403'),
346-
new OA\Response(response: 404, ref: '#/components/responses/404'),
347-
new OA\Response(response: 412, ref: '#/components/responses/412'),
348-
new OA\Response(response: 500, ref: '#/components/responses/500'),
373+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
374+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
375+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
376+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
377+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
378+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
349379
]
350380
)]
351381

@@ -376,12 +406,12 @@ public function __construct
376406
response: 204,
377407
description: 'Image deleted successfully'
378408
),
379-
new OA\Response(response: 400, ref: '#/components/responses/400'),
380-
new OA\Response(response: 401, ref: '#/components/responses/401'),
381-
new OA\Response(response: 403, ref: '#/components/responses/403'),
382-
new OA\Response(response: 404, ref: '#/components/responses/404'),
383-
new OA\Response(response: 412, ref: '#/components/responses/412'),
384-
new OA\Response(response: 500, ref: '#/components/responses/500'),
409+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
410+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
411+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
412+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),
413+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
414+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
385415
]
386416
)]
387417

0 commit comments

Comments
 (0)