FastAPI 0.140.11 has been released, addressing a bug that affected endpoints with a return type of Iterable[T] when using response_model_* parameters. The issue caused these parameters to be silently ignored for non-generator endpoints, potentially leading to incorrect OpenAPI schemas or documentation.
Changes in this release
- Bug fix:
response_model_*parameters (e.g.,response_model_exclude_unset,response_model_include) are now properly applied to endpoints that returnIterable[...]but do not use a generator function. Previously, these parameters were only respected for generator-based endpoints. - Affects endpoints where the return type annotation is
Iterable[SomeModel]and the function is a regular (non-generator) function. - The fix ensures that the
response_model_*behavior matches the documented expectations.
Impact for developers
If you have endpoints returning an Iterable (like a list) with response_model_* parameters, they will now work correctly. For example, using response_model_exclude_unset=True will exclude unset fields from the response model when the endpoint returns an Iterable. This aligns the handling of Iterable return types with other return types like List[Model] or the model itself.
Notes
- No breaking changes: this is a patch release fixing a specific bug.
- All other
response_model_*behavior remains unchanged.
Source: https://github.com/fastapi/fastapi/releases/tag/0.140.11