Skip to content

strictQueryParameterValidation blocks pagination parameters #8543

Description

@jannes-io

API Platform version(s) affected: 4.3.4

Description

When enabling defaults.strictQueryParameterValidation in global config:

#config/packages/api-platform.yaml
api_platform:
    defaults:
        strictQueryParameterValidation: true
        parameters:
            # Some of our own global parameters, not sure if this might be related that we also define more params
            ApiPlatform\Metadata\QueryParameter:
                key: '_lang'
                required: false
                description: '2 letter language code, for example EN. By default, the primary language is used.'

It does not automatically whitelist the pagination query parameters for GetCollection operations. The openapi docs do include the pagination parameters, so they are definitely added to the operation, but for the parameter validation, they are not included.

How to reproduce
Enable strictQueryParameterValidation, then try to do a GetCollection operation with pagination parameters. Result is 400:

"title": "Parameter not supported",
"detail": "Parameter \"page\" not supported",
"description": "Parameter \"page\" not supported"

Possible Solution
Add the pagination parameters to the operation before query parameter validation.

#8544

Additional Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions