mirror of https://github.com/tiangolo/fastapi.git
📝 Add notification message warning about old versions of FastAPI not supporting `Annotated` (#9298)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
925ba5c652
commit
8df86309c8
|
|
@ -85,6 +85,13 @@ In this case, this dependency expects:
|
|||
|
||||
And then it just returns a `dict` containing those values.
|
||||
|
||||
!!! info
|
||||
FastAPI added support for `Annotated` (and started recommending it) in version 0.95.0.
|
||||
|
||||
If you have an older version, you would get errors when trying to use `Annotated`.
|
||||
|
||||
Make sure you [Upgrade the FastAPI version](../../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`.
|
||||
|
||||
### Import `Depends`
|
||||
|
||||
=== "Python 3.10+"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,13 @@ First, import `Path` from `fastapi`, and import `Annotated`:
|
|||
{!> ../../../docs_src/path_params_numeric_validations/tutorial001.py!}
|
||||
```
|
||||
|
||||
!!! info
|
||||
FastAPI added support for `Annotated` (and started recommending it) in version 0.95.0.
|
||||
|
||||
If you have an older version, you would get errors when trying to use `Annotated`.
|
||||
|
||||
Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`.
|
||||
|
||||
## Declare metadata
|
||||
|
||||
You can declare all the same parameters as for `Query`.
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@ To achieve that, first import:
|
|||
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
|
||||
```
|
||||
|
||||
!!! info
|
||||
FastAPI added support for `Annotated` (and started recommending it) in version 0.95.0.
|
||||
|
||||
If you have an older version, you would get errors when trying to use `Annotated`.
|
||||
|
||||
Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`.
|
||||
|
||||
## Use `Annotated` in the type for the `q` parameter
|
||||
|
||||
Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations){.internal-link target=_blank}?
|
||||
|
|
|
|||
Loading…
Reference in New Issue