Skip to content

Commit 162b49d

Browse files
feat: Extend Swagger Coverage for controller OAuth2TrackQuestionsTemplateApiController
1 parent 589e1a4 commit 162b49d

File tree

2 files changed

+330
-2
lines changed

2 files changed

+330
-2
lines changed

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

Lines changed: 235 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
use App\Models\Foundation\Summit\Events\Presentations\TrackQuestions\TrackQuestionTemplateConstants;
1616
use App\Models\Foundation\Summit\Repositories\ITrackQuestionTemplateRepository;
1717
use App\Services\Model\ITrackQuestionTemplateService;
18+
use Illuminate\Http\Response;
1819
use Illuminate\Support\Facades\Log;
1920
use Illuminate\Support\Facades\Request;
2021
use libs\utils\PaginationValidationRules;
22+
use OpenApi\Attributes as OA;
2123
use models\exceptions\EntityNotFoundException;
2224
use models\exceptions\ValidationException;
2325
use Exception;
@@ -65,6 +67,30 @@ public function __construct
6567
/**
6668
* @return mixed
6769
*/
70+
#[OA\Get(
71+
path: '/api/v1/track-question-templates',
72+
summary: 'Get all track question templates',
73+
description: 'Returns a paginated list of track question templates',
74+
tags: ['track-question-templates'],
75+
security: [['Bearer' => []]],
76+
parameters: [
77+
new OA\Parameter(name: 'page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 1)),
78+
new OA\Parameter(name: 'per_page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 5)),
79+
new OA\Parameter(name: 'filter', in: 'query', required: false, description: 'Filter by name, label or class_name', schema: new OA\Schema(type: 'string')),
80+
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by id, name, or label', schema: new OA\Schema(type: 'string')),
81+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations (tracks)', schema: new OA\Schema(type: 'string')),
82+
],
83+
responses: [
84+
new OA\Response(
85+
response: Response::HTTP_OK,
86+
description: 'Success',
87+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedTrackQuestionTemplatesResponse')
88+
),
89+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
90+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
91+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
92+
]
93+
)]
6894
public function getTrackQuestionTemplates(){
6995
$values = Request::all();
7096
$rules = PaginationValidationRules::get();
@@ -160,6 +186,32 @@ public function getTrackQuestionTemplates(){
160186
/**
161187
* @return mixed
162188
*/
189+
#[OA\Post(
190+
path: '/api/v1/track-question-templates',
191+
summary: 'Create a new track question template',
192+
description: 'Creates a new track question template',
193+
tags: ['track-question-templates'],
194+
security: [['Bearer' => []]],
195+
requestBody: new OA\RequestBody(
196+
required: true,
197+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplateRequest')
198+
),
199+
parameters: [
200+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
201+
],
202+
responses: [
203+
new OA\Response(
204+
response: Response::HTTP_CREATED,
205+
description: 'Track Question Template Created',
206+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
207+
),
208+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
209+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
210+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
211+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
212+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
213+
]
214+
)]
163215
public function addTrackQuestionTemplate(){
164216
try {
165217

@@ -205,6 +257,28 @@ public function addTrackQuestionTemplate(){
205257
* @param $track_question_template_id
206258
* @return mixed
207259
*/
260+
#[OA\Get(
261+
path: '/api/v1/track-question-templates/{track_question_template_id}',
262+
summary: 'Get a track question template by id',
263+
description: 'Returns a single track question template',
264+
tags: ['track-question-templates'],
265+
security: [['Bearer' => []]],
266+
parameters: [
267+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
268+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
269+
],
270+
responses: [
271+
new OA\Response(
272+
response: Response::HTTP_OK,
273+
description: 'Success',
274+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
275+
),
276+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
277+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
278+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
279+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
280+
]
281+
)]
208282
public function getTrackQuestionTemplate($track_question_template_id){
209283
try {
210284

@@ -234,6 +308,33 @@ public function getTrackQuestionTemplate($track_question_template_id){
234308
* @param $track_question_template_id
235309
* @return mixed
236310
*/
311+
#[OA\Put(
312+
path: '/api/v1/track-question-templates/{track_question_template_id}',
313+
summary: 'Update a track question template',
314+
description: 'Updates an existing track question template',
315+
tags: ['track-question-templates'],
316+
security: [['Bearer' => []]],
317+
requestBody: new OA\RequestBody(
318+
required: true,
319+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplateRequest')
320+
),
321+
parameters: [
322+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
323+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
324+
],
325+
responses: [
326+
new OA\Response(
327+
response: Response::HTTP_OK,
328+
description: 'Track Question Template Updated',
329+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionTemplate')
330+
),
331+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
332+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
333+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
334+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
335+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
336+
]
337+
)]
237338
public function updateTrackQuestionTemplate($track_question_template_id){
238339
try {
239340

@@ -278,6 +379,23 @@ public function updateTrackQuestionTemplate($track_question_template_id){
278379
* @param $track_question_template_id
279380
* @return mixed
280381
*/
382+
#[OA\Delete(
383+
path: '/api/v1/track-question-templates/{track_question_template_id}',
384+
summary: 'Delete a track question template',
385+
description: 'Deletes a track question template',
386+
tags: ['track-question-templates'],
387+
security: [['Bearer' => []]],
388+
parameters: [
389+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
390+
],
391+
responses: [
392+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Question Template Deleted'),
393+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
394+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
395+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
396+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
397+
]
398+
)]
281399
public function deleteTrackQuestionTemplate($track_question_template_id){
282400
try {
283401

@@ -302,6 +420,27 @@ public function deleteTrackQuestionTemplate($track_question_template_id){
302420
/**
303421
* @return mixed
304422
*/
423+
#[OA\Get(
424+
path: '/api/v1/track-question-templates/metadata',
425+
summary: 'Get track question templates metadata',
426+
description: 'Returns metadata about available track question template types',
427+
tags: ['track-question-templates'],
428+
security: [['Bearer' => []]],
429+
responses: [
430+
new OA\Response(
431+
response: Response::HTTP_OK,
432+
description: 'Success',
433+
content: new OA\JsonContent(
434+
type: 'object',
435+
properties: [
436+
new OA\Property(property: 'class_names', type: 'array', items: new OA\Items(type: 'string')),
437+
]
438+
)
439+
),
440+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
441+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
442+
]
443+
)]
305444
public function getTrackQuestionTemplateMetadata(){
306445
return $this->ok
307446
(
@@ -318,6 +457,28 @@ public function getTrackQuestionTemplateMetadata(){
318457
* @param $track_question_template_value_id
319458
* @return mixed
320459
*/
460+
#[OA\Get(
461+
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
462+
summary: 'Get a track question template value',
463+
description: 'Returns a single track question template value',
464+
tags: ['track-question-templates'],
465+
security: [['Bearer' => []]],
466+
parameters: [
467+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
468+
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
469+
],
470+
responses: [
471+
new OA\Response(
472+
response: Response::HTTP_OK,
473+
description: 'Success',
474+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
475+
),
476+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
477+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
478+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
479+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
480+
]
481+
)]
321482
public function getTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
322483
try {
323484

@@ -350,6 +511,33 @@ public function getTrackQuestionTemplateValue($track_question_template_id, $trac
350511
* @param $track_question_template_id
351512
* @return mixed
352513
*/
514+
#[OA\Post(
515+
path: '/api/v1/track-question-templates/{track_question_template_id}/values',
516+
summary: 'Add a value to a track question template',
517+
description: 'Adds a new value to a multi-value track question template',
518+
tags: ['track-question-templates'],
519+
security: [['Bearer' => []]],
520+
requestBody: new OA\RequestBody(
521+
required: true,
522+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplateRequest')
523+
),
524+
parameters: [
525+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
526+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
527+
],
528+
responses: [
529+
new OA\Response(
530+
response: Response::HTTP_CREATED,
531+
description: 'Track Question Template Value Created',
532+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
533+
),
534+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
535+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
536+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
537+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
538+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
539+
]
540+
)]
353541
public function addTrackQuestionTemplateValue($track_question_template_id){
354542
try {
355543

@@ -399,6 +587,34 @@ public function addTrackQuestionTemplateValue($track_question_template_id){
399587
* @param $track_question_template_value_id
400588
* @return mixed
401589
*/
590+
#[OA\Put(
591+
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
592+
summary: 'Update a track question template value',
593+
description: 'Updates an existing track question template value',
594+
tags: ['track-question-templates'],
595+
security: [['Bearer' => []]],
596+
requestBody: new OA\RequestBody(
597+
required: true,
598+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplateRequest')
599+
),
600+
parameters: [
601+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
602+
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
603+
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand relations', schema: new OA\Schema(type: 'string')),
604+
],
605+
responses: [
606+
new OA\Response(
607+
response: Response::HTTP_OK,
608+
description: 'Track Question Template Value Updated',
609+
content: new OA\JsonContent(ref: '#/components/schemas/TrackQuestionValueTemplate')
610+
),
611+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
612+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
613+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
614+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
615+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
616+
]
617+
)]
402618
public function updateTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
403619
try {
404620

@@ -449,6 +665,24 @@ public function updateTrackQuestionTemplateValue($track_question_template_id, $t
449665
* @param $track_question_template_value_id
450666
* @return mixed
451667
*/
668+
#[OA\Delete(
669+
path: '/api/v1/track-question-templates/{track_question_template_id}/values/{track_question_template_value_id}',
670+
summary: 'Delete a track question template value',
671+
description: 'Deletes a track question template value',
672+
tags: ['track-question-templates'],
673+
security: [['Bearer' => []]],
674+
parameters: [
675+
new OA\Parameter(name: 'track_question_template_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template id'),
676+
new OA\Parameter(name: 'track_question_template_value_id', in: 'path', required: true, schema: new OA\Schema(type: 'integer'), description: 'The track question template value id'),
677+
],
678+
responses: [
679+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: 'Track Question Template Value Deleted'),
680+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
681+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
682+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
683+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
684+
]
685+
)]
452686
public function deleteTrackQuestionTemplateValue($track_question_template_id, $track_question_template_value_id){
453687
try {
454688
$this->track_question_template_service->deleteTrackQuestionValueTemplate
@@ -472,4 +706,4 @@ public function deleteTrackQuestionTemplateValue($track_question_template_id, $t
472706
return $this->error500($ex);
473707
}
474708
}
475-
}
709+
}

0 commit comments

Comments
 (0)