Skip to content

Commit 6b76a6f

Browse files
feat: Add OpenAPI documentation annotations for OAuth2StreamChatSSOApiController
Signed-off-by: matiasperrone-exo <matias.perrone@exomindset.co>
1 parent 7f63bee commit 6b76a6f

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use models\exceptions\EntityNotFoundException;
1717
use models\exceptions\ValidationException;
1818
use OAuth2\IResourceServerContext;
19+
use OpenApi\Attributes as OA;
20+
use Symfony\Component\HttpFoundation\Response as HttpResponse;
1921
use Utils\Services\ILogService;
2022
/**
2123
* Class OAuth2StreamChatSSOApiController
@@ -44,6 +46,40 @@ public function __construct
4446
* @param string $forum_slug
4547
* @return \Illuminate\Http\JsonResponse|mixed
4648
*/
49+
#[OA\Get(
50+
path: '/api/v1/sso/stream-chat/{forum_slug}/profile',
51+
summary: 'Get Stream Chat user profile for a forum',
52+
security: [['OAuth2StreamChatSSOSecurity' => []]],
53+
tags: ['Stream Chat SSO'],
54+
parameters: [
55+
new OA\Parameter(
56+
name: 'forum_slug',
57+
description: 'Forum slug',
58+
in: 'path',
59+
required: true,
60+
schema: new OA\Schema(type: 'string')
61+
),
62+
],
63+
responses: [
64+
new OA\Response(
65+
response: HttpResponse::HTTP_OK,
66+
description: 'OK',
67+
content: new OA\JsonContent(ref: '#/components/schemas/StreamChatUserProfile')
68+
),
69+
new OA\Response(
70+
response: HttpResponse::HTTP_NOT_FOUND,
71+
description: 'Not Found'
72+
),
73+
new OA\Response(
74+
response: HttpResponse::HTTP_PRECONDITION_FAILED,
75+
description: 'Validation Error'
76+
),
77+
new OA\Response(
78+
response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR,
79+
description: 'Server Error'
80+
),
81+
]
82+
)]
4783
public function getUserProfile(string $forum_slug){
4884
try{
4985
$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: 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\SecurityScheme(
8+
securityScheme: 'OAuth2StreamChatSSOSecurity',
9+
type: 'http',
10+
description: 'OAuth2 Bearer token for Stream Chat SSO endpoints',
11+
scheme: 'bearer',
12+
bearerFormat: 'JWT'
13+
)]
14+
class OAuth2StreamChatSSOApiControllerSecuritySchema
15+
{
16+
}

0 commit comments

Comments
 (0)