Skip to content

OpenApi style=form not possible anymore #7546

@temp

Description

@temp

API Platform version(s) affected: 4.2.6

Description
After an upgrade to api-platform/core 4.2.6 our openapi query parameter definitions don't work as expected anymore
We get a validation error with style=form

How to reproduce

            parameters: [
                'tags' => new QueryParameter(
                    key: 'tags',
                    schema: [
                        'type' => 'array',
                        'items' => [
                            'type' => 'string',
                            'uniqueItems' => true,
                            'enum' => ['A', 'B', 'C'],
                        ],
                    ],
                    openApi: new Parameter(
                        'tags',
                        'query',
                        description: 'Only return activities with the given comma-seperated tag(s)',
                        required: false,
                        style: 'form',
                        explode: false,
                        example: 'A,B
                    ),
                    nativeType: new BuiltinType(TypeIdentifier::ARRAY),
                ),
            ],

This is called with ?tags=A,B and throws this exception:

request.DEBUG: Uncaught PHP Exception ApiPlatform\Validator\Exception\ValidationException: "tags: This value should be of type array." at ParameterValidatorProvider.php line 98 {"exception":"[object] (ApiPlatform\\Validator\\Exception\\ValidationException(code: 0): tags: This value should be of type array. at .../vendor/api-platform/core/src/Symfony/Validator/State/ParameterValidatorProvider.php:98)

Possible Solution
Is there a way to get style=form serialization?

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