You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Varun Chawla
2f9439742f
Fix issue #13056 : Handle ForwardRef in Annotated types
When using Annotated types with ForwardRef string annotations (e.g.,
Annotated['ModelName', Query()]), FastAPI would fail with a Pydantic
error about the type not being fully defined.
The fix resolves ForwardRef in the extracted type annotation during
parameter analysis, ensuring that the actual resolved type is passed
to Pydantic rather than the unresolved ForwardRef.
Changes:
- Modified analyze_param() to resolve ForwardRef when extracting from Annotated
- Added globalns parameter to pass the function's global namespace for resolution
- Updated get_dependant() to extract and pass globalns to analyze_param()
- Added comprehensive tests for ForwardRef with Annotated types
The fix handles various scenarios:
- Query parameters with ForwardRef
- Path parameters with ForwardRef
- Header parameters with ForwardRef
- Request body with ForwardRef
- Optional types with ForwardRef
- Multiple annotations with ForwardRef
5 months ago
..
_compat
♻️ Refactor and simplify Pydantic v2 (and v1) compatibility internal utils (#14862)
5 months ago
dependencies
Fix issue #13056: Handle ForwardRef in Annotated types
5 months ago
middleware
📝 Use `WSGIMiddleware` from `a2wsgi` instead of deprecated `fastapi.middleware.wsgi.WSGIMiddleware` (#14756)
5 months ago
openapi
♻️ Refactor and simplify Pydantic v2 (and v1) compatibility internal utils (#14862)
5 months ago
security
🐛 Strip whitespaces from `Authorization` header credentials (#14786)
5 months ago
__init__.py
🔖 Release version 0.128.4
5 months ago
__main__.py
♻️ Add support for `pip install "fastapi[standard]"` with standard dependencies and `python -m fastapi` (#11935)
2 years ago
applications.py
📝 Add links to related sections of docs to docstrings (#14776)
5 months ago
background.py
♻️ Upgrade internal syntax to Python 3.9+ 🎉 (#14564)
7 months ago
cli.py
♻️ Add support for `pip install "fastapi[standard]"` with standard dependencies and `python -m fastapi` (#11935)
2 years ago
concurrency.py
♻️ Upgrade internal syntax to Python 3.9+ 🎉 (#14564)
7 months ago
datastructures.py
➖ Drop support for `pydantic.v1` (#14609)
7 months ago
encoders.py
🎨 Tweak types for mypy (#14816)
5 months ago
exception_handlers.py
⬆️ Upgrade Starlette supported version range to >=0.40.0,<0.49.0 (#14077)
10 months ago
exceptions.py
📝 Add links to related sections of docs to docstrings (#14776)
5 months ago
logger.py
🔊 Refactor logging (#781)
7 years ago
param_functions.py
📝 Add links to related sections of docs to docstrings (#14776)
5 months ago
params.py
➖ Drop support for `pydantic.v1` (#14609)
7 months ago
py.typed
✨ add py.typed to ship typing information (#209)
7 years ago
requests.py
⬆ Require Pydantic > 1.0 (#1862)
6 years ago
responses.py
✨ Add reference (code API) docs with PEP 727, add subclass with custom docstrings for `BackgroundTasks`, refactor docs structure (#10392)
3 years ago
routing.py
♻️ Refactor internals, simplify Pydantic v2/v1 utils, `create_model_field`, better types for `lenient_issubclass` (#14860)
5 months ago
staticfiles.py
✨ Improve type annotations, add support for mypy --strict, internally and for external packages (#2547)
6 years ago
templating.py
✨ Improve type annotations, add support for mypy --strict, internally and for external packages (#2547)
6 years ago
testclient.py
✨ Improve type annotations, add support for mypy --strict, internally and for external packages (#2547)
6 years ago
types.py
🏷️ Re-export `IncEx` type from Pydantic instead of duplicating it (#14641)
5 months ago
utils.py
♻️ Refactor internals, simplify Pydantic v2/v1 utils, `create_model_field`, better types for `lenient_issubclass` (#14860)
5 months ago
websockets.py
✨ Export `WebSocketState` in `fastapi.websockets` (#4376)
4 years ago