Browse Source
When a type annotation uses a string literal inside Annotated, e.g.
Annotated['Potato', Depends(get_potato)], Python stores it as
Annotated[ForwardRef('Potato'), Depends(get_potato)] at runtime.
get_typed_annotation only handled the case where the annotation itself
is a string/ForwardRef. It did not recurse into Annotated's first
argument. As a result, the ForwardRef was never resolved, FastAPI
could not identify the type, and the parameter was treated as Any,
producing an incorrect OpenAPI schema.
Fix by also handling the case where annotation is ForwardRef directly
(not wrapped in a string), and by recursively resolving any
ForwardRef found as the first argument of an Annotated type.
Fixes #13056
pull/15364/head
committed by
Ofek Danny
1 changed files with 14 additions and 1 deletions
Loading…
Reference in new issue