Open agusmdev opened 6 months ago
It seems it's a FastAPI issue that happens when using Pydantic V2. They already know about this: https://github.com/pydantic/pydantic/issues/6647 and it seems the workaround is to use SkipJsonSchema
from pydantic
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.
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 disappearsWithout Optional:
With Optional:
Do you know a workaround or a possible fix to this?