Expand description
Python model generation.
Emits a models.py of stdlib dataclasses with JSON round-tripping, one
dataclass per model and one Literal alias per string union.
§Why dataclasses rather than pydantic
Generated code inherits its dependencies onto every consumer. A schema
describing a file format (the motivating case is a DAW project document)
wants to be loadable in a notebook, a build script, or a CI job without
pulling a validation framework in first. Dataclasses are stdlib, and
from_dict/to_dict cover the round trip that matters.
The cost is that this validates nothing beyond shape: an out-of-range value that the JSON Schema would reject is preserved as-is. Constraints in the IR are emitted as comments so they are visible, not enforced.
§Ordering
Definitions are emitted in dependency order where possible, and forward
references fall back to from __future__ import annotations, which makes
every annotation lazy and cycles harmless.
Functions§
- generate
- Generate Python models for a schema.