mirror of https://github.com/tiangolo/fastapi.git
added Python 3.10+ syntax for small part
This commit is contained in:
parent
8c572a9ef2
commit
b57f2a43d9
|
|
@ -385,13 +385,25 @@ q: Union[str, None] = None
|
||||||
|
|
||||||
But we are now declaring it with `Query`, for example like:
|
But we are now declaring it with `Query`, for example like:
|
||||||
|
|
||||||
=== "Annotated"
|
=== "Python 3.10+ Annotated"
|
||||||
|
|
||||||
|
```Python
|
||||||
|
q: Annotated[str | None, Query(min_length=3)] = None
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Python 3.9+ Annotated"
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
q: Annotated[Union[str, None], Query(min_length=3)] = None
|
q: Annotated[Union[str, None], Query(min_length=3)] = None
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "non-Annotated"
|
=== "Python 3.10+ non-Annotated"
|
||||||
|
|
||||||
|
```Python
|
||||||
|
q: str | None = Query(default=None, min_length=3)
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Python 3.9+ non-Annotated"
|
||||||
|
|
||||||
```Python
|
```Python
|
||||||
q: Union[str, None] = Query(default=None, min_length=3)
|
q: Union[str, None] = Query(default=None, min_length=3)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue