Skip to content

Commit 44ea73b

Browse files
chore: Add controller's response OpenAPI schema
1 parent c653fab commit 44ea73b

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,7 @@ public function __construct(IConsultantRepository $repository, IResourceServerCo
8484
new OA\Response(
8585
response: 200,
8686
description: 'Success - Returns paginated list of consultants',
87-
content: new OA\JsonContent(
88-
properties: [
89-
'total' => new OA\Property(property: 'total', type: 'integer', example: 15),
90-
'per_page' => new OA\Property(property: 'per_page', type: 'integer', example: 15),
91-
'current_page' => new OA\Property(property: 'current_page', type: 'integer', example: 1),
92-
'last_page' => new OA\Property(property: 'last_page', type: 'integer', example: 1),
93-
'data' => new OA\Property(
94-
property: 'data',
95-
type: 'array',
96-
items: new OA\Items(
97-
properties: [
98-
'id' => new OA\Property(property: 'id', type: 'integer', example: 1),
99-
'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'),
100-
'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'),
101-
'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'),
102-
'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'),
103-
'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'),
104-
'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1),
105-
'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1)
106-
],
107-
type: 'object'
108-
)
109-
)
110-
],
111-
type: 'object'
112-
)
87+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedConsultantsResponse')
11388
),
11489
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
11590
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error")

app/Swagger/schemas.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,37 @@ class RSVPUpdateRequestSchema_{
376376
]
377377
)]
378378
class RSVPAdminAddRequestSchema {}
379+
380+
#[OA\Schema(
381+
schema: 'ConsultantsResponseSchema',
382+
type: 'object',
383+
properties: [
384+
'id' => new OA\Property(property: 'id', type: 'integer', example: 1),
385+
'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'),
386+
'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'),
387+
'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'),
388+
'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'),
389+
'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'),
390+
'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1),
391+
'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1)
392+
]
393+
)]
394+
class ConsultantsResponseSchema {}
395+
396+
#[OA\Schema(
397+
schema: 'PaginatedConsultantsResponseSchema',
398+
allOf: [
399+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
400+
new OA\Schema(
401+
type: 'object',
402+
properties: [
403+
new OA\Property(
404+
property: 'data',
405+
type: 'array',
406+
items: new OA\Items(ref: '#/components/schemas/ConsultantsResponseSchema')
407+
)
408+
]
409+
)
410+
]
411+
)]
412+
class PaginatedConsultantsResponseSchema {}

0 commit comments

Comments
 (0)