$ the-wire · showcase
Optional parameter models for query, header, cookie, and form params
By RepoJournal · Filed · About FastAPI & Pydantic · Composed from the cited sources · methodology
FastAPI landed a cluster of parameter-model changes from tiangolo that make form, query, header, cookie, and path parameters behave consistently with optional models and AliasChoices, while Pydantic's day was docstrings and test hygiene.
✨ Add support for optional query, header, and cookie parameter models fastapi/fastapi
Query, header, and cookie parameter models can now be declared optional, matching what form models could already do. Endpoints that previously had to wrap a model in a manual dependency can move the optionality into the signature.
✨ Add support for optional form models fastapi/fastapi
Form models accept an optional declaration as well, so a body of form fields can be omitted entirely rather than rejected when absent. Worth re-checking any handler that relied on a missing form model being a 422.
🐛 Respect model alias settings for query, header, and cookie parameters fastapi/fastapi
Model alias settings (alias, and the populate-by-name style config) now apply to query, header, and cookie parameters instead of being ignored in favor of the field name. Handlers whose clients send aliased keys stop needing a manual rename step.
🐛 Fix `AliasChoices` for path parameters fastapi/fastapi
AliasChoices now resolves for path parameters, so a Path parameter backed by a union of accepted aliases matches the behavior the other parameter locations already had. The companion fix for form and file AliasChoices also corrects the location reported in validation errors, which changes error payload shape for affected handlers.
Unify `TypeAdapter` serialization methods docstrings pydantic/pydantic
The long tail: Pydantic corrected the round_trip documentation on TypeAdapter.dump_json(), which claimed the method serializes and deserializes when it only calls the serializer, and fixed a UUID in the union serializer tests so generated test IDs are stable.