Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/V1/ResultsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function list(Request $request)
);
}
$validator = Validator::make($request->all(), [
'per_page' => 'integer|min:1|max:500',
'page.size' => 'integer|min:1|max:'.config('json-api-paginate.max_results'),
]);

if ($validator->fails()) {
Expand Down Expand Up @@ -65,7 +65,7 @@ public function list(Request $request)
'created_at',
'updated_at',
])
->jsonPaginate($request->input('per_page', 25));
->jsonPaginate();

return ResultResource::collection($results);
}
Expand Down
2 changes: 1 addition & 1 deletion app/OpenApi/Annotations/V1/ResultsAnnotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ResultsAnnotations
parameters: [
new OA\Parameter(ref: '#/components/parameters/AcceptHeader'),
new OA\Parameter(
name: 'per_page',
name: 'per.page',
in: 'query',
required: false,
schema: new OA\Schema(type: 'integer', minimum: 1, maximum: 500, default: 25),
Expand Down
2 changes: 1 addition & 1 deletion app/OpenApi/Schemas/ResultsCollectionSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)
),
new OA\Property(property: 'path', type: 'string'),
new OA\Property(property: 'per_page', type: 'integer'),
new OA\Property(property: 'per.page', type: 'integer'),
new OA\Property(property: 'to', type: 'integer'),
new OA\Property(property: 'total', type: 'integer'),
],
Expand Down
17 changes: 17 additions & 0 deletions config/json-api-paginate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return [

/*
* The maximum number of results that will be returned
* when using the JSON API paginator.
*/
'max_results' => env('API_MAX_RESULTS', 500),

/*
* The default number of results that will be returned
* when using the JSON API paginator.
*/
'default_size' => 25,

];
2 changes: 1 addition & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"$ref": "#/components/parameters/AcceptHeader"
},
{
"name": "per_page",
"name": "per.page",
"in": "query",
"description": "Number of results per page",
"required": false,
Expand Down