Skip to content

Commit 25b285e

Browse files
chore: Add controller's response OpenAPI schema
1 parent 67549b2 commit 25b285e

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

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
@@ -351,3 +351,37 @@ class RSVPUpdateRequestSchema_{
351351
]
352352
)]
353353
class RSVPAdminAddRequestSchema {}
354+
355+
#[OA\Schema(
356+
schema: 'ConsultantsResponseSchema',
357+
type: 'object',
358+
properties: [
359+
'id' => new OA\Property(property: 'id', type: 'integer', example: 1),
360+
'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'),
361+
'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'),
362+
'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'),
363+
'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'),
364+
'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'),
365+
'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1),
366+
'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1)
367+
]
368+
)]
369+
class ConsultantsResponseSchema {}
370+
371+
#[OA\Schema(
372+
schema: 'PaginatedConsultantsResponseSchema',
373+
allOf: [
374+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
375+
new OA\Schema(
376+
type: 'object',
377+
properties: [
378+
new OA\Property(
379+
property: 'data',
380+
type: 'array',
381+
items: new OA\Items(ref: '#/components/schemas/ConsultantsResponseSchema')
382+
)
383+
]
384+
)
385+
]
386+
)]
387+
class PaginatedConsultantsResponseSchema {}

0 commit comments

Comments
 (0)