Expand description
JSON Schema reference bundling and inlining.
Prepare $refs in a generated schema before it’s written to disk.
Fully inlined export mode is delegated to the jsonschema crate’s
dereference helper, which sits on top of
referencing — the same ref-resolution
library that the broader JSON Schema validator ecosystem uses. This
gives us battle-tested behaviour for every $ref shape we care about:
- file refs with or without
#/json/pointerfragments - URL refs with or without
#/json/pointerfragments - bare fragment refs (
#/$defs/foo) against the current document - RFC 6901 escapes (
~0,~1) inside pointers - relative-URI resolution against a base
- JSON Schema drafts 4 through 2020-12 (we ship draft-07)
- cycle detection (left in place as
$refstrings rather than recursing forever)
All we own is the jsonschema::Retrieve implementation that maps URIs back to
their content — files from the chart-local filesystem and URLs over
HTTP via ureq, both gated by an explicit fetch policy.
Self-contained output mode keeps use sites as $refs but re-homes
external documents under root-level $defs. For tests, the lower-level
entry points accept any Retrieve impl so callers can wire in an
in-memory map keyed by URI and avoid disk I/O entirely.
Functions§
- bundle_
prepared_ refs - Validate and normalize already-prepared refs without allowing file/URL retrieval.
- bundle_
refs - Resolve external
$refs into root-level$defsentries while preserving internal refs as refs. - bundle_
with_ retriever - Low-level bundling entry point for tests and custom retrievers.
- flatten_
prepared_ refs - Fully inline already-prepared refs without allowing file/URL retrieval.
- flatten_
refs - Inline every
$refinschemaagainst the filesystem rooted atbase_dir. - flatten_
with_ retriever - Low-level dereference entry point: lets callers (most importantly,
tests) plug in a custom
Retrieveso they don’t have to touch the filesystem to exercise the ref-resolution behaviour.