- Defaults for omitted Query, Header, Cookie, and Form parameters and model fields are no longer treated as user input and are not validated unless validate_default=True is enabled behavior changed · inferred, marked in the notes below
- Body(validate_default=True) is now honored
- Applying a default to a parameter model no longer marks the field as explicitly set, so model_dump(exclude_unset=True) excludes it behavior changed · inferred, marked in the notes below
- Default factories run once
- Validation errors no longer include injected defaults in the input
- Default handling for request parameters and models
2 changes to check, marked in the notes below
From FastAPI
Defaults for omitted Query, Header, Cookie, and Form parameters and model fields are no longer treated as user input. Defaults are not validated unless validate_default=True is enabled. If you rely on validators running for omitted values, enable default validation with Field(validate_default=True) for model fields or, for example, Query(validate_default=True) for individual parameters. Body(validate_default=True) is now honored too. behavior changed · inferred
For parameter models, applying a default no longer marks a field as explicitly set, so model_dump(exclude_unset=True) excludes it. Default factories run once, and validation errors no longer include injected defaults in input. behavior changed · inferred
Omitted boolean form fields still become False and count as explicitly set.