Skip to content

Commit 68f63a5

Browse files
feat: Extend Swagger Coverage for controller OAuth2SummitPresentationActionTypeApiController
1 parent 57298dc commit 68f63a5

3 files changed

Lines changed: 240 additions & 5 deletions

File tree

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

Lines changed: 190 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
use App\Http\Utils\EpochCellFormatter;
1616
use App\Models\Foundation\Summit\Repositories\IPresentationActionTypeRepository;
1717
use App\Services\Model\ISummitPresentationActionTypeService;
18+
use Illuminate\Http\Response;
1819
use Illuminate\Support\Facades\Input;
1920
use models\exceptions\ValidationException;
2021
use models\oauth2\IResourceServerContext;
2122
use models\summit\ISummitRepository;
2223
use models\summit\Summit;
2324
use models\utils\IEntity;
2425
use ModelSerializers\SerializerRegistry;
26+
use OpenApi\Attributes as OA;
2527
use utils\Filter;
2628
use utils\FilterElement;
2729

@@ -84,7 +86,7 @@ protected function addChild(Summit $summit, array $payload): IEntity
8486
/**
8587
* @inheritDoc
8688
*/
87-
function getAddValidationRules(array $payload): array
89+
public function getAddValidationRules(array $payload): array
8890
{
8991
return SummitPresentationActionTypeValidationRulesFactory::build($payload, false);
9092
}
@@ -116,7 +118,7 @@ protected function getChildFromSummit(Summit $summit, $child_id): ?IEntity
116118
/**
117119
* @inheritDoc
118120
*/
119-
function getUpdateValidationRules(array $payload): array
121+
public function getUpdateValidationRules(array $payload): array
120122
{
121123
return SummitPresentationActionTypeValidationRulesFactory::build($payload, true);
122124
}
@@ -133,6 +135,160 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
133135
* @param $summit_id
134136
* @return \Illuminate\Http\JsonResponse|mixed
135137
*/
138+
#[OA\Post(
139+
path: '/api/v1/summits/{id}/presentation-action-types',
140+
summary: 'Create a new presentation action type',
141+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
142+
tags: ['Summits', 'Presentation Action Types'],
143+
parameters: [
144+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
145+
],
146+
requestBody: new OA\RequestBody(
147+
required: true,
148+
content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionTypeCreateRequest')
149+
),
150+
responses: [
151+
new OA\Response(
152+
response: Response::HTTP_CREATED,
153+
description: 'Presentation action type created',
154+
content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType')
155+
),
156+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
157+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
158+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
159+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
160+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
161+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
162+
]
163+
)]
164+
public function add($summit_id){
165+
return parent::add($summit_id);
166+
}
167+
168+
/**
169+
* @param $summit_id
170+
* @param $action_id
171+
* @return \Illuminate\Http\JsonResponse|mixed
172+
*/
173+
#[OA\Get(
174+
path: '/api/v1/summits/{id}/presentation-action-types/{action_id}',
175+
summary: 'Get a presentation action type by ID',
176+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
177+
tags: ['Summits', 'Presentation Action Types'],
178+
parameters: [
179+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
180+
new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')),
181+
],
182+
responses: [
183+
new OA\Response(
184+
response: Response::HTTP_OK,
185+
description: 'Successful response',
186+
content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType')
187+
),
188+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
189+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
190+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
191+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
192+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
193+
]
194+
)]
195+
public function get($summit_id, $action_id){
196+
return parent::get($summit_id, $action_id);
197+
}
198+
199+
/**
200+
* @param $summit_id
201+
* @param $action_id
202+
* @return \Illuminate\Http\JsonResponse|mixed
203+
*/
204+
#[OA\Put(
205+
path: '/api/v1/summits/{id}/presentation-action-types/{action_id}',
206+
summary: 'Update a presentation action type',
207+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
208+
tags: ['Summits', 'Presentation Action Types'],
209+
parameters: [
210+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
211+
new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')),
212+
],
213+
requestBody: new OA\RequestBody(
214+
required: true,
215+
content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionTypeUpdateRequest')
216+
),
217+
responses: [
218+
new OA\Response(
219+
response: Response::HTTP_OK,
220+
description: 'Presentation action type updated',
221+
content: new OA\JsonContent(ref: '#/components/schemas/PresentationActionType')
222+
),
223+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
224+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
225+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
226+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
227+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
228+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
229+
]
230+
)]
231+
public function update($summit_id, $action_id){
232+
return parent::update($summit_id, $action_id);
233+
}
234+
235+
/**
236+
* @param $summit_id
237+
* @param $action_id
238+
* @return \Illuminate\Http\JsonResponse|mixed
239+
*/
240+
#[OA\Delete(
241+
path: '/api/v1/summits/{id}/presentation-action-types/{action_id}',
242+
summary: 'Delete a presentation action type',
243+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
244+
tags: ['Summits', 'Presentation Action Types'],
245+
parameters: [
246+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
247+
new OA\Parameter(name: 'action_id', in: 'path', required: true, description: 'Presentation Action Type ID', schema: new OA\Schema(type: 'integer')),
248+
],
249+
responses: [
250+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: "No Content"),
251+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
252+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
253+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
254+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
255+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
256+
]
257+
)]
258+
public function delete($summit_id, $action_id){
259+
return parent::delete($summit_id, $action_id);
260+
}
261+
262+
/**
263+
* @param $summit_id
264+
* @return \Illuminate\Http\JsonResponse|mixed
265+
*/
266+
#[OA\Get(
267+
path: '/api/v1/summits/{id}/presentation-action-types',
268+
summary: 'Get all presentation action types for a summit',
269+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
270+
tags: ['Summits', 'Presentation Action Types'],
271+
parameters: [
272+
new OA\Parameter(ref: '#/components/parameters/page'),
273+
new OA\Parameter(ref: '#/components/parameters/per_page'),
274+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
275+
new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by label (label=@value, label==value)', schema: new OA\Schema(type: 'string')),
276+
new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-label, +/-order', schema: new OA\Schema(type: 'string')),
277+
new OA\Parameter(name: 'selection_plan_id', in: 'query', description: 'Filter by selection plan and include order field', schema: new OA\Schema(type: 'integer')),
278+
],
279+
responses: [
280+
new OA\Response(
281+
response: Response::HTTP_OK,
282+
description: 'Successful response',
283+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPresentationActionTypesResponse')
284+
),
285+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
286+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
287+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
288+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
289+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
290+
]
291+
)]
136292
public function getAllBySummit($summit_id)
137293
{
138294
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
@@ -178,6 +334,37 @@ function () {
178334
* @param $summit_id
179335
* @return \Illuminate\Http\JsonResponse|mixed
180336
*/
337+
#[OA\Get(
338+
path: '/api/v1/summits/{id}/presentation-action-types/csv',
339+
summary: 'Get all presentation action types for a summit in CSV format',
340+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
341+
tags: ['Summits', 'Presentation Action Types'],
342+
parameters: [
343+
new OA\Parameter(ref: '#/components/parameters/page'),
344+
new OA\Parameter(ref: '#/components/parameters/per_page'),
345+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
346+
new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by label (label=@value, label==value)', schema: new OA\Schema(type: 'string')),
347+
new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-label, +/-order', schema: new OA\Schema(type: 'string')),
348+
new OA\Parameter(name: 'selection_plan_id', in: 'query', description: 'Filter by selection plan and include order field', schema: new OA\Schema(type: 'integer')),
349+
new OA\Parameter(name: 'columns', in: 'query', description: 'Comma-separated list of columns (allowed: id, created, last_edited, label, order)', schema: new OA\Schema(type: 'string')),
350+
],
351+
responses: [
352+
new OA\Response(
353+
response: Response::HTTP_OK,
354+
description: 'CSV file',
355+
content: new OA\MediaType(
356+
mediaType: 'text/csv',
357+
schema: new OA\Schema(type: 'string', format: 'binary')
358+
)
359+
),
360+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
361+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
362+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
363+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
364+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
365+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
366+
]
367+
)]
181368
public function getAllBySummitCSV($summit_id)
182369
{
183370
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
@@ -248,4 +435,4 @@ function () use ($summit) {
248435
sprintf('summit_presentation_action_types-%s', $summit_id)
249436
);
250437
}
251-
}
438+
}

app/Swagger/SummitPresentationSchemas.php

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

55
use OpenApi\Attributes as OA;
66

7-
//
7+
#[OA\Schema(
8+
schema: 'PresentationActionType',
9+
type: 'object',
10+
properties: [
11+
new OA\Property(property: 'id', type: 'integer', example: 1),
12+
new OA\Property(property: 'created', type: 'integer', example: 1630500518),
13+
new OA\Property(property: 'last_edited', type: 'integer', example: 1630500518),
14+
new OA\Property(property: 'label', type: 'string', example: 'Review'),
15+
new OA\Property(property: 'summit_id', type: 'integer', example: 42),
16+
new OA\Property(property: 'order', type: 'integer', example: 1, description: 'Order within a selection plan. Only present when filtering by selection_plan_id'),
17+
]
18+
)]
19+
class PresentationActionTypeSchema {}
20+
21+
#[OA\Schema(
22+
schema: 'PaginatedPresentationActionTypesResponse',
23+
allOf: [
24+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
25+
new OA\Schema(
26+
type: 'object',
27+
properties: [
28+
new OA\Property(
29+
property: 'data',
30+
type: 'array',
31+
items: new OA\Items(ref: '#/components/schemas/PresentationActionType')
32+
)
33+
]
34+
)
35+
]
36+
)]
37+
class PaginatedPresentationActionTypesResponseSchema {}
38+
39+
#[OA\Schema(
40+
schema: 'PresentationActionTypeCreateRequest',
41+
type: 'object',
42+
required: ['label'],
43+
properties: [
44+
new OA\Property(property: 'label', type: 'string', example: 'Review', maxLength: 255),
45+
]
46+
)]
47+
class PresentationActionTypeCreateRequestSchema {}
48+
49+
#[OA\Schema(
50+
schema: 'PresentationActionTypeUpdateRequest',
51+
type: 'object',
52+
properties: [
53+
new OA\Property(property: 'label', type: 'string', example: 'Review', maxLength: 255),
54+
]
55+
)]
56+
class PresentationActionTypeUpdateRequestSchema {}

app/Swagger/schemas.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
require __DIR__ . DIRECTORY_SEPARATOR . "SoftwareSchemas.php";
2323
require __DIR__ . DIRECTORY_SEPARATOR . "SummitSchemas.php";
2424
require __DIR__ . DIRECTORY_SEPARATOR . "SummitMetricsSchemas.php";
25-
require __DIR__ . DIRECTORY_SEPARATOR . "SummitPresentationSchemas.php";
2625
require __DIR__ . DIRECTORY_SEPARATOR . "SummitPresentationTrackQuestionsSchemas.php";
2726
require __DIR__ . DIRECTORY_SEPARATOR . "SummitProposedScheduleSchemas.php";
2827
require __DIR__ . DIRECTORY_SEPARATOR . "SummitRSVPSchemas.php";

0 commit comments

Comments
 (0)