Skip to content

Commit cdd4135

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

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

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

Lines changed: 38 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,41 @@ 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+
]
80+
)]
4381
/**
4482
* @param string $forum_slug
4583
* @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: 'string of base64 profile JSON + space + hash + space + timestamp. The base64 encoded profile is a JSON stringfied object containing the user profile information: id, username, email, avatar in that order. The hash is the base64 encoded info signed with public/private keys'),
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)