github koxudaxi/datamodel-code-generator 0.21.0

latest releases: 0.33.0, 0.32.0, 0.31.2...
2 years ago

What's Changed

New Contributors

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)

__root__ field (a.k.a Custom Root Types) is removed in pydantic v2.
The model is changed to RootModel

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 pydantic/pydantic-core#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: 0.20.0...0.21.0

Don't miss a new datamodel-code-generator release

NewReleases is sending notifications on new releases.