Skip to content

Commit c6b0f98

Browse files
fix: Reuse already defined schema and add Paginated Schema
1 parent 71f5f4d commit c6b0f98

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

app/Http/Controllers/Apis/CountriesApiController.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@ final class CountriesApiController extends JsonController
4545
new OA\Response(
4646
response: 200,
4747
description: 'Success - Returns paginated list of countries',
48-
content: new OA\JsonContent(
49-
properties: [
50-
'total' => new OA\Property(property: 'total', type: 'integer', example: 195),
51-
'per_page' => new OA\Property(property: 'per_page', type: 'integer', example: 195),
52-
'current_page' => new OA\Property(property: 'current_page', type: 'integer', example: 1),
53-
'last_page' => new OA\Property(property: 'last_page', type: 'integer', example: 1),
54-
'data' => new OA\Property(
55-
property: 'data',
56-
type: 'array',
57-
items: new OA\Items(ref: "#/components/schemas/ISOElementSchema")
58-
)
59-
],
60-
type: 'object'
61-
)
48+
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedISOElementResponseSchema'),
6249
),
6350
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
6451
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"),

app/Swagger/schemas.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,22 @@ class RSVPAdminAddRequestSchema {}
385385
]
386386
)]
387387
class ISOElementSchema {};
388+
389+
#[OA\Schema(
390+
schema: 'PaginatedISOElementResponseSchema',
391+
type: 'object',
392+
allOf: [
393+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
394+
new OA\Schema(
395+
type: 'object',
396+
properties: [
397+
new OA\Property(
398+
property: 'data',
399+
type: 'array',
400+
items: new OA\Items(ref: "#/components/schemas/ISOElementSchema")
401+
)
402+
]
403+
)
404+
]
405+
)]
406+
class PaginatedISOElementResponseSchema {};

0 commit comments

Comments
 (0)