There are special use-cases that each language supports; this document pertains to Python models.
The generated Python models require at least v3.7.
In some cases you might want to use pydantic data validation and settings management using Python type hints for the models. Modelina follows Pydantic v2.
There are some limitations to the current implementation:
- The preset doesn't unwrap properties of type
ConstrainedDictionaryModel
withserialilzationType = unwrap
, they are simply excluded from the serialization
You can find an example of its use here
Using the preset PYTON_JSON_SERIALIZER
, you can generate serializeToJson
method to convert model instance to JSON and deserializeFromJson
method to convert JSON to model instance.
- Above preset doesn't unwrap properties of type
ConstrainedDictionaryModel
withserialilzationType = unwrap
- The serialized JSON object will have the same property names as defined in the model object.
Check out this example for a live demonstration.