-
-
Notifications
You must be signed in to change notification settings - Fork 940
Description
API Platform version(s) affected: 4.2.3
Description
On the previous version (v4.1.26) we were able to disable the paginator maximum.
How to reproduce
Using the following api-platform config in Symfony:
$config->defaults()
->paginationItemsPerPage(50)
->paginationMaximumItemsPerPage(null)
->paginationEnabled(true)
->paginationClientEnabled(true)
->paginationClientItemsPerPage(true)Running php bin/console api:openapi:export to generate the openapi.json file,
Previously this was generated:
{
"name": "itemsPerPage",
"in": "query",
"description": "The number of items per page",
"required": false,
"deprecated": false,
"allowEmptyValue": true,
"schema": {
"type": "integer",
"default": 50,
"minimum": 0
},
"style": "form",
"explode": false,
"allowReserved": false
}Now it generates:
{
"name": "itemsPerPage",
"in": "query",
"description": "The number of items per page",
"required": false,
"deprecated": false,
"schema": {
"type": "integer",
"default": 50,
"minimum": 0,
"maximum": 30
},
"style": "form",
"explode": false
}for the "itemsPerPage" parameter.
With the latest version it has a max of 30, but 50 is the default.
Cause
I think the issue is in ApiPlatform\Symfony\Bundle\DependencyInjection\ApiPlatformExtension.php,
which previously contained
$container->setParameter('api_platform.collection.pagination.maximum_items_per_page', $config['defaults']['pagination_maximum_items_per_page'] ?? null);
But since #7396 it has:
$container->setParameter('api_platform.collection.pagination.maximum_items_per_page', $config['defaults']['pagination_maximum_items_per_page'] ?? 30);
The code in ApiPlatform\OpenApi\Factory\OpenApiFactory.php does have a null check for $maxItemsPerPage, so it is a valid config option.