Skip to content

Commit 90b84bc

Browse files
Feature | Extend Swagger Coverage for controller OAuth2SpeakerActiveInvolvementApiController (#373)
* feat: Extend Swagger Coverage for controller Apis/Protected/Summit/OAuth2SpeakerActiveInvolvementApiController.php * fix: incorrect types and descriptions for errors * fix: Move schema to the new file * fix: Change "namespace" word positioning * chore: Add security param * fix: security scopes * fix: Security schema * chore: Move the security schema for the controller to its own file * chore: include PR requested changes --------- Co-authored-by: Matias Perrone <github@matiasperrone.com>
1 parent 113642d commit 90b84bc

File tree

3 files changed

+98
-5
lines changed

3 files changed

+98
-5
lines changed

app/Http/Controllers/Apis/Protected/Summit/OAuth2SpeakerActiveInvolvementApiController.php

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php namespace App\Http\Controllers;
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
25
/**
36
* Copyright 2018 OpenStack Foundation
47
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,12 +15,16 @@
1215
* limitations under the License.
1316
**/
1417
use App\Models\Foundation\Summit\Repositories\ISpeakerActiveInvolvementRepository;
18+
use App\Security\SummitScopes;
1519
use models\oauth2\IResourceServerContext;
1620
use Illuminate\Support\Facades\Log;
1721
use models\exceptions\EntityNotFoundException;
1822
use models\exceptions\ValidationException;
23+
use Symfony\Component\HttpFoundation\Response;
1924
use utils\PagingResponse;
2025
use Illuminate\Support\Facades\Request;
26+
use OpenApi\Attributes as OA;
27+
2128
/**
2229
* Class OAuth2SpeakerActiveInvolvementApiController
2330
* @package App\Http\Controllers
@@ -34,12 +41,45 @@ public function __construct
3441
(
3542
ISpeakerActiveInvolvementRepository $repository,
3643
IResourceServerContext $resource_server_context
37-
)
38-
{
44+
) {
3945
parent::__construct($resource_server_context);
4046
$this->repository = $repository;
4147
}
4248

49+
#[OA\Get(
50+
path: '/api/v1/speakers/active-involvements',
51+
summary: 'Get all default speaker active involvements',
52+
description: 'Retrieves a list of default active involvements for speakers. These are predefined involvement types that speakers can select to describe their current activities (e.g., "Active Contributor", "User", "Evaluator").',
53+
operationId: 'getAllSpeakerActiveInvolvements',
54+
security: [
55+
[
56+
'speaker_active_involvement_oauth2' => [
57+
SummitScopes::ReadSummitData,
58+
SummitScopes::ReadAllSummitData,
59+
]
60+
]
61+
],
62+
tags: ['Speakers'],
63+
parameters: [
64+
new OA\Parameter(
65+
name: 'expand',
66+
in: 'query',
67+
required: false,
68+
description: 'No expandable relationships available for this resource',
69+
schema: new OA\Schema(type: 'string', example: '')
70+
),
71+
],
72+
responses: [
73+
new OA\Response(
74+
response: 200,
75+
description: 'Active involvements retrieved successfully',
76+
content: new OA\JsonContent(ref: '#/components/schemas/SpeakerActiveInvolvementsResponse')
77+
),
78+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
79+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
80+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
81+
]
82+
)]
4383
/**
4484
* @return mixed
4585
*/
@@ -71,4 +111,4 @@ public function getAll(){
71111
return $this->error500($ex);
72112
}
73113
}
74-
}
114+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use App\Security\SummitScopes;
6+
use OpenApi\Attributes as OA;
7+
8+
9+
#[OA\SecurityScheme(
10+
type: 'oauth2',
11+
securityScheme: 'speaker_active_involvement_oauth2',
12+
flows: [
13+
new OA\Flow(
14+
authorizationUrl: L5_SWAGGER_CONST_AUTH_URL,
15+
tokenUrl: L5_SWAGGER_CONST_TOKEN_URL,
16+
flow: 'authorizationCode',
17+
scopes: [
18+
SummitScopes::ReadSummitData => 'Read Summit Data',
19+
SummitScopes::ReadAllSummitData => 'Read All Summit Data',
20+
],
21+
),
22+
],
23+
)
24+
]
25+
class SpeakerActiveInvolvementAuthSchema{}

app/Swagger/SummitSpeakersSchemas.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,32 @@
44

55
use OpenApi\Attributes as OA;
66

7-
//
7+
#[OA\Schema(
8+
schema: 'SpeakerActiveInvolvement',
9+
type: 'object',
10+
properties: [
11+
new OA\Property(property: 'id', type: 'integer', example: 1),
12+
new OA\Property(property: 'created', type: 'integer', format: 'int64', example: 1633024800),
13+
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64', example: 1633024800),
14+
new OA\Property(property: 'involvement', type: 'string', example: 'Active Contributor'),
15+
new OA\Property(property: 'is_default', type: 'boolean', example: true),
16+
]
17+
)]
18+
class SpeakerActiveInvolvementSchema {}
19+
20+
#[OA\Schema(
21+
schema: 'SpeakerActiveInvolvementsResponse',
22+
type: 'object',
23+
properties: [
24+
new OA\Property(property: 'total', type: 'integer', example: 5),
25+
new OA\Property(property: 'per_page', type: 'integer', example: 5),
26+
new OA\Property(property: 'current_page', type: 'integer', example: 1),
27+
new OA\Property(property: 'last_page', type: 'integer', example: 1),
28+
new OA\Property(
29+
property: 'data',
30+
type: 'array',
31+
items: new OA\Items(ref: '#/components/schemas/SpeakerActiveInvolvement')
32+
),
33+
]
34+
)]
35+
class SpeakerActiveInvolvementsResponseSchema {}

0 commit comments

Comments
 (0)