Breaking Changes
Code Generation Changes
--use-defaultno longer makes required fields nullable - Previously,--use-defaultturned required fields into optional nullable fields (e.g.,status: str | None = 'active'). Now required fields keep their original non-nullable type and just get the default value rendered (e.g.,status: str = 'active'). Users whose downstream code depends on these fields beingOptional/nullable will need to update. (#3054)- Required model-ref fields no longer render defaults without
--use-default- Previously, required fields referencing models (e.g.,shipping_address: Address) inconsistently rendered defaults withvalidate_default=Truewhile scalar required fields did not. Now all required fields consistently omit defaults unless--use-defaultis passed. Users who relied on the previous behavior where model-ref required fields had defaults rendered will see those defaults removed. (#3054)
Custom Template Update Required
- Built-in Jinja2 templates now use
field.use_default_with_required- The built-in templates forBaseModel,dataclass,pydantic_v2/dataclass, andmsgspecwere updated to checkfield.use_default_with_requiredalongsidefield.requiredwhen deciding whether to render defaults. Custom templates that replicate the old default-rendering logic (e.g.,{%- if not field.required %}) will still work but won't support the new--use-defaultbehavior for required fields. To get the updated behavior, custom templates should change conditions likenot field.requiredto(not field.required or field.use_default_with_required). (#3054)
What's Changed
- Harden workflow credentials by @koxudaxi in #3095
- Fix release automation workflows by @koxudaxi in #3110
- Enforce shared assertions in e2e tests by @koxudaxi in #3108
- Fix docs preview required check by @koxudaxi in #3112
- Fix required field default rendering and --use-default nullable types by @butvinm in #3054
- Remove unused CLI doc schema version lookup by @koxudaxi in #3113
- Fix byte to binary type mapping by @koxudaxi in #3114
- Create generated docs sync PRs by @koxudaxi in #3117
- Support local HTTP ref paths by @koxudaxi in #3116
- Fix reuse discriminator literals by @koxudaxi in #3115
- docstrings that can be single line to be formatted on a single line by @kevin-paulson-mindbridge-ai in #3107
- Fix indefinite hang on OpenAPI schemas with cyclic model dependencies by @kevin-paulson-mindbridge-ai in #3078
- Add OpenAPI enum literal alias regression test by @koxudaxi in #3124
- Fix pydantic model extra warnings by @koxudaxi in #3127
- Fix snake case array discriminator by @koxudaxi in #3125
- Fix serialization alias choices by @koxudaxi in #3126
- Fix generated docs sync prompt snapshots by @koxudaxi in #3129
- Add manual generated docs sync trigger by @koxudaxi in #3130
- Use source tree for generated prompt snapshots by @koxudaxi in #3132
- Propagate enum member descriptions for anyOf const pattern by @mvanhorn in #3133
- Allow generated prompt snapshot updates by @koxudaxi in #3134
- Write generated prompt snapshots directly by @koxudaxi in #3135
- Preserve tox python preference for generated docs by @koxudaxi in #3136
- Sync generated docs by @dcg-generated-docs[bot] in #3137
New Contributors
- @mvanhorn made their first contribution in #3133
- @dcg-generated-docs[bot] made their first contribution in #3137
Full Changelog: 0.56.1...0.57.0