Skip to content

Unable to disable pagination maximum items per page since 4.2 #7530

@bram123

Description

@bram123

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions