Breaking Changes
- Discriminated unions with duplicate or unresolvable discriminator values now fall back to a plain union - When a discriminated union contains variants that resolve to the same discriminator value, or variants that are containers,
RootModel/type-alias wrappers,None/strmembers, or otherwise lack a resolvable discriminator literal, the generator no longer emitsField(..., discriminator='...')and instead produces a regular union. Previously such schemas emitted adiscriminator=argument. Users regenerating models from these schemas will see thediscriminatorkeyword removed from the affected fields (#3603)
# Before (invalid duplicate-value discriminator was emitted):
class GroupedItem(RootModel[Item | ItemReference]):
root: Item | ItemReference = Field(..., discriminator='type')
# After (falls back to a plain union when variants are not valid discriminated members):
class MixedItem(RootModel[str | ItemReference | None]):
root: str | ItemReference | NoneWhat's Changed
- Update CHANGELOG for 0.68.1 by @dcg-generated-docs[bot] in #3594
- Update release benchmark data by @dcg-generated-docs[bot] in #3595
- Skip unused formatter construction by @koxudaxi in #3599
- Retain model import caches by @koxudaxi in #3600
- Fix pydantic typed extra runtime compatibility by @koxudaxi in #3601
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci[bot] in #3605
- Fix legacy pydantic extra templates by @koxudaxi in #3602
- Handle duplicate discriminator values by @koxudaxi in #3603
- Bump the github-actions group across 1 directory with 7 updates by @dependabot[bot] in #3598
- Allow custom and generated file headers by @koxudaxi in #3607
- Fix payload runtime validation exclusions by @koxudaxi in #3609
- Fix optional discriminator literals by @koxudaxi in #3608
- Fix invalid dotted model names by @koxudaxi in #3610
- Add multi-module stdout guard by @koxudaxi in #3611
- Fix empty ("") property name dropping its alias by @chuenchen309 in #3612
New Contributors
- @chuenchen309 made their first contribution in #3612
Full Changelog: 0.68.1...0.69.0