Skip to content

Swagger not showing types of filters #521

@agusmdev

Description

@agusmdev

Hi! I started using this library and it works great. Excellent job @arthurio !

I just realized that with the latest version of Pydantic V2 the new behavior of optional fields breaks the types of the query params in the swagger documentation.

If you set your query params as "Optional" or with the notation query_param: Type | None it won't show the type on the swagger docs.

I've tried this by running the example https://github.com/arthurio/fastapi-filter/blob/main/examples/fastapi_filter_sqlalchemy.py, you'll see the only param that shows the type the only one that it's not optional: age__gte: int = Field(Query(description="this is a nice description")). If you change this param to be optional (age__gte: Optional[int] = Field(Query(description="this is a nice description"))) the type disappears

Without Optional:
Captura de pantalla 2023-12-13 a la(s) 10 08 52

With Optional:
Captura de pantalla 2023-12-13 a la(s) 10 09 35

Do you know a workaround or a possible fix to this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions