ExactFilter on enum typed property is not generating enums in docs.jsonopenapi · Issue #3017 · api-platform/api-platform · GitHub
Skip to content

ExactFilter on enum typed property is not generating enums in docs.jsonopenapi #3017

Open

Description

@kkleinlankhorst

API Platform version(s) affected: 4.4.3

Description
I'm rewriting the legacy ApiFilter BackedEnumFilter to a #[QueryParameter] attribute using the ExactFilter that is kept in 6.0 (see this documentation: https://api-platform.com/docs/core/upgrade-guide/#legacy-doctrine-filters). The filter works but the enums are not generated anymore (which means the dropdown with available values is lost on the SwaggerUI). Now a normal text input is given which is not desired for our UI.

How to reproduce
So the old situation was:
#[ApiFilter(BackedEnumFilter::class, properties: ['type'])]
This generated the enums belonging to this type property in the docs.jsonopenapi of our api

In the new situation a QueryParameter is used with ExactFilter:

#[ApiResource(
    operations: [
        new GetCollection(
            '/activiteiten/bijeenkomsten{._format}',
            parameters: [
                'type' => new QueryParameter(
                    filter: new ExactFilter(),
                    property: 'type',
                ),
            ]
        ),
    ],
)]

And type in this Entity is the following:

#[ORM\Column(name: 'act_type', type: Types::ENUM)]
private TypeEnum $type;

Filtering like this works when the user correctly inputs an enum value but the enums are not generated anymore in the docs.jsonopenapi

Possible Solution
Adding

schema: [
        'type' => 'string',
        'enum' => array_column(TypeEnum::cases(), 'value'),
    ],

to the requestParameter to retrieve the values of the enums here for the dropdown is not possible since only constant values can be given here.

Another idea is creating a custom filter and using the getOpenApiParameters() function to document the filter, but this seems impossible because ExactFilter is a final class.

Additional Context
This was the json in our docs.jsonopenapi:
{ "name": "type", "in": "query", "description": "", "required": false, "deprecated": false, "schema": { "type": "string", "enum": [ "cursus", "opleiding", "clinic", "themabijeenkomst", "clusterbijeenkomst", "symposium", "congres", "regioraad", "bondsraad", "officialbijeenkomst", "kaderbijeenkomst", "webinar", "workshop", "e-learning", "bijscholing" ] }, "style": "form", "explode": false }, { "name": "type[]", "in": "query", "description": "", "required": false, "deprecated": false, "schema": { "type": "array", "items": { "type": "string", "enum": [ "cursus", "opleiding", "clinic", "themabijeenkomst", "clusterbijeenkomst", "symposium", "congres", "regioraad", "bondsraad", "officialbijeenkomst", "kaderbijeenkomst", "webinar", "workshop", "e-learning", "bijscholing" ] } }, "style": "form", "explode": true },

And this is the json now with the Exactfilter in the QueryParameter:
{ "name": "type", "in": "query", "description": "Bijeenkomst type", "required": false, "deprecated": false, "schema": { "type": "string" }, "style": "form", "explode": true }, { "name": "type[]", "in": "query", "description": "Bijeenkomst type", "required": false, "deprecated": false, "schema": { "type": "array", "items": { "type": "string" } }, "style": "deepObject", "explode": true },

Which misses the enum in the schema attribute

Activity

  1. changed the title [-]ExactFilter on enum typed property is not showing enums as dropdown in the swaggerUI[/-] [+]ExactFilter on enum typed property is not generating enums in docs.jsonopenapi[/+] on Oct 19, 2026
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