The FastAPI team has released version 0.140.8, a patch release that addresses a critical bug introduced in a prior update. The fix focuses on preserving stream item type metadata when routes are included via include_router().
- Bug Fix: A bug caused stream item types to be lost when using
include_router(). Specifically, when a router defined a streaming response with a type annotation (e.g.,List[Item]), the type information was not carried over to the parent application after inclusion. This affected auto-generated OpenAPI schemas and client code generation. PR #15077 by @alex-raw resolves this issue. - No Other Changes: This release contains only this one fix; no new features or other modifications were introduced.
For developers using streaming responses (e.g., StreamingResponse) across modular applications with include_router(), this fix ensures that the OpenAPI documentation accurately reflects the response model. Without it, clients generated from the spec would miss type hints, leading to potential runtime errors or incomplete API contracts. The bug was subtle, as it only manifested when the type was defined on the router level, not inline in the path operation decorator.
To upgrade, run: pip install fastapi --upgrade. This patch is recommended for all projects that organize routes via include_router() and rely on streaming response schemas.
Source: https://github.com/fastapi/fastapi/releases/tag/0.140.8