pub struct SchemaDocument { /* private fields */ }Expand description
Fully resolved JSON Schema document.
Implementations§
Source§impl SchemaDocument
impl SchemaDocument
Sourcepub fn from_json(raw: &Value) -> Result<Self, AstError>
pub fn from_json(raw: &Value) -> Result<Self, AstError>
Build a resolved schema document from raw JSON Schema.
The resolved graph is built from the canonicalized schema so
compatibility analysis and generation can consume a deterministic IR,
while is_valid() intentionally validates against a backend compiled
from the original raw schema document. Raw backend validation happens
eagerly unless resolver-owned reference features are present, because
those should keep producing the schema frontend’s more precise typed
reference errors during root resolution.
Sourcepub fn root(&self) -> Result<&SchemaNode, AstError>
pub fn root(&self) -> Result<&SchemaNode, AstError>
Return the lazily built resolved root node.
This is the low-level extension point for crates that need the resolved
IR, such as jsoncompat and json_schema_fuzz. Validation callers
should prefer SchemaDocument::is_valid.
Sourcepub fn canonical_schema_json(&self) -> Result<&Value, AstError>
pub fn canonical_schema_json(&self) -> Result<&Value, AstError>
Return the canonicalized JSON Schema document used to build root().
Sourcepub fn source_schema_json(&self) -> &Value
pub fn source_schema_json(&self) -> &Value
Return the original JSON Schema document supplied at construction time.
The compatibility crate uses this to detect valid-but-unmodeled keywords before the canonical semantic IR intentionally drops them.
Sourcepub fn validate_source_schema(&self) -> Result<(), AstError>
pub fn validate_source_schema(&self) -> Result<(), AstError>
Ensure the original JSON Schema document is accepted by the backend Draft 2020-12 validator before downstream tooling reasons about it.