Skip to content

Commit 86cab5f

Browse files
chore: Add unique operationId attribute to OpenAPI documentation
Signed-off-by: matiasperrone-exo <matias.perrone@exomindset.co>
1 parent d46008f commit 86cab5f

5 files changed

Lines changed: 698 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ final class OAuth2UserApiController extends OAuth2ProtectedController
5555
#[OA\Get(
5656
path: '/api/v1/users',
5757
summary: 'Get all users',
58+
operationId: 'getUsers',
5859
tags: ['Users'],
5960
security: [
6061
['user_oauth2' => [
@@ -211,6 +212,7 @@ public function __construct
211212
#[OA\Get(
212213
path: '/api/v1/users/me',
213214
summary: 'Get current user basic info',
215+
operationId: 'getCurrentUser',
214216
tags: ['Users'],
215217
security: [
216218
['user_oauth2' => [
@@ -328,12 +330,18 @@ private function _update($id){
328330
#[OA\Post(
329331
path: '/api/v1/users',
330332
summary: 'Create a new user',
333+
operationId: 'createUser',
331334
tags: ['Users'],
332335
security: [
333336
['user_oauth2' => [
334337
IUserScopes::Write,
335338
]],
336339
],
340+
requestBody: new OA\RequestBody(
341+
description: 'User data',
342+
required: true,
343+
content: new OA\JsonContent(ref: '#/components/schemas/CreateUserRequest')
344+
),
337345
responses: [
338346
new OA\Response(
339347
response: HttpResponse::HTTP_CREATED,
@@ -365,12 +373,18 @@ public function create(){
365373
#[OA\Put(
366374
path: '/api/v1/users/me',
367375
summary: 'Update current user',
376+
operationId: 'updateCurrentUser',
368377
tags: ['Users'],
369378
security: [
370379
['user_oauth2' => [
371380
IUserScopes::MeWrite,
372381
]],
373382
],
383+
requestBody: new OA\RequestBody(
384+
description: 'User data to update',
385+
required: true,
386+
content: new OA\JsonContent(ref: '#/components/schemas/UpdateUserRequest')
387+
),
374388
responses: [
375389
new OA\Response(
376390
response: HttpResponse::HTTP_CREATED,
@@ -402,6 +416,7 @@ public function updateMe(){
402416
#[OA\Put(
403417
path: '/api/v1/users/{id}',
404418
summary: 'Update a user by ID',
419+
operationId: 'updateUser',
405420
tags: ['Users'],
406421
security: [
407422
['user_oauth2' => [
@@ -417,6 +432,11 @@ public function updateMe(){
417432
schema: new OA\Schema(type: 'integer')
418433
),
419434
],
435+
requestBody: new OA\RequestBody(
436+
description: 'User data to update',
437+
required: true,
438+
content: new OA\JsonContent(ref: '#/components/schemas/UpdateUserRequest')
439+
),
420440
responses: [
421441
new OA\Response(
422442
response: HttpResponse::HTTP_CREATED,
@@ -448,6 +468,7 @@ public function update($id){
448468
#[OA\Put(
449469
path: '/api/v1/users/me/pic',
450470
summary: 'Update current user profile picture',
471+
operationId: 'updateCurrentUserProfilePicture',
451472
tags: ['Users'],
452473
security: [
453474
['user_oauth2' => [
@@ -511,6 +532,7 @@ public function updateMyPic(LaravelRequest $request){
511532
#[OA\Get(
512533
path: '/api/v1/users/info',
513534
summary: 'Get current user info (OpenID Connect UserInfo)',
535+
operationId: 'getUserInfo',
514536
tags: ['Users'],
515537
security: [
516538
['user_oauth2' => [
@@ -533,6 +555,7 @@ public function updateMyPic(LaravelRequest $request){
533555
#[OA\Post(
534556
path: '/api/v1/users/info',
535557
summary: 'Get current user info (OpenID Connect UserInfo)',
558+
operationId: 'getUserInfoPost',
536559
tags: ['Users'],
537560
security: [
538561
['user_oauth2' => [
@@ -591,6 +614,7 @@ public function userInfo()
591614
#[OA\Get(
592615
path: '/api/v1/users/{id}',
593616
summary: 'Get a user by ID',
617+
operationId: 'getUserById',
594618
tags: ['Users'],
595619
security: [
596620
['user_oauth2' => [
@@ -672,6 +696,7 @@ public function getV2($id)
672696
#[OA\Put(
673697
path: '/api/v1/users/{id}/groups',
674698
summary: 'Update user group assignments',
699+
operationId: 'updateUserGroups',
675700
tags: ['Users'],
676701
security: [
677702
['user_oauth2' => [
@@ -687,6 +712,11 @@ public function getV2($id)
687712
schema: new OA\Schema(type: 'integer')
688713
),
689714
],
715+
requestBody: new OA\RequestBody(
716+
description: 'Group IDs to assign',
717+
required: true,
718+
content: new OA\JsonContent(ref: '#/components/schemas/UpdateUserGroupsRequest')
719+
),
690720
responses: [
691721
new OA\Response(
692722
response: HttpResponse::HTTP_CREATED,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php namespace App\Swagger\schemas;
2+
3+
/**
4+
* Copyright 2025 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
16+
use OpenApi\Attributes as OA;
17+
18+
#[OA\Schema(
19+
schema: 'CreateUserRequest',
20+
title: 'Create User Request',
21+
description: 'Request body for creating a new user. Only email is required, all other fields are optional.',
22+
type: 'object',
23+
required: ['email'],
24+
allOf: [
25+
new OA\Schema(ref: '#/components/schemas/UserFields')
26+
]
27+
)]
28+
class CreateUserRequestSchema
29+
{
30+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php namespace App\Swagger\schemas;
2+
3+
/**
4+
* Copyright 2025 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
16+
use OpenApi\Attributes as OA;
17+
18+
#[OA\Schema(
19+
schema: 'UpdateUserGroupsRequest',
20+
title: 'Update User Groups Request',
21+
description: 'Request body for updating user group assignments',
22+
type: 'object',
23+
required: ['groups'],
24+
properties: [
25+
new OA\Property(
26+
property: 'groups',
27+
type: 'array',
28+
items: new OA\Items(type: 'integer'),
29+
description: 'Array of group IDs to assign to the user',
30+
example: [1, 2, 3]
31+
)
32+
]
33+
)]
34+
class UpdateUserGroupsRequestSchema
35+
{
36+
}

0 commit comments

Comments
 (0)