Breaking Changes
Default Behavior Changes
- New warning emitted by default for unresolved local
$refpointers - By default, an unresolved local$refJSON pointer now emits a newDanglingRefWarningand generates a fallbackAnymodel. Previously such refs resolved to a silent fallback, and some cases (e.g., out-of-range JSON pointer array indices) raised a hard error. Schemas that previously generated cleanly can now produce warnings, which breaks workflows that treat warnings as errors (e.g.,python -W error). Use--strict-refsto fail on unresolved pointers instead, or--disable-warningsto silence them (#3639)
Error Handling Changes
$refto a non-dict file now raisesInvalidFileFormatErrorinstead ofTypeError- Resolving a$refto a JSON/YAML file whose top-level value is not a mapping (e.g., a list) now raisesdatamodel_code_generator.InvalidFileFormatError(a subclass ofError/Exception) rather than the built-inTypeError. Programmatic callers that catchTypeErroraroundgenerate()must catchInvalidFileFormatError(orError) instead (#3639)- Malformed-input diagnostics reworded - Malformed inputs that previously surfaced an uncaught traceback now emit a concise message such as
Invalid file format for <type> at <source>: ..., and the missing-file message changed fromFile not foundtoFile not found: <path>. Tooling that matches on the exact previous strings needs updating (#3639) - Generation now aborts when output paths would overwrite inputs or collide - A new path-conflict validation runs before generation in both the
generate()Python API and the CLI. Invocations that previously succeeded now raise anError(CLI exits with an error code) in these cases: the output path resolves to an existing input file, the--emit-model-metadatapath resolves to an existing input file, or the output and model-metadata paths resolve to the same file. Symlinks and hardlinks are resolved before the comparison. Workflows that intentionally wrote output over an input path, or that pointed the model-metadata artifact at the same path as the output, will now fail with one of:
Output path must not overwrite an input path: <path>
Model metadata path must not overwrite an input path: <path>
Output and model metadata paths must be different: <path>
(#3647)
What's Changed
- Update CHANGELOG for 0.70.0 by @dcg-generated-docs[bot] in #3619
- Decouple RootModel dependency ordering by @koxudaxi in #3620
- Improve README and docs homepage links by @koxudaxi in #3624
- Update release benchmark data by @dcg-generated-docs[bot] in #3625
- Move discriminator policies to output models by @koxudaxi in #3621
- Invalidate generation facts for every list mutation by @koxudaxi in #3622
- Document package manager installation options by @koxudaxi in #3629
- Move dict-key dependency policy to output models by @koxudaxi in #3626
- Decouple parser model behavior helpers by @koxudaxi in #3632
- Share model constraints across output backends by @koxudaxi in #3630
- Move Pydantic type rendering to backend by @koxudaxi in #3627
- Move dataclass ordering policies to output models by @koxudaxi in #3628
- Move template reference metadata to output models by @koxudaxi in #3631
- Declare output model construction capabilities by @koxudaxi in #3623
- Fix payload runtime validation exclusions by @koxudaxi in #3635
- Cover output backends across input formats by @koxudaxi in #3636
- Track large schema memory by @koxudaxi in #3637
- Reuse remote schema connections by @koxudaxi in #3638
- Improve malformed input diagnostics by @koxudaxi in #3639
- Bump setuptools from 82.0.1 to 83.0.0 by @dependabot[bot] in #3633
- Update project usage examples by @koxudaxi in #3641
- Fix vLLM usage link by @koxudaxi in #3642
- Refresh custom template paths by @koxudaxi in #3640
- List project maintainers by @koxudaxi in #3643
- Preserve Unicode line separators by @koxudaxi in #3644
- Fix TypedDict unique item sets by @koxudaxi in #3645
- Defer msgspec forward references by @koxudaxi in #3646
- Validate generation path conflicts by @koxudaxi in #3647
- Enforce dynamic model cache size by @koxudaxi in #3648
- Filter imported dynamic model classes by @koxudaxi in #3649
- Defer nested model default factories by @koxudaxi in #3650
- Isolate generation state by @koxudaxi in #3652
Full Changelog: 0.70.0...0.71.0