JSONSchex.ScopeScanner (jsonschex v0.5.0)

Copy Markdown View Source

Scans a raw schema tree to discover all $id, $anchor, and $dynamicAnchor definitions, resolving them against parent base URIs to build a registry of absolute URI → raw schema mappings.

The resulting registry is used by JSONSchex.Compiler to populate the defs field in the compiled Schema, enabling reference resolution during validation.

Examples

iex> schema = %{
...>   "$id" => "https://example.com/schema",
...>   "$defs" => %{
...>     "user" => %{"$id" => "user", "type" => "object"}
...>   }
...> }
iex> registry = JSONSchex.ScopeScanner.scan(schema)
iex> Map.has_key?(registry, "https://example.com/schema")
true
iex> Map.has_key?(registry, "https://example.com/user")
true

Summary

Functions

Scans a raw schema and returns a tuple {registry, refs} where

Functions

scan(schema)

Scans a raw schema and returns a tuple {registry, refs} where:

  • registry is a map of {absolute_uri => raw_schema}.
  • refs is a MapSet of explicitly defined references.