Gathering detailed insights and metrics for @apidevtools/json-schema-ref-parser
Gathering detailed insights and metrics for @apidevtools/json-schema-ref-parser
Gathering detailed insights and metrics for @apidevtools/json-schema-ref-parser
Gathering detailed insights and metrics for @apidevtools/json-schema-ref-parser
Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
npm install @apidevtools/json-schema-ref-parser
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
960 Stars
699 Commits
229 Forks
9 Watching
14 Branches
48 Contributors
Updated on 26 Nov 2024
TypeScript (99.61%)
JavaScript (0.35%)
HTML (0.03%)
CSS (0.01%)
Cumulative downloads
Total Downloads
Last day
-3.3%
842,937
Compared to previous day
Last week
3.3%
4,333,302
Compared to previous week
Last month
15.2%
17,987,830
Compared to previous month
Last year
49%
168,075,586
Compared to previous year
3
23
Install using npm:
1npm install @apidevtools/json-schema-ref-parser 2yarn add @apidevtools/json-schema-ref-parser 3bun add @apidevtools/json-schema-ref-parser
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
instance1import $RefParser from "@apidevtools/json-schema-ref-parser"; 2 3try { 4 await $RefParser.dereference(mySchema); 5 // note - by default, mySchema is modified in place, and the returned value is a reference to the same object 6 console.log(mySchema.definitions.person.properties.firstName); 7 8 // if you want to avoid modifying the original schema, you can disable the `mutateInputSchema` option 9 let clonedSchema = await $RefParser.dereference(mySchema, { mutateInputSchema: false }); 10 console.log(clonedSchema.definitions.person.properties.firstName); 11} catch (err) { 12 console.error(err); 13}
For more detailed examples, please see the API Documentation
If you are using Node.js < 18, you'll need a polyfill for fetch
,
like node-fetch:
1import fetch from "node-fetch"; 2 3globalThis.fetch = fetch;
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.
Webpack 5 has dropped the default export of node core modules in favour of polyfills, you'll need to set them up
yourself ( after npm-installing them )
Edit your webpack.config.js
:
1config.resolve.fallback = { 2 path: require.resolve("path-browserify"), 3 fs: require.resolve("browserify-fs"), 4}; 5 6config.plugins.push( 7 new webpack.ProvidePlugin({ 8 Buffer: ["buffer", "Buffer"], 9 }), 10);
Full API documentation is available right here
I welcome any contributions, enhancements, and bug-fixes. Open an issue on GitHub and submit a pull request.
To build/test the project locally on your computer:
Clone this repo
git clone https://github.com/APIDevTools/json-schema-ref-parser.git
Install dependencies
yarn install
Run the tests
yarn test
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.
Thanks to these awesome companies for their support of Open Source developers ❤
The latest stable version of the package.
Stable Version
1
8.1/10
Summary
json-schema-ref-parser Prototype Pollution issue
Affected Versions
>= 11.0.0, <= 11.1.0
Patched Versions
11.2.0
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
8 existing vulnerabilities detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@bcherny/json-schema-ref-parser
Parse, Resolve, and Dereference JSON Schema $ref pointers
@apidevtools/swagger-parser
Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers
@stoplight/json-schema-ref-parser
Parse, Resolve, and Dereference JSON Schema $ref pointers
swagger-parser
Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers