Schematrix user manual

schematrix reads JSON Schema documents and writes Ruby classes with type signatures. It runs as a CLI (schematrix) and as a library (Schematrix.generate).

This manual covers everything the tool does. The README gives the short version; the API pages under Schematrix in this reference document every public class and method.

How a run works

  1. You pass one or more schema documents (JSON or YAML) and pick one or more generators.

  2. The compiler loads each document, checks its $schema dialect, and walks every schema node reachable from the roots, following $ref edges. Each object schema it finds becomes a compiled record.

  3. Each generator turns the records into source files, one file per class, and formats them with SyntaxTree.

Nothing is fetched from the network. A schema URI that points at another host resolves to a local file through schema directories (--schema-dir).

The design rule

Generated code represents every instance the schema accepts. A schema feature with no exact Ruby rendering widens the generated type instead of narrowing acceptance. The generated classes do not validate: they shape data. Constraints such as pattern, minimum, or minLength never reach the output. format is the exception: a scalar format the scalar type table maps changes the slot’s Ruby type and converts its values on load and dump (see Schema features).

Manual contents