FastAPI has published release 0.158.2, a small but targeted update that adds a new feature to the form-handling side of the framework. According to the release notes, the headline change is support for optional form models, contributed in PR #16582 by @tiangolo. The release is otherwise presented as a feature release rather than a patch focused on fixes, so the form-model capability is the item developers should pay attention to when upgrading.
Concrete changes in this release:
- Optional form models are now supported, so a form body declared as a model can be treated as optional in an endpoint's signature instead of being required on every request.
- The feature landed via PR
#16582, authored by@tiangolo, and is listed under the Features section of the 0.158.2 release notes. - No additional changes are described in the provided release excerpt beyond this form-model support entry.
Why this matters: FastAPI's form parsing has traditionally required developers to choose between declaring a full Pydantic model for structured form data or falling back to individual Form(...) parameters when a submission could be absent. Optional form models close that gap, letting teams keep model-based validation and documentation for endpoints where the form payload is legitimately skippable — for example, partial updates submitted as form data or endpoints that accept a form only in some client flows. Because the model remains the unit of validation, generated OpenAPI schemas and editor type hints should continue to reflect the expected field structure, while the request itself no longer has to include the form. Developers relying on form-heavy endpoints, such as HTML form submissions or file-adjacent workflows, should review the release notes and confirm their router signatures behave as expected after bumping to [email protected]. As always, pin the version in your dependency file and run your existing request-validation tests before rolling the change into production services.
Source: https://github.com/fastapi/fastapi/releases/tag/0.158.2