Expand description
Rust types from component schemas (JSON Schema draft 7, as
draft7_definitions writes them): a struct per object, an enum per string
enumeration, an untagged enum per oneOf or anyOf, an alias per named
string, a type of its own per kind of id, a field per property, optional
where the schema does not require it. It knows the shapes the spec’s schemas use and refuses any other, so a
schema that grows a new shape fails the build rather than generating
something wrong.
A union is untagged, and the first member that decodes is the one meant.
Its members are told apart by what they are — text, a list, an object — or,
between objects, by a single-valued discriminant each carries (status,
kind, code) or by one being the empty object. What the schema says that a type cannot — a pattern, a length, a
bound — is the validators’ to hold at the boundary, before a value is
decoded. A kind of id is the exception: its pattern is written as the
check its only constructor makes, and decoding goes through that
constructor, so a value of the type has always passed its rule.
Structs§
- Generation
- What one generation writes.