JavaScript library that resolves $ref references in JSON Schemas, part of the Fastify ecosystem. Current stable version is 3.0.0, released with TypeScript type definitions and following semver. It resolves internal and external schema references, supports dereferencing, and provides schema dependency tracking. Unlike json-schema-ref-parser, it is lightweight, synchronous, and focused on Fastify-like use cases. Key differentiators: no dependencies, simple API, and support for circular references with optional Symbol insertion.
npm install json-schema-ref-resolverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates adding two schemas (one referencing the other via $ref), then retrieving the dereferenced schema where the reference is replaced by the actual type.
Set allowEqualDuplicates: false in constructor options to enforce strict unique $id.
Wrap getSchema() calls in try/catch when not using jsonPointer, or always provide jsonPointer and check for null.
If you rely on strict schema id uniqueness, explicitly set allowEqualDuplicates: false.
Use import { RefResolver } from 'json-schema-ref-resolver' in ESM, or const { RefResolver } = require('json-schema-ref-resolver') in CJS.Ensure unique $id values per schema, or set allowEqualDuplicates: true in the constructor (default).
No dependency data recorded yet.