2026-09-22 · 6 min read · Rahul Chitturi
- json-schema
- validation
- debugging
$dynamicRef and $dynamicAnchor let a JSON Schema extension point resolve through the active chain of referenced resources. They are useful for recursive, extensible schemas, but a small change to a resource identifier or reference path can select a different anchor than expected.
A schema that works in one validator may fail elsewhere when the dialect, vocabulary support, registry, or bundling behavior differs.
Map resources before instances
Record each schema resource's $id, base URI, dialect, dynamic anchors, ordinary anchors, and references. Resolve the initial target first, then trace the dynamic scope used by the selected dialect.
- Use exact, case-sensitive anchor names.
- Give bundled resources stable absolute identifiers.
- Do not treat $dynamicRef as a text substitution.
- Surface unsupported dialects instead of ignoring keywords.
Reduce the extension chain
Build a minimal base schema, one extending resource, and one failing instance. Compare the result with an ordinary $ref so the problem is clearly dynamic resolution rather than an unrelated object or recursion rule.
Capture evaluated locations and error paths from the validator when available. A final error can occur far below the reference that selected the active extension point.
Test portable public fixtures
Use Flashman's JSON formatter for schemas and instances, diff for identifier changes, URL tool for public resource URIs, and YAML converter for configuration copies.
Test missing and duplicate anchors, nested resources, recursive arrays and objects, bundled and remote schemas, relative identifiers, dialect mismatch, unresolved references, deep inputs, and validator upgrades.