Backplane. JsonSchema. Compiler
(backplane_json_schema v1.10.58)
Copy Markdown
Transforms raw JSON Schema maps into executable Schema structs.
Compilation has two phases:
- Node compilation — Recursively converts keywords into
Rulestructs (serializable rule descriptors), resolves vocabularies, and compiles$defs. - Scope scanning — Discovers all
$idand anchor definitions across the schema tree and registers them by absolute URI for reference resolution.
Standard rules execute first; finalizer rules (unevaluatedProperties,
unevaluatedItems) run last so they can see which keys were already evaluated.
Examples
iex> {:ok, schema} = Backplane.JsonSchema.Compiler.compile(%{"type" => "string"})
iex> length(schema.rules)
1
Summary
Functions
Bundles a JSON Schema fragment into a standalone raw schema document.
Compiles a raw JSON Schema into an executable Schema struct.
Compiles a JSON Schema fragment while preserving its surrounding reference context.
Functions
@spec bundle_fragment(map() | boolean(), keyword()) :: {:ok, map() | boolean()} | {:error, Backplane.JsonSchema.Types.Error.t()}
Bundles a JSON Schema fragment into a standalone raw schema document.
Compiles a raw JSON Schema into an executable Schema struct.
See Backplane.JsonSchema.compile/2 for options and usage.
@spec compile_fragment(map() | boolean(), keyword()) :: {:ok, Backplane.JsonSchema.Types.Schema.t()} | {:error, Backplane.JsonSchema.Types.Error.t()}
Compiles a JSON Schema fragment while preserving its surrounding reference context.
Draft 7 entries inherit ancestor $id bases for node compilation. Discovery
retains the containing document and retrieval base, while JSON Pointer lookup
uses the entry's owning resource, or the containing document if no new resource
is declared.