Datamodel-code-generator

Latest version: v0.26.5

Safety actively analyzes 702474 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 33

0.21.3

What's Changed
* Give Pydantic V2 its own `dump_resolve_reference_action` to use `model_rebuild` not `update_forward_refs` by lmmx in https://github.com/koxudaxi/datamodel-code-generator/pull/1468
* fix: Fix regex expression of hostname in pydantic v2 by xu-cheng in https://github.com/koxudaxi/datamodel-code-generator/pull/1449
* Add `base_class` validation similar to `_validate_base_class` to bare `generate` calls by kylebebak in https://github.com/koxudaxi/datamodel-code-generator/pull/1453
* Fix issue 1461: Open API parameter models use base class if set by piercsi in https://github.com/koxudaxi/datamodel-code-generator/pull/1462
* Issues 1454 typeddict not required optional bug fix by kylebebak in https://github.com/koxudaxi/datamodel-code-generator/pull/1457

New Contributors
* lmmx made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1468
* xu-cheng made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1449
* kylebebak made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1453
* piercsi made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1462

**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.2...0.21.3

0.21.2

What's Changed
* Pre-commit-hooks by yehoshuadimarsky in https://github.com/koxudaxi/datamodel-code-generator/pull/1416
* feat: add additional imports by skonik in https://github.com/koxudaxi/datamodel-code-generator/pull/1422
* Add orm_mode to Config(BaseModel) by Beaueve in https://github.com/koxudaxi/datamodel-code-generator/pull/1425
* Fix "parent" AttributeError when calling --collapse-root-models by imankulov in https://github.com/koxudaxi/datamodel-code-generator/pull/1432

New Contributors
* yehoshuadimarsky made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1416
* skonik made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1422
* Beaueve made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1425
* imankulov made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1432

**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.1...0.21.2

0.21.1

What's Changed
* Relax version constraint of prance by tetsuok in https://github.com/koxudaxi/datamodel-code-generator/pull/1409
* Fix optional field doesn't include `None` by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1411

New Contributors
* tetsuok made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1409

**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.21.0...0.21.1

0.21.0

What's Changed
* pyproject: correct poetry-core package name by ConnorBaker in https://github.com/koxudaxi/datamodel-code-generator/pull/1374
* Support pydantic v2 in runtime by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1392
* Add pydantic v2 as output model type by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1391
* Add --use-unique-items as set by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1400

New Contributors
* ConnorBaker made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1374

What is the difference between pydantic v1 and v2 output model?

Summary
datamodel-code-generator supports Pydantic v1 and v2 as output model type.

Pydantic v2 is a major release with many breaking changes. See the migration guide for more information:
https://docs.pydantic.dev/2.0/migration/

What's changes in v2 output?
`__root__` field (a.k.a [Custom Root Types](https://docs.pydantic.dev/1.10/usage/models/#custom-root-types))
`__root__` field (a.k.a [Custom Root Types](https://docs.pydantic.dev/1.10/usage/models/#custom-root-types)) is removed in pydantic v2.
The model is changed to [RootModel](https://docs.pydantic.dev/latest/usage/models/#rootmodel-and-custom-root-types)

pydantic.Field
https://docs.pydantic.dev/2.0/migration/#changes-to-pydanticfield

- const -> removed
- min_items (use min_length instead)
- max_items (use max_length instead)
- unique_items -> removed and the list type will be replaced by `typing.Set`. this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296
- allow_mutation (use frozen instead)
- regex (use pattern instead)

Model Config
- `pydantic.Config` -> `pydantic.ConfigDict`
- allow_mutation —> frozen (inverse value for getting same behavior).
- allow_population_by_field_name → populate_by_name



**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.20.0...0.21.0

0.20.0

What's Changed
* Update documentation by noddycode in https://github.com/koxudaxi/datamodel-code-generator/pull/1316
* Support TypedDict as output type by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1309
* Remove self attribute from jsonschema root attributes by rezen in https://github.com/koxudaxi/datamodel-code-generator/pull/1318
* Fix $ref With Path Items by zach-hamm in https://github.com/koxudaxi/datamodel-code-generator/pull/1323
* Remove keep-runtime-typing on ruff config by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1349
* Update `openapi-spec-validator` to `0.5.2` by Fokko in https://github.com/koxudaxi/datamodel-code-generator/pull/1343
* Added support for model wise base classes by senesh-deshan in https://github.com/koxudaxi/datamodel-code-generator/pull/1350
* Fix the custom file header by Fokko in https://github.com/koxudaxi/datamodel-code-generator/pull/1346

Breaking Changes
* Eliminate the naming differences of model names and field names by the OS by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1348

Due to differences in file loading order between operating systems, we've added a sorting process when fetching file listings within directories in order to eliminate discrepancies in model and field names. As a result, model names that differ from those generated by existing earlier versions may be produced.

New Contributors
* noddycode made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1316
* rezen made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1318
* zach-hamm made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1323
* Fokko made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1343
* senesh-deshan made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1350

**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.19.0...0.20.0

0.19.0

What's Changed
* Import Annotated from typing_extensions for Python <= 3.8 by airwoodix in https://github.com/koxudaxi/datamodel-code-generator/pull/1274
* Fix OpenAPI array response by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1261
* Fix unresolved nested ref in openapi by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1269
* Fix unsorted dataclass field by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1288
* Fix allOf-anyOf by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1291
* Fix null by koxudaxi in https://github.com/koxudaxi/datamodel-code-generator/pull/1299

New Contributors
* airwoodix made their first contribution in https://github.com/koxudaxi/datamodel-code-generator/pull/1274

**Full Changelog**: https://github.com/koxudaxi/datamodel-code-generator/compare/0.18.1...0.19.0

Page 5 of 33

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.