Skip to content

Commit 487b12f

Browse files
feat: Add OpenAPI documentation annotations for OAuth2StreamChatSSOApiController v1 routes
1 parent 0d6b7e3 commit 487b12f

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
**/
14+
use App\libs\OAuth2\IUserScopes;
1415
use App\Services\Auth\IStreamChatSSOService;
1516
use Illuminate\Support\Facades\Log;
1617
use models\exceptions\EntityNotFoundException;
1718
use models\exceptions\ValidationException;
1819
use OAuth2\IResourceServerContext;
20+
use OpenApi\Attributes as OA;
21+
use Symfony\Component\HttpFoundation\Response as HttpResponse;
1922
use Utils\Services\ILogService;
2023
/**
2124
* Class OAuth2StreamChatSSOApiController
@@ -44,6 +47,41 @@ public function __construct
4447
* @param string $forum_slug
4548
* @return \Illuminate\Http\JsonResponse|mixed
4649
*/
50+
#[OA\Get(
51+
path: '/api/v1/sso/stream-chat/{forum_slug}/profile',
52+
operationId: 'getStreamChatUserProfile',
53+
summary: 'Get Stream Chat user profile for a forum',
54+
security: [['OAuth2StreamChatSSOSecurity' => [IUserScopes::SSO]]],
55+
tags: ['Stream Chat SSO'],
56+
parameters: [
57+
new OA\Parameter(
58+
name: 'forum_slug',
59+
description: 'Forum slug',
60+
in: 'path',
61+
required: true,
62+
schema: new OA\Schema(type: 'string')
63+
),
64+
],
65+
responses: [
66+
new OA\Response(
67+
response: HttpResponse::HTTP_OK,
68+
description: 'OK',
69+
content: new OA\JsonContent(ref: '#/components/schemas/StreamChatUserProfile')
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+
)]
4785
public function getUserProfile(string $forum_slug){
4886
try{
4987
$profile = $this->service->getUserProfile($forum_slug);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
#[OA\Schema(
8+
schema: 'StreamChatUserProfile',
9+
type: 'object',
10+
properties: [
11+
new OA\Property(property: 'id', type: 'string', description: 'User ID'),
12+
new OA\Property(property: 'name', type: 'string', description: 'Display name'),
13+
new OA\Property(property: 'image', type: 'string', description: 'Avatar URL'),
14+
new OA\Property(property: 'token', type: 'string', description: 'Stream Chat JWT token'),
15+
new OA\Property(property: 'api_key', type: 'string', description: 'Stream Chat API key'),
16+
new OA\Property(property: 'local_role', type: 'string', description: 'User role in the forum'),
17+
],
18+
description: 'Stream Chat SSO user profile'
19+
)]
20+
class StreamChatUserProfileSchema
21+
{
22+
}
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: 'OAuth2StreamChatSSOSecurity',
10+
type: 'oauth2',
11+
description: 'OAuth2 authentication for Stream 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 OAuth2StreamChatSSOApiControllerSecuritySchema
22+
{
23+
}

0 commit comments

Comments
 (0)