Skip to content

Commit 01921e5

Browse files
feat: Add OpenAPI documentation for OAuth2DisqusSSOApiController v1
1 parent 0d6b7e3 commit 01921e5

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

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

Lines changed: 46 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 OAuth2DisqusSSOApiController
2225
* @package App\Http\Controllers\Api\OAuth2
@@ -40,6 +43,49 @@ public function __construct
4043
$this->service = $service;
4144
}
4245

46+
#[OA\Get(
47+
path: '/api/v1/sso/disqus/{forum_slug}/profile',
48+
operationId: 'getDisqusUserProfile',
49+
summary: 'Get Disqus user profile for a forum',
50+
security: [['OAuth2DisqusSSOSecurity' => [IUserScopes::SSO]]],
51+
tags: ['Disqus SSO'],
52+
parameters: [
53+
new OA\Parameter(
54+
name: 'forum_slug',
55+
description: 'Forum slug',
56+
in: 'path',
57+
required: true,
58+
schema: new OA\Schema(type: 'string')
59+
),
60+
],
61+
responses: [
62+
new OA\Response(
63+
response: HttpResponse::HTTP_OK,
64+
description: 'OK',
65+
content: new OA\JsonContent(ref: '#/components/schemas/DisqusUserProfileSerialized')
66+
),
67+
new OA\Response(
68+
response: HttpResponse::HTTP_NOT_FOUND,
69+
description: 'Not Found'
70+
),
71+
new OA\Response(
72+
response: HttpResponse::HTTP_PRECONDITION_FAILED,
73+
description: 'Validation Error'
74+
),
75+
new OA\Response(
76+
response: HttpResponse::HTTP_INTERNAL_SERVER_ERROR,
77+
description: 'Server Error'
78+
),
79+
new OA\Response(
80+
response: HttpResponse::HTTP_UNAUTHORIZED,
81+
description: 'Unauthorized'
82+
),
83+
new OA\Response(
84+
response: HttpResponse::HTTP_FORBIDDEN,
85+
description: 'Forbidden'
86+
),
87+
]
88+
)]
4389
/**
4490
* @param string $forum_slug
4591
* @return \Illuminate\Http\JsonResponse|mixed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
#[OA\Schema(
8+
schema: 'DisqusUserProfileSerialized',
9+
type: 'object',
10+
properties: [
11+
new OA\Property(property: 'auth', type: 'string', description: 'Base64 encoded profile JSON + space + hash + space + timestamp.'),
12+
new OA\Property(property: 'public_key', type: 'string', description: 'Public key'),
13+
],
14+
description: 'Disqus SSO user profile'
15+
)]
16+
class DisqusUserProfileSerializedSchema
17+
{
18+
}
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: 'OAuth2DisqusSSOSecurity',
10+
type: 'oauth2',
11+
description: 'OAuth2 authentication for Disqus 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 OAuth2DisqusSSOSecuritySchema
22+
{
23+
}

0 commit comments

Comments
 (0)