Skip to content

Commit 7d24b01

Browse files
feat: Extend Swagger Coverage for controller OAuth2SummitTaxTypeApiController
1 parent abbde7c commit 7d24b01

File tree

2 files changed

+255
-2
lines changed

2 files changed

+255
-2
lines changed

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

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
use models\utils\IBaseRepository;
2222
use models\utils\IEntity;
2323
use ModelSerializers\SerializerRegistry;
24+
use Illuminate\Http\Response;
2425
use Illuminate\Support\Facades\Log;
26+
use OpenApi\Attributes as OA;
2527
use Exception;
2628
/**
2729
* Class OAuth2SummitTaxTypeApiController
@@ -49,6 +51,145 @@ final class OAuth2SummitTaxTypeApiController extends OAuth2ProtectedController
4951

5052
use DeleteSummitChildElement;
5153

54+
#[OA\Get(
55+
path: '/api/v1/summits/{id}/tax-types',
56+
summary: 'Get all tax types for a summit',
57+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
58+
tags: ['Summits', 'Tax Types'],
59+
parameters: [
60+
new OA\Parameter(ref: '#/components/parameters/page'),
61+
new OA\Parameter(ref: '#/components/parameters/per_page'),
62+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
63+
new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by name (name=@value, name==value)', schema: new OA\Schema(type: 'string')),
64+
new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-name', schema: new OA\Schema(type: 'string')),
65+
new OA\Parameter(name: 'relations', in: 'query', description: 'Relations to include: ticket_types', schema: new OA\Schema(type: 'string')),
66+
],
67+
responses: [
68+
new OA\Response(
69+
response: Response::HTTP_OK,
70+
description: 'Successful response',
71+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedSummitTaxTypesResponse')
72+
),
73+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
74+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
75+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
76+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
77+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
78+
]
79+
)]
80+
public function getAllBySummit($summit_id){
81+
return parent::getAllBySummit($summit_id);
82+
}
83+
84+
#[OA\Post(
85+
path: '/api/v1/summits/{id}/tax-types',
86+
summary: 'Create a new tax type',
87+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
88+
tags: ['Summits', 'Tax Types'],
89+
parameters: [
90+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
91+
],
92+
requestBody: new OA\RequestBody(
93+
required: true,
94+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxTypeCreateRequest')
95+
),
96+
responses: [
97+
new OA\Response(
98+
response: Response::HTTP_CREATED,
99+
description: 'Tax type created',
100+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxType')
101+
),
102+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
103+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
104+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
105+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
106+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
107+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
108+
]
109+
)]
110+
public function add($summit_id){
111+
return parent::add($summit_id);
112+
}
113+
114+
#[OA\Get(
115+
path: '/api/v1/summits/{id}/tax-types/{tax_id}',
116+
summary: 'Get a tax type by ID',
117+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
118+
tags: ['Summits', 'Tax Types'],
119+
parameters: [
120+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
121+
new OA\Parameter(name: 'tax_id', in: 'path', required: true, description: 'Tax Type ID', schema: new OA\Schema(type: 'integer')),
122+
],
123+
responses: [
124+
new OA\Response(
125+
response: Response::HTTP_OK,
126+
description: 'Successful response',
127+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxType')
128+
),
129+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
130+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
131+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
132+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
133+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
134+
]
135+
)]
136+
public function get($summit_id, $tax_id){
137+
return parent::get($summit_id, $tax_id);
138+
}
139+
140+
#[OA\Put(
141+
path: '/api/v1/summits/{id}/tax-types/{tax_id}',
142+
summary: 'Update a tax type',
143+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
144+
tags: ['Summits', 'Tax Types'],
145+
parameters: [
146+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
147+
new OA\Parameter(name: 'tax_id', in: 'path', required: true, description: 'Tax Type ID', schema: new OA\Schema(type: 'integer')),
148+
],
149+
requestBody: new OA\RequestBody(
150+
required: true,
151+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxTypeUpdateRequest')
152+
),
153+
responses: [
154+
new OA\Response(
155+
response: Response::HTTP_OK,
156+
description: 'Tax type updated',
157+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxType')
158+
),
159+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
160+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
161+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
162+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
163+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
164+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
165+
]
166+
)]
167+
public function update($summit_id, $tax_id){
168+
return parent::update($summit_id, $tax_id);
169+
}
170+
171+
#[OA\Delete(
172+
path: '/api/v1/summits/{id}/tax-types/{tax_id}',
173+
summary: 'Delete a tax type',
174+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
175+
tags: ['Summits', 'Tax Types'],
176+
parameters: [
177+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
178+
new OA\Parameter(name: 'tax_id', in: 'path', required: true, description: 'Tax Type ID', schema: new OA\Schema(type: 'integer')),
179+
],
180+
responses: [
181+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: "No Content"),
182+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
183+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
184+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
185+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
186+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
187+
]
188+
)]
189+
public function delete($summit_id, $tax_id){
190+
return parent::delete($summit_id, $tax_id);
191+
}
192+
52193
/**
53194
* @return array
54195
*/
@@ -163,6 +304,30 @@ protected function deleteChild(Summit $summit, $child_id): void
163304
* @param $ticket_type_id
164305
* @return \Illuminate\Http\JsonResponse|mixed
165306
*/
307+
#[OA\Put(
308+
path: '/api/v1/summits/{id}/tax-types/{tax_id}/ticket-types/{ticket_type_id}',
309+
summary: 'Add a tax type to a ticket type',
310+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
311+
tags: ['Summits', 'Tax Types'],
312+
parameters: [
313+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
314+
new OA\Parameter(name: 'tax_id', in: 'path', required: true, description: 'Tax Type ID', schema: new OA\Schema(type: 'integer')),
315+
new OA\Parameter(name: 'ticket_type_id', in: 'path', required: true, description: 'Ticket Type ID', schema: new OA\Schema(type: 'integer')),
316+
],
317+
responses: [
318+
new OA\Response(
319+
response: Response::HTTP_OK,
320+
description: 'Tax type added to ticket type successfully',
321+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxType')
322+
),
323+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
324+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
325+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
326+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
327+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
328+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
329+
]
330+
)]
166331
public function addTaxToTicketType($summit_id, $tax_id, $ticket_type_id){
167332
try {
168333

@@ -193,6 +358,30 @@ public function addTaxToTicketType($summit_id, $tax_id, $ticket_type_id){
193358
* @param $ticket_type_id
194359
* @return \Illuminate\Http\JsonResponse|mixed
195360
*/
361+
#[OA\Delete(
362+
path: '/api/v1/summits/{id}/tax-types/{tax_id}/ticket-types/{ticket_type_id}',
363+
summary: 'Remove a tax type from a ticket type',
364+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
365+
tags: ['Summits', 'Tax Types'],
366+
parameters: [
367+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
368+
new OA\Parameter(name: 'tax_id', in: 'path', required: true, description: 'Tax Type ID', schema: new OA\Schema(type: 'integer')),
369+
new OA\Parameter(name: 'ticket_type_id', in: 'path', required: true, description: 'Ticket Type ID', schema: new OA\Schema(type: 'integer')),
370+
],
371+
responses: [
372+
new OA\Response(
373+
response: Response::HTTP_OK,
374+
description: 'Tax type removed from ticket type successfully',
375+
content: new OA\JsonContent(ref: '#/components/schemas/SummitTaxType')
376+
),
377+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
378+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
379+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
380+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
381+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
382+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
383+
]
384+
)]
196385
public function removeTaxFromTicketType($summit_id, $tax_id, $ticket_type_id){
197386
try {
198387

@@ -216,4 +405,4 @@ public function removeTaxFromTicketType($summit_id, $tax_id, $ticket_type_id){
216405
return $this->error500($ex);
217406
}
218407
}
219-
}
408+
}

app/Swagger/SummitRegistrationSchemas.php

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

55
use OpenApi\Attributes as OA;
66

7-
//
7+
#[OA\Schema(
8+
schema: 'SummitTaxType',
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: 'name', type: 'string', example: 'VAT'),
15+
new OA\Property(property: 'tax_id', type: 'string', example: 'VAT-001', nullable: true),
16+
new OA\Property(property: 'rate', type: 'number', format: 'float', example: 21.0),
17+
new OA\Property(property: 'summit_id', type: 'integer', example: 42),
18+
new OA\Property(
19+
property: 'ticket_types',
20+
type: 'array',
21+
items: new OA\Items(oneOf: [
22+
new OA\Schema(type: 'integer'),
23+
new OA\Schema(type: 'SummitTicketType')
24+
]),
25+
example: [1, 2, 3],
26+
description: 'Array of ticket type IDs or its Model (only present when relations=ticket_types), expanded when expand includes ticket_types.'
27+
),
28+
]
29+
)]
30+
class SummitTaxTypeSchema {}
31+
32+
#[OA\Schema(
33+
schema: 'PaginatedSummitTaxTypesResponse',
34+
allOf: [
35+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
36+
new OA\Schema(
37+
type: 'object',
38+
properties: [
39+
new OA\Property(
40+
property: 'data',
41+
type: 'array',
42+
items: new OA\Items(ref: '#/components/schemas/SummitTaxType')
43+
)
44+
]
45+
)
46+
]
47+
)]
48+
class PaginatedSummitTaxTypesResponseSchema {}
49+
50+
#[OA\Schema(
51+
schema: 'SummitTaxTypeCreateRequest',
52+
type: 'object',
53+
required: ['name', 'rate'],
54+
properties: [
55+
new OA\Property(property: 'name', type: 'string', example: 'VAT'),
56+
new OA\Property(property: 'tax_id', type: 'string', example: 'VAT-001'),
57+
new OA\Property(property: 'rate', type: 'number', format: 'float', example: 21.0, description: 'Rate must be greater than 0'),
58+
]
59+
)]
60+
class SummitTaxTypeCreateRequestSchema {}
61+
62+
#[OA\Schema(
63+
schema: 'SummitTaxTypeUpdateRequest',
64+
type: 'object',
65+
properties: [
66+
new OA\Property(property: 'name', type: 'string', example: 'VAT'),
67+
new OA\Property(property: 'tax_id', type: 'string', example: 'VAT-001'),
68+
new OA\Property(property: 'rate', type: 'number', format: 'float', example: 21.0, description: 'Rate must be greater than 0'),
69+
]
70+
)]
71+
class SummitTaxTypeUpdateRequestSchema {}

0 commit comments

Comments
 (0)