Socket
Socket
Sign inDemoInstall

@bcherny/json-schema-ref-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bcherny/json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers


Version published
Maintainers
1
Created

What is @bcherny/json-schema-ref-parser?

@bcherny/json-schema-ref-parser is a powerful library for parsing, resolving, and dereferencing JSON Schema $ref pointers. It helps in handling complex JSON schemas with references to other schemas, either local or remote.

What are @bcherny/json-schema-ref-parser's main functionalities?

Dereferencing

Dereferencing resolves all $ref pointers in the schema, replacing them with the actual referenced values. This is useful for working with a fully resolved schema.

const $RefParser = require('@bcherny/json-schema-ref-parser');

const schema = {
  "$ref": "http://example.com/schema.json"
};

$RefParser.dereference(schema)
  .then(dereferencedSchema => {
    console.log(dereferencedSchema);
  })
  .catch(err => {
    console.error(err);
  });

Bundling

Bundling resolves all $ref pointers in the schema, but keeps the references intact. This is useful for creating a single schema file that contains all referenced schemas.

const $RefParser = require('@bcherny/json-schema-ref-parser');

const schema = {
  "$ref": "http://example.com/schema.json"
};

$RefParser.bundle(schema)
  .then(bundledSchema => {
    console.log(bundledSchema);
  })
  .catch(err => {
    console.error(err);
  });

Resolving

Resolving retrieves all referenced files and schemas, but does not dereference them. This is useful for understanding the structure and dependencies of a schema.

const $RefParser = require('@bcherny/json-schema-ref-parser');

const schema = {
  "$ref": "http://example.com/schema.json"
};

$RefParser.resolve(schema)
  .then(resolvedSchema => {
    console.log(resolvedSchema);
  })
  .catch(err => {
    console.error(err);
  });

Other packages similar to @bcherny/json-schema-ref-parser

Keywords

FAQs

Package last updated on 23 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc