Skip to content

Commit 5ce71f5

Browse files
feat: Add OpenAPI documentation for OAuth2RocketChatSSOApiController v1 api routes
1 parent 0d6b7e3 commit 5ce71f5

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use models\exceptions\ValidationException;
1818
use OAuth2\IResourceServerContext;
1919
use Utils\Services\ILogService;
20+
use App\libs\OAuth2\IUserScopes;
21+
use OpenApi\Attributes as OA;
22+
use Symfony\Component\HttpFoundation\Response as HttpResponse;
2023
/**
2124
* Class OAuth2RocketChatSSOApiController
2225
* @package App\Http\Controllers\Api\OAuth2
@@ -39,6 +42,46 @@ public function __construct
3942
$this->service = $service;
4043
}
4144

45+
46+
#[OA\Get(
47+
path: '/api/v1/sso/rocket-chat/{forum_slug}/profile',
48+
operationId: 'getRocketChatUserProfile',
49+
summary: 'Get Rocket Chat user profile for a forum.',
50+
description: 'Returns Rocket Chat user profile data for the authenticated user in the context of the specified forum. The content of the response is defined by "data" portion of the Rocket Chat login endpoint response structure',
51+
security: [['OAuth2RocketChatSSOSecurity' => [IUserScopes::SSO]]],
52+
tags: ['Rocket Chat SSO'],
53+
parameters: [
54+
new OA\Parameter(
55+
name: 'forum_slug',
56+
description: 'Forum slug',
57+
in: 'path',
58+
required: true,
59+
schema: new OA\Schema(type: 'string')
60+
),
61+
],
62+
responses: [
63+
new OA\Response(
64+
response: HttpResponse::HTTP_OK,
65+
description: 'OK, returns Rocket Chat user profile data on login success',
66+
content: new OA\JsonContent(
67+
// The content of the response is defined by "data" portion of
68+
// the Rocket Chat login endpoint response structure
69+
)
70+
),
71+
new OA\Response(
72+
response: HttpResponse::HTTP_NOT_FOUND,
73+
description: 'Not Found'
74+
),
75+
new OA\Response(
76+
response: HttpResponse::HTTP_PRECONDITION_FAILED,
77+
description: 'Validation Error'
78+
),
79+
new OA\Response(
80+
response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR,
81+
description: 'Server Error'
82+
),
83+
]
84+
)]
4285
/**
4386
* @param string $forum_slug
4487
* @return \Illuminate\Http\JsonResponse|mixed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
#[OA\Schema(
8+
schema: 'RocketChatUserProfile',
9+
type: 'object',
10+
properties: [
11+
],
12+
description: 'Rocket Chat SSO user profile'
13+
)]
14+
class RocketChatUserProfileSchema
15+
{
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use App\libs\OAuth2\IUserScopes;
6+
use OpenApi\Attributes as OA;
7+
8+
#[OA\SecurityScheme(
9+
securityScheme: 'OAuth2RocketChatSSOSecurity',
10+
type: 'oauth2',
11+
description: 'OAuth2 authentication for Rocket Chat SSO endpoints',
12+
flows: [
13+
new OA\Flow(
14+
flow: 'authorizationCode',
15+
authorizationUrl: L5_SWAGGER_CONST_AUTH_URL,
16+
tokenUrl: L5_SWAGGER_CONST_TOKEN_URL,
17+
scopes: [IUserScopes::SSO => 'Single Sign-On access']
18+
),
19+
]
20+
)]
21+
class OAuth2RocketChatSSOApiControllerSecuritySchema
22+
{
23+
}

0 commit comments

Comments
 (0)