Skip to content

Commit 15d1118

Browse files
committed
feat: Add requestBody ref schemas
1 parent 203171d commit 15d1118

2 files changed

Lines changed: 80 additions & 60 deletions

File tree

app/Http/Controllers/Apis/Protected/Main/OAuth2SponsoredProjectApiController.php

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,7 @@ function () {
305305
]]],
306306
requestBody: new OA\RequestBody(
307307
required: true,
308-
content: new OA\JsonContent(
309-
type: 'object',
310-
properties: [
311-
new OA\Property(property: 'name', type: 'string', description: 'Project name'),
312-
new OA\Property(property: 'description', type: 'string', description: 'Project description'),
313-
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the project is active'),
314-
]
315-
)
308+
content: new OA\JsonContent(ref:'#/components/schemas/SponsoredProjectRequest')
316309
),
317310
parameters: [
318311
new OA\Parameter(
@@ -422,14 +415,7 @@ public function get($id)
422415
]]],
423416
requestBody: new OA\RequestBody(
424417
required: true,
425-
content: new OA\JsonContent(
426-
type: 'object',
427-
properties: [
428-
new OA\Property(property: 'name', type: 'string', description: 'Project name'),
429-
new OA\Property(property: 'description', type: 'string', description: 'Project description'),
430-
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the project is active'),
431-
]
432-
)
418+
content: new OA\JsonContent(ref: '#/components/schemas/SponsoredProjectRequest')
433419
),
434420
parameters: [
435421
new OA\Parameter(
@@ -790,15 +776,7 @@ public function getSponsorshipType($id, $sponsorship_type_id){
790776
]]],
791777
requestBody: new OA\RequestBody(
792778
required: true,
793-
content: new OA\JsonContent(
794-
type: 'object',
795-
properties: [
796-
new OA\Property(property: 'name', type: 'string', description: 'Sponsorship type name'),
797-
new OA\Property(property: 'description', type: 'string', description: 'Sponsorship type description'),
798-
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the sponsorship type is active'),
799-
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
800-
]
801-
)
779+
content: new OA\JsonContent(ref:'#/components/schemas/ProjectSponsorshipTypeCreateRequest')
802780
),
803781
parameters: [
804782
new OA\Parameter(
@@ -863,15 +841,7 @@ function ($payload, $id){
863841
]]],
864842
requestBody: new OA\RequestBody(
865843
required: true,
866-
content: new OA\JsonContent(
867-
type: 'object',
868-
properties: [
869-
new OA\Property(property: 'name', type: 'string', description: 'Sponsorship type name'),
870-
new OA\Property(property: 'description', type: 'string', description: 'Sponsorship type description'),
871-
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the sponsorship type is active'),
872-
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
873-
]
874-
)
844+
content: new OA\JsonContent(ref: '#/components/schemas/ProjectSponsorshipTypeUpdateRequest')
875845
),
876846
parameters: [
877847
new OA\Parameter(
@@ -1197,14 +1167,7 @@ function ($page, $per_page, $filter, $order, $applyExtraFilters) {
11971167
]]],
11981168
requestBody: new OA\RequestBody(
11991169
required: true,
1200-
content: new OA\JsonContent(
1201-
type: 'object',
1202-
required: ['company_id'],
1203-
properties: [
1204-
new OA\Property(property: 'company_id', type: 'integer', description: 'The company id'),
1205-
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
1206-
]
1207-
)
1170+
content: new OA\JsonContent(ref: '#/components/schemas/AddSupportingCompanyRequest')
12081171
),
12091172
parameters: [
12101173
new OA\Parameter(
@@ -1284,12 +1247,7 @@ function($payload, $project_id, $sponsorship_type_id){
12841247
]]],
12851248
requestBody: new OA\RequestBody(
12861249
required: true,
1287-
content: new OA\JsonContent(
1288-
type: 'object',
1289-
properties: [
1290-
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
1291-
]
1292-
)
1250+
content: new OA\JsonContent(ref: '#/components/schemas/UpdateSupportingCompanyRequest')
12931251
),
12941252
parameters: [
12951253
new OA\Parameter(
@@ -1517,18 +1475,7 @@ public function getSupportingCompany($id, $sponsorship_type_id, $company_id){
15171475
required: true,
15181476
content: new OA\MediaType(
15191477
mediaType: 'multipart/form-data',
1520-
schema: new OA\Schema(
1521-
type: 'object',
1522-
required: ['file'],
1523-
properties: [
1524-
new OA\Property(
1525-
property: 'file',
1526-
type: 'string',
1527-
format: 'binary',
1528-
description: 'The logo file to upload'
1529-
),
1530-
]
1531-
)
1478+
schema: new OA\Schema(ref: '#/components/schemas/UploadSponsoredProjectLogoRequest')
15321479
)
15331480
),
15341481
parameters: [

app/Swagger/SponsoredProjectSchemas.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,76 @@ class PaginatedProjectSponsorshipTypesResponseSchema {}
6464
)]
6565
class PaginatedSupportingCompaniesResponseSchema {}
6666

67+
68+
69+
#[OA\Schema(
70+
schema: 'SponsoredProjectRequest',
71+
type: 'object',
72+
properties: [
73+
new OA\Property(property: 'name', type: 'string', description: 'Project name'),
74+
new OA\Property(property: 'description', type: 'string', description: 'Project description'),
75+
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the project is active'),
76+
]
77+
)]
78+
class SponsoredProjectRequestSchema {}
79+
80+
81+
#[OA\Schema(
82+
schema: 'ProjectSponsorshipTypeCreateRequest',
83+
type: 'object',
84+
properties: [
85+
new OA\Property(property: 'name', type: 'string', description: 'Sponsorship type name'),
86+
new OA\Property(property: 'description', type: 'string', description: 'Sponsorship type description'),
87+
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the sponsorship type is active'),
88+
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
89+
]
90+
)]
91+
class ProjectSponsorshipTypeCreateRequestSchema {}
92+
93+
#[OA\Schema(
94+
schema: 'ProjectSponsorshipTypeUpdateRequest',
95+
type: 'object',
96+
properties: [
97+
new OA\Property(property: 'name', type: 'string', description: 'Sponsorship type name'),
98+
new OA\Property(property: 'description', type: 'string', description: 'Sponsorship type description'),
99+
new OA\Property(property: 'is_active', type: 'boolean', description: 'Whether the sponsorship type is active'),
100+
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
101+
]
102+
)]
103+
class ProjectSponsorshipTypeUpdateRequestSchema {}
104+
105+
#[OA\Schema(
106+
schema: 'AddSupportingCompanyRequest',
107+
type: 'object',
108+
required: ['company_id'],
109+
properties: [
110+
new OA\Property(property: 'company_id', type: 'integer', description: 'The company id'),
111+
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
112+
]
113+
)]
114+
class AddSupportingCompanyRequestSchema {}
115+
116+
#[OA\Schema(
117+
schema: 'UpdateSupportingCompanyRequest',
118+
type: 'object',
119+
required: ['order'],
120+
properties: [
121+
new OA\Property(property: 'order', type: 'integer', description: 'Display order'),
122+
]
123+
)]
124+
class UpdateSupportingCompanyRequestSchema {}
125+
126+
#[OA\Schema(
127+
schema: 'UploadSponsoredProjectLogoRequest',
128+
type: 'object',
129+
required: ['file'],
130+
properties: [
131+
new OA\Property(
132+
property: 'file',
133+
type: 'string',
134+
format: 'binary',
135+
description: 'The logo file to upload'
136+
),
137+
]
138+
)]
139+
class UploadSponsoredProjectLogoRequestSchema {}

0 commit comments

Comments
 (0)