Skip to content

fix: fix boolean parameters type detection #7223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vincentchalamon
Copy link
Contributor

Q A
Branch? 4.1
Tickets N/A
License MIT
Doc PR N/A

Considering the following configuration:

new GetCollection(
    // ...
    parameters: [
        'archivedOnly' => new QueryParameter(
            key: 'archivedOnly',
            schema: ['type' => 'boolean'],
            required: true,
            openApi: new Model\Parameter(
                name: 'archivedOnly',
                in: 'query',
                required: true,
            ),
        ),
    ],
),

The current code only supports array or string types, then fallback to an array of strings (cf. ParameterResourceMetadataCollectionFactory line 160), which seems then considered to an iterable by the validator (All validator is applied, which expects an array as value), leading to the following error:

Symfony\Component\HttpClient\Exception\ClientException: An error occurred

archivedOnly: This value should be of type iterable.

Supporting boolean type here fixes this issue.

@vincentchalamon vincentchalamon requested a review from soyuka June 17, 2025 16:04
@soyuka soyuka merged commit dba9737 into api-platform:4.1 Jun 19, 2025
110 of 111 checks passed
@soyuka
Copy link
Member

soyuka commented Jun 19, 2025

thanks !

@vincentchalamon vincentchalamon deleted the fix/parameter-type-detection branch June 19, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants