Skip to content

Commit

Permalink
Merge pull request #2594 from tarlepp/feat/open-api-annotations-to-at…
Browse files Browse the repository at this point in the history
…tributes

Feat - Use Open API attributes instead of annotations
  • Loading branch information
tarlepp committed Dec 31, 2023
2 parents d516430 + fd27fa1 commit de51535
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 68 deletions.
2 changes: 1 addition & 1 deletion config/packages/nelmio_api_doc.yaml
Expand Up @@ -16,7 +16,7 @@ nelmio_api_doc:
path_patterns:
- ^/api/doc
- ^/api/doc.json
- ^/(auth|healthz|version|profile|localization)
- ^/(healthz|version|v1/auth|v1/profile|v1/localization)
internal:
path_patterns: # an array of regexps
- ^/[a-z]
7 changes: 6 additions & 1 deletion src/Controller/v1/Localization/TimeZoneController.php
Expand Up @@ -76,7 +76,12 @@ public function __construct(
],
type: 'object'
),
example: ['en', 'fi']
example: [
'timezone' => 'Europe',
'identifier' => 'Europe/Helsinki',
'offset' => 'GMT+2:00',
'value' => 'Europe/Helsinki',
],
),
)]
public function __invoke(): JsonResponse
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/Profile/GroupsController.php
Expand Up @@ -44,14 +44,13 @@ public function __construct(
methods: [Request::METHOD_GET],
)]
#[IsGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/Profile/IndexController.php
Expand Up @@ -49,14 +49,13 @@ public function __construct(
methods: [Request::METHOD_GET],
)]
#[IsGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down
9 changes: 3 additions & 6 deletions src/Controller/v1/Profile/RolesController.php
Expand Up @@ -42,14 +42,11 @@ public function __construct(
methods: [Request::METHOD_GET],
)]
#[IsGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
example: 'Bearer {token}',
)]
#[OA\Response(
response: 200,
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/Role/InheritedRolesController.php
Expand Up @@ -48,14 +48,13 @@ public function __construct(
methods: [Request::METHOD_GET],
)]
#[IsGranted(RoleEnum::ADMIN->value)]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/User/AttachUserGroupController.php
Expand Up @@ -58,14 +58,13 @@ public function __construct(
)]
#[IsGranted(Role::ROOT->value)]
#[OA\Tag(name: 'User Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Parameter(name: 'user', description: 'User GUID', in: 'path', required: true)]
#[OA\Parameter(name: 'userGroup', description: 'User Group GUID', in: 'path', required: true)]
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/User/DetachUserGroupController.php
Expand Up @@ -57,14 +57,13 @@ public function __construct(
)]
#[IsGranted(Role::ROOT->value)]
#[OA\Tag(name: 'User Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Parameter(name: 'user', description: 'User GUID', in: 'path', required: true)]
#[OA\Parameter(name: 'userGroup', description: 'User Group GUID', in: 'path', required: true)]
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/User/UserGroupsController.php
Expand Up @@ -49,14 +49,13 @@ public function __construct(
)]
#[IsGranted(new Expression('is_granted("IS_USER_HIMSELF", object) or "ROLE_ROOT" in role_names'), 'user')]
#[OA\Tag(name: 'User Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/User/UserRolesController.php
Expand Up @@ -47,14 +47,13 @@ public function __construct(
)]
#[IsGranted(new Expression('is_granted("IS_USER_HIMSELF", object) or "ROLE_ROOT" in role_names'), 'user')]
#[OA\Tag(name: 'User Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/UserGroup/AttachUserController.php
Expand Up @@ -57,14 +57,13 @@ public function __construct(
)]
#[IsGranted(Role::ROOT->value)]
#[OA\Tag(name: 'UserGroup Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Parameter(name: 'userGroup', description: 'User Group GUID', in: 'path', required: true)]
#[OA\Parameter(name: 'user', description: 'User GUID', in: 'path', required: true)]
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/UserGroup/DetachUserController.php
Expand Up @@ -57,14 +57,13 @@ public function __construct(
)]
#[IsGranted(Role::ROOT->value)]
#[OA\Tag(name: 'UserGroup Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Parameter(name: 'userGroup', description: 'User Group GUID', in: 'path', required: true)]
#[OA\Parameter(name: 'user', description: 'User GUID', in: 'path', required: true)]
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/v1/UserGroup/UsersController.php
Expand Up @@ -54,14 +54,13 @@ public function __construct(
)]
#[IsGranted(Role::ROOT->value)]
#[OA\Tag(name: 'UserGroup Management')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
#[OA\Parameter(
name: 'Authorization',
description: 'Authorization header',
name: 'bearerAuth',
in: 'header',
bearerFormat: 'JWT',
scheme: 'bearer',
required: true,
example: 'Bearer {token}',
allowReserved: true,
)]
#[OA\Response(
response: 200,
Expand Down

0 comments on commit de51535

Please sign in to comment.