Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-ref-resolver

Package Overview
Dependencies
Maintainers
9
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-ref-resolver

JSON schema reference resolver

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created

What is json-schema-ref-resolver?

The json-schema-ref-resolver npm package is a utility for resolving JSON Schema $ref references. It allows you to dereference, bundle, and resolve JSON Schema references, making it easier to work with complex schemas that have multiple references.

What are json-schema-ref-resolver'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 expanded schema.

const $RefParser = require('json-schema-ref-resolver');

const schema = {
  properties: {
    name: { $ref: '#/definitions/name' }
  },
  definitions: {
    name: { type: 'string' }
  }
};

$RefParser.dereference(schema, (err, dereferencedSchema) => {
  if (err) {
    console.error(err);
  } else {
    console.log(dereferencedSchema);
  }
});

Bundling

Bundling resolves all external $ref pointers and bundles them into a single schema. This is useful for creating a self-contained schema that doesn't rely on external files.

const $RefParser = require('json-schema-ref-resolver');

const schema = {
  properties: {
    name: { $ref: 'definitions.json#/name' }
  }
};

$RefParser.bundle(schema, (err, bundledSchema) => {
  if (err) {
    console.error(err);
  } else {
    console.log(bundledSchema);
  }
});

Resolving

Resolving retrieves and parses all referenced files, but does not replace the $ref pointers. This is useful for understanding the structure and dependencies of a schema without modifying it.

const $RefParser = require('json-schema-ref-resolver');

const schema = {
  properties: {
    name: { $ref: 'definitions.json#/name' }
  }
};

$RefParser.resolve(schema, (err, resolvedSchema) => {
  if (err) {
    console.error(err);
  } else {
    console.log(resolvedSchema);
  }
});

Other packages similar to json-schema-ref-resolver

Keywords

FAQs

Package last updated on 04 Sep 2024

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