-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Required query parameter declaration issues (FastAPI v.0.100.0) #9861
Description
Privileged issue
- I'm @tiangolo or he asked me directly to create an issue here.
Issue Content
When I declare query parameter without Annotated and with Ellipsis, e.g.:
item_name: str = ...
Everythings works as it should, there are no errors and interactive API docs webpage contains an information that item_name is „*required”. But:
When I declare query parameter with or without Annotated and without Ellipsis, (as it is described in Tutorial - User Guide), e.g.:
item_name: str
or
item_name: Annotated[str, Query(min_length=3)]
I get an uvicorn process error:
item_name: str
^^^^^^^^^^^^^^
SyntaxError: non-default argument follows default argument
When I declara query parameter with Annotated and with Ellipsis, e.g.:
item_name: Annotated[str, Query(min_length=3)] = ...
There are no errors but interactive API docs webpage DOESN’T contain any information that item_name is required.
When I try to import Required from pydantic (as it is described in Tutorial - User Guide, eg at the chapter
https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#use-pydantics-required-instead-of-ellipsis
e.g.
from pydantic import Required
item_name: Annotated[str, Query(min_length=3)] = Required
I got en error:
pydantic.errors.PydanticImportError: pydantic:Required has been removed in V2.