Breaking Changes
Python Version
- Python 3.9 support dropped - Minimum Python version is now 3.10+ (#2692)
Default Behavior Changes
- Native type hints by default -
list[...]/dict[...]are now used instead ofList[...]/Dict[...]. Use--no-use-standard-collectionsto restore previous behavior (#2699) - Union operator by default -
X | Ysyntax is now used instead ofUnion[X, Y]/Optional[X]. Use--no-use-union-operatorto restore previous behavior (#2703)
Code Generation Changes
- Nullable required fields no longer have default values (Pydantic v2) - Fields marked as both
requiredandnullableno longer get= None. Thepydantic_v2/BaseModel.jinja2template logic was updated to only assign default values whenfield.requiredis false. This fixes incorrect behavior where required fields could be omitted (#2520) - TypedDict respects enum_field_as_literal setting - TypedDict output now respects user's
--enum-field-as-literalsetting instead of forcingall. Added new--enum-field-as-literal noneoption (#2691) - prefixItems now generates tuple types - JSON Schema
prefixItemswith matchingminItems/maxItemsand noitemsnow generatestuple[T1, T2, ...]instead oflist[...]. This applies when the array has a fixed length with heterogeneous types (#2537)
What's Changed
- feat: Add --use-status-code-in-response-name option by @koxudaxi in #2688
- feat: Add support for number type with time-delta format by @koxudaxi in #2689
- docs: Add CHANGELOG.md with auto-update workflow by @koxudaxi in #2690
- feat: Add --enum-field-as-literal none option and respect user settings for TypedDict by @koxudaxi in #2691
- docs: Clarify default encoding behavior in documentation by @koxudaxi in #2693
- ci: Improve CLI docs generation workflow by @koxudaxi in #2695
- feat(docs): Group CLI examples by schema type with tabs by @koxudaxi in #2696
- feat: Add --ignore-enum-constraints option by @koxudaxi in #2694
- Add zensical.toml configuration by @koxudaxi in #2697
- fix: Make docs generation deterministic by sorting glob results and dict iterations by @koxudaxi in #2698
- feat: Drop Python 3.9 support, require Python 3.10+ by @koxudaxi in #2692
- fix: Update zensical dependency version to 0.0.13 for Python 3.10+ by @koxudaxi in #2700
- feat: Default to native list/dict type hints instead of typing.List/Dict by @koxudaxi in #2699
- fix: Remove unnecessary pass statement when nested class exists by @koxudaxi in #2704
- build: Replace pre-commit with prek by @koxudaxi in #2702
- fix: Improve state management in Imports, DataType, and DataModel classes by @koxudaxi in #2705
- feat: Default to union operator for type hints by @koxudaxi in #2703
- fix: handle fork PRs in lint workflow by @koxudaxi in #2706
- fix: handle fork PRs in readme and cli-docs workflows by @koxudaxi in #2707
- Nullable required fields should not have default value by @raymondbutcher in #2520
- Add support for prefixItems to emit tuples by @saulshanabrook in #2537
- Remove unnecessary flags from --check test by @koxudaxi in #2708
- fix: update expected files to use modern union type syntax (
str | None) by @koxudaxi in #2709 - fix: trigger docs build after changelog update by @koxudaxi in #2710
New Contributors
- @raymondbutcher made their first contribution in #2520
- @saulshanabrook made their first contribution in #2537
Full Changelog: 0.45.0...0.46.0