Skip to content

Commit 4f42a74

Browse files
feat: Extend Swagger Coverage for controller OAuth2SummitSponsorshipTypeApiController
1 parent 57298dc commit 4f42a74

File tree

3 files changed

+267
-3
lines changed

3 files changed

+267
-3
lines changed

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

Lines changed: 200 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
use App\ModelSerializers\SerializerUtils;
1717
use App\Services\Model\ISummitSponsorshipTypeService;
1818
use Illuminate\Http\Request as LaravelRequest;
19+
use Illuminate\Http\Response;
1920
use models\oauth2\IResourceServerContext;
2021
use models\summit\ISummitRepository;
2122
use models\summit\Summit;
2223
use models\utils\IEntity;
2324
use ModelSerializers\SerializerRegistry;
25+
use OpenApi\Attributes as OA;
2426

2527
/**
2628
* Class OAuth2SummitSponsorshipTypeApiController
@@ -69,6 +71,144 @@ public function __construct
6971

7072
use DeleteSummitChildElement;
7173

74+
#[OA\Get(
75+
path: '/api/v1/summits/{id}/sponsorships-types',
76+
summary: 'Get all sponsorship types for a summit',
77+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
78+
tags: ['Summits', 'Sponsorship Types'],
79+
parameters: [
80+
new OA\Parameter(ref: '#/components/parameters/page'),
81+
new OA\Parameter(ref: '#/components/parameters/per_page'),
82+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
83+
new OA\Parameter(name: 'filter', in: 'query', description: 'Filter by name, label, or size (name=@value, label==value, size=@value)', schema: new OA\Schema(type: 'string')),
84+
new OA\Parameter(name: 'order', in: 'query', description: 'Order by: +/-id, +/-name, +/-order, +/-label, +/-size', schema: new OA\Schema(type: 'string')),
85+
],
86+
responses: [
87+
new OA\Response(
88+
response: Response::HTTP_OK,
89+
description: 'Successful response',
90+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedSummitSponsorshipTypesResponse')
91+
),
92+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
93+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
94+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
95+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
96+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
97+
]
98+
)]
99+
public function getAllBySummit($summit_id){
100+
return parent::getAllBySummit($summit_id);
101+
}
102+
103+
#[OA\Post(
104+
path: '/api/v1/summits/{id}/sponsorships-types',
105+
summary: 'Create a new sponsorship type',
106+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
107+
tags: ['Summits', 'Sponsorship Types'],
108+
parameters: [
109+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
110+
],
111+
requestBody: new OA\RequestBody(
112+
required: true,
113+
content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipTypeCreateRequest')
114+
),
115+
responses: [
116+
new OA\Response(
117+
response: Response::HTTP_CREATED,
118+
description: 'Sponsorship type created',
119+
content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipType')
120+
),
121+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
122+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
123+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
124+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
125+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
126+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
127+
]
128+
)]
129+
public function add($summit_id){
130+
return parent::add($summit_id);
131+
}
132+
133+
#[OA\Get(
134+
path: '/api/v1/summits/{id}/sponsorships-types/{type_id}',
135+
summary: 'Get a sponsorship type by ID',
136+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
137+
tags: ['Summits', 'Sponsorship Types'],
138+
parameters: [
139+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
140+
new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')),
141+
],
142+
responses: [
143+
new OA\Response(
144+
response: Response::HTTP_OK,
145+
description: 'Successful response',
146+
content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipType')
147+
),
148+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
149+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
150+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
151+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
152+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
153+
]
154+
)]
155+
public function get($summit_id, $type_id){
156+
return parent::get($summit_id, $type_id);
157+
}
158+
159+
#[OA\Put(
160+
path: '/api/v1/summits/{id}/sponsorships-types/{type_id}',
161+
summary: 'Update a sponsorship type',
162+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
163+
tags: ['Summits', 'Sponsorship Types'],
164+
parameters: [
165+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
166+
new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')),
167+
],
168+
requestBody: new OA\RequestBody(
169+
required: true,
170+
content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipTypeUpdateRequest')
171+
),
172+
responses: [
173+
new OA\Response(
174+
response: Response::HTTP_OK,
175+
description: 'Sponsorship type updated',
176+
content: new OA\JsonContent(ref: '#/components/schemas/SummitSponsorshipType')
177+
),
178+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
179+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
180+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
181+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
182+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
183+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
184+
]
185+
)]
186+
public function update($summit_id, $type_id){
187+
return parent::update($summit_id, $type_id);
188+
}
189+
190+
#[OA\Delete(
191+
path: '/api/v1/summits/{id}/sponsorships-types/{type_id}',
192+
summary: 'Delete a sponsorship type',
193+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
194+
tags: ['Summits', 'Sponsorship Types'],
195+
parameters: [
196+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
197+
new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')),
198+
],
199+
responses: [
200+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: "No Content"),
201+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
202+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
203+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
204+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
205+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
206+
]
207+
)]
208+
public function delete($summit_id, $type_id){
209+
return parent::delete($summit_id, $type_id);
210+
}
211+
72212
/**
73213
* @return array
74214
*/
@@ -184,6 +324,47 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I
184324
* @throws \models\exceptions\EntityNotFoundException
185325
* @throws \models\exceptions\ValidationException
186326
*/
327+
#[OA\Post(
328+
path: '/api/v1/summits/{id}/sponsorships-types/{type_id}/badge-image',
329+
summary: 'Upload a badge image for a sponsorship type',
330+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
331+
tags: ['Summits', 'Sponsorship Types'],
332+
parameters: [
333+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
334+
new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')),
335+
],
336+
requestBody: new OA\RequestBody(
337+
required: true,
338+
content: new OA\MediaType(
339+
mediaType: 'multipart/form-data',
340+
schema: new OA\Schema(
341+
required: ['file'],
342+
properties: [
343+
new OA\Property(property: 'file', type: 'string', format: 'binary', description: 'Image file to upload')
344+
]
345+
)
346+
)
347+
),
348+
responses: [
349+
new OA\Response(
350+
response: Response::HTTP_CREATED,
351+
description: 'Badge image uploaded successfully',
352+
content: new OA\JsonContent(
353+
properties: [
354+
new OA\Property(property: 'id', type: 'integer', example: 123),
355+
new OA\Property(property: 'url', type: 'string', example: 'https://example.com/badge.png'),
356+
new OA\Property(property: 'filename', type: 'string', example: 'badge.png'),
357+
]
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+
)]
187368
public function addBadgeImage(LaravelRequest $request, $summit_id, $type_id){
188369
return $this->processRequest(function () use ($request, $summit_id, $type_id) {
189370

@@ -214,6 +395,24 @@ public function addBadgeImage(LaravelRequest $request, $summit_id, $type_id){
214395
* @throws \models\exceptions\EntityNotFoundException
215396
* @throws \models\exceptions\ValidationException
216397
*/
398+
#[OA\Delete(
399+
path: '/api/v1/summits/{id}/sponsorships-types/{type_id}/badge-image',
400+
summary: 'Remove the badge image from a sponsorship type',
401+
security: [['OAuth2' => ['openid', 'profile', 'email']]],
402+
tags: ['Summits', 'Sponsorship Types'],
403+
parameters: [
404+
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID', schema: new OA\Schema(type: 'integer')),
405+
new OA\Parameter(name: 'type_id', in: 'path', required: true, description: 'Sponsorship Type ID', schema: new OA\Schema(type: 'integer')),
406+
],
407+
responses: [
408+
new OA\Response(response: Response::HTTP_NO_CONTENT, description: "No Content"),
409+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
410+
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
411+
new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"),
412+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not found"),
413+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
414+
]
415+
)]
217416
public function removeBadgeImage($summit_id, $type_id){
218417
return $this->processRequest(function () use ($summit_id, $type_id) {
219418

@@ -226,4 +425,4 @@ public function removeBadgeImage($summit_id, $type_id){
226425

227426
});
228427
}
229-
}
428+
}

app/Swagger/SummitSchemas.php

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,72 @@
22

33
namespace App\Swagger\schemas;
44

5+
use models\summit\ISponsorshipTypeConstants;
56
use OpenApi\Attributes as OA;
67

7-
//
8+
#[OA\Schema(
9+
schema: 'SummitSponsorshipType',
10+
type: 'object',
11+
properties: [
12+
new OA\Property(property: 'id', type: 'integer', example: 1),
13+
new OA\Property(property: 'widget_title', type: 'string', example: 'Platinum Sponsors', nullable: true),
14+
new OA\Property(property: 'lobby_template', type: 'string', example: 'big-header', nullable: true),
15+
new OA\Property(property: 'expo_hall_template', type: 'string', example: 'big-images', nullable: true),
16+
new OA\Property(property: 'sponsor_page_template', type: 'string', example: 'big-header', nullable: true),
17+
new OA\Property(property: 'event_page_template', type: 'string', example: 'big-header', nullable: true),
18+
new OA\Property(property: 'sponsor_page_use_disqus_widget', type: 'boolean', example: true),
19+
new OA\Property(property: 'sponsor_page_use_live_event_widget', type: 'boolean', example: true),
20+
new OA\Property(property: 'sponsor_page_use_schedule_widget', type: 'boolean', example: true),
21+
new OA\Property(property: 'sponsor_page_use_banner_widget', type: 'boolean', example: true),
22+
new OA\Property(property: 'badge_image', type: 'string', example: 'https://example.com/badge.png', nullable: true),
23+
new OA\Property(property: 'badge_image_alt_text', type: 'string', example: 'Platinum Badge', nullable: true),
24+
new OA\Property(property: 'order', type: 'integer', example: 1),
25+
new OA\Property(property: 'should_display_on_expo_hall_page', type: 'boolean', example: true),
26+
new OA\Property(property: 'should_display_on_lobby_page', type: 'boolean', example: true),
27+
new OA\Property(property: 'summit', type: 'Summit'),
28+
new OA\Property(property: 'type', type: 'SponsorshipType'),
29+
]
30+
)]
31+
class SummitSponsorshipTypeSchema {}
32+
33+
#[OA\Schema(
34+
schema: 'PaginatedSummitSponsorshipTypesResponse',
35+
allOf: [
36+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
37+
new OA\Schema(
38+
type: 'object',
39+
properties: [
40+
new OA\Property(
41+
property: 'data',
42+
type: 'array',
43+
items: new OA\Items(ref: '#/components/schemas/SummitSponsorshipType')
44+
)
45+
]
46+
)
47+
]
48+
)]
49+
class PaginatedSummitSponsorshipTypesResponseSchema {}
50+
51+
#[OA\Schema(
52+
schema: 'SummitSponsorshipTypeCreateRequest',
53+
type: 'object',
54+
required: ['name', 'label', 'size'],
55+
properties: [
56+
new OA\Property(property: 'name', type: 'string', example: 'platinum'),
57+
new OA\Property(property: 'label', type: 'string', example: 'Platinum'),
58+
new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes),
59+
]
60+
)]
61+
class SummitSponsorshipTypeCreateRequestSchema {}
62+
63+
#[OA\Schema(
64+
schema: 'SummitSponsorshipTypeUpdateRequest',
65+
type: 'object',
66+
properties: [
67+
new OA\Property(property: 'name', type: 'string', example: 'platinum'),
68+
new OA\Property(property: 'label', type: 'string', example: 'Platinum'),
69+
new OA\Property(property: 'size', type: 'string', example: ISponsorshipTypeConstants::BigSize, enum: ISponsorshipTypeConstants::AllowedSizes),
70+
new OA\Property(property: 'order', type: 'integer', example: 1, minimum: 1),
71+
]
72+
)]
73+
class SummitSponsorshipTypeUpdateRequestSchema {}

app/Swagger/schemas.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
require __DIR__ . DIRECTORY_SEPARATOR . "MarketplaceSchemas.php";
2121
require __DIR__ . DIRECTORY_SEPARATOR . "ResourceServerSchemas.php";
2222
require __DIR__ . DIRECTORY_SEPARATOR . "SoftwareSchemas.php";
23-
require __DIR__ . DIRECTORY_SEPARATOR . "SummitSchemas.php";
2423
require __DIR__ . DIRECTORY_SEPARATOR . "SummitMetricsSchemas.php";
2524
require __DIR__ . DIRECTORY_SEPARATOR . "SummitPresentationSchemas.php";
2625
require __DIR__ . DIRECTORY_SEPARATOR . "SummitPresentationTrackQuestionsSchemas.php";

0 commit comments

Comments
 (0)