Gathering detailed insights and metrics for @readme/json-schema-ref-parser
Gathering detailed insights and metrics for @readme/json-schema-ref-parser
Gathering detailed insights and metrics for @readme/json-schema-ref-parser
Gathering detailed insights and metrics for @readme/json-schema-ref-parser
Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
npm install @readme/json-schema-ref-parser
Typescript
Module System
Node Version
NPM Version
99
Supply Chain
99.6
Quality
82.5
Maintenance
100
Vulnerability
99.6
License
JavaScript (68.65%)
TypeScript (31.3%)
HTML (0.04%)
CSS (0.02%)
Total Downloads
23,197,234
Last Day
12,620
Last Week
254,216
Last Month
1,184,592
Last Year
12,506,621
MIT License
723 Commits
4 Forks
2 Watchers
9 Branches
9 Contributors
Updated on Feb 14, 2025
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
@readme/json-schema-ref-parser@1.2.0
Unpacked Size
135.17 kB
Size
31.27 kB
File Count
23
NPM Version
7.24.2
Node Version
16.14.0
Cumulative downloads
Total Downloads
Last Day
-32.2%
12,620
Compared to previous day
Last Week
-16.8%
254,216
Compared to previous week
Last Month
1.3%
1,184,592
Compared to previous month
Last Year
71.7%
12,506,621
Compared to previous year
Parse, Resolve, and Dereference JSON Schema $ref pointers
You've got a JSON Schema with $ref
pointers to other files and/or URLs. Maybe you know all the referenced files ahead of time. Maybe you don't. Maybe some are local files, and others are remote URLs. Maybe they are a mix of JSON and YAML format. Maybe some of the files contain cross-references to each other.
1{ 2 "definitions": { 3 "person": { 4 // references an external file 5 "$ref": "schemas/people/Bruce-Wayne.json" 6 }, 7 "place": { 8 // references a sub-schema in an external file 9 "$ref": "schemas/places.yaml#/definitions/Gotham-City" 10 }, 11 "thing": { 12 // references a URL 13 "$ref": "http://wayne-enterprises.com/things/batmobile" 14 }, 15 "color": { 16 // references a value in an external file via an internal reference 17 "$ref": "#/definitions/thing/properties/colors/black-as-the-night" 18 } 19 } 20}
JSON Schema $Ref Parser is a full JSON Reference and JSON Pointer implementation that crawls even the most complex JSON Schemas and gives you simple, straightforward JavaScript objects.
$ref
pointers to external files and URLs, as well as custom sources such as databases$ref
pointers$ref
pointers to the same value always resolve to the same object instance1$RefParser.dereference(mySchema, (err, schema) => { 2 if (err) { 3 console.error(err); 4 } else { 5 // `schema` is just a normal JavaScript object that contains your entire JSON Schema, 6 // including referenced files, combined into a single object 7 console.log(schema.definitions.person.properties.firstName); 8 } 9})
Or use async
/await
syntax instead. The following example is the same as above:
1try { 2 const schema = await $RefParser.dereference(mySchema); 3 console.log(schema.definitions.person.properties.firstName); 4} catch(err) { 5 console.error(err); 6}
For more detailed examples, please see the API Documentation
Install using npm:
1npm install @readme/json-schema-ref-parser
When using JSON Schema $Ref Parser in Node.js apps, you'll probably want to use CommonJS syntax:
1const $RefParser = require("@readme/json-schema-ref-parser");
When using a transpiler such as Babel or TypeScript, or a bundler such as Webpack or Rollup, you can use ECMAScript modules syntax instead:
1import $RefParser from "@readme/json-schema-ref-parser";
@apidevtools/json-schema-ref-parser
$ref
pointers may live alongside a description
property. https://github.com/readmeio/json-schema-ref-parser/pull/2$refs.circularRefs
property containing an array of any circular $ref
pointers that may exist within the schema definition.JSON Schema $Ref Parser supports recent versions of every major web browser. Older browsers may require Babel and/or polyfills.
To use JSON Schema $Ref Parser in a browser, you'll need to use a bundling tool such as Webpack, Rollup, Parcel, or Browserify. Some bundlers may require a bit of configuration, such as setting browser: true
in rollup-plugin-resolve.
Full API documentation is available right here
JSON Schema $Ref Parser is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
No vulnerabilities found.
No security vulnerabilities found.