momoa.engines.pydantic¶
source module momoa.engines.pydantic
Pydantic v2 engine: compiles JSON Schema into pydantic.BaseModel subclasses.
Uses datamodel-code-generator to handle the full JSON Schema → Pydantic mapping, including $ref, $defs, nested objects, arrays, enums, and composition keywords.
Known limitation: dynamically generated models are not pickle-able. Use model_dump() / model_validate() for cross-process serialisation instead of pickle.
Classes
-
PydanticEngine — Compiles JSON Schema into pydantic.BaseModel subclasses.
source class PydanticEngine()
Compiles JSON Schema into pydantic.BaseModel subclasses.
Attributes
-
output_format : str — Engine identifier.
Methods
-
context_labeller — No URI labelling needed; datamodel-code-generator handles naming itself.
-
compile — Compile a JSON Schema spec into BaseModel subclasses with .serialize().
source property PydanticEngine.output_format: str
Engine identifier.
source method PydanticEngine.context_labeller() → None
No URI labelling needed; datamodel-code-generator handles naming itself.
source method PydanticEngine.compile(spec: dict[str, Any], *, root_name: str | None = None) → EngineResult