momoa.model [source] ¶
module momoa.model
Base wrapper class for building JSONSchema based models.
Classes
-
Model — Base model class.
Functions
-
_serialize_schema_value — Helper function to recursively serialize schema values.
momoa.model.Model [source] ¶
class Model(**data)
Base model class.
Raises
Methods
-
_format — Converts Python native values to JSONSchema string equivalents on the fly.
-
_unformat — Converts JSONSchema formatted string values to Python native on the fly.
-
serialize — Validates data and serializes it into JSON-ready format.
-
make_model — Constructs a Model subclass based on the class derived from JSONSchema.
momoa.model.Model._format [source] ¶
method Model._format(field: str, value: Any) → str
Converts Python native values to JSONSchema string equivalents on the fly.
momoa.model.Model._unformat [source] ¶
method Model._unformat(field: str, value: str) → Any
Converts JSONSchema formatted string values to Python native on the fly.
momoa.model.Model.serialize [source] ¶
method Model.serialize()
Validates data and serializes it into JSON-ready format.
momoa.model.Model.make_model [source] ¶
staticmethod Model.make_model(schema_class: meta.ObjectMeta, string_formatter=StringFormat) → type[Model]
Constructs a Model subclass based on the class derived from JSONSchema.
Parameters
-
schema_class : meta.ObjectMeta — Class derived from the JSONSchema.
-
string_formatter — Class used to format strings.
Returns
-
type[Model] — Subclass of the Model class.