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

deref

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deref

JSON-Schema $ref resolution

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by9.78%
Maintainers
1
Weekly downloads
 
Created
Source

Do you have $ref's ?

A simple way for solving $ref values:

var deref = require('deref');

var $ = deref();

var schema = {
  id: 'http://x.y.z/rootschema.json#',
  schema1: {
    id: '#foo'
  },
  schema2: {
    id: 'otherschema.json',
    nested: {
      id: '#bar'
    },
    alsonested: {
      id: 't/inner.json#a'
    }
  },
  schema3: {
    id: 'some://where.else/completely#'
  }
};

console.log($(schema).schema2.nested.id);
// output: http://x.y.z/otherschema.json#bar

Basic usage

The resulting function of calling deref() can accept three arguments:

  • fakeroot (string)

    Used on missing $schema values for resolve into fully qualified URIs.

    console.log($('http://example.com', { id: '#foo' }).id);
    // output: http://example.com#foo
    

    If missing will use http://json-schema.org/schema.

  • schema (object)

    The JSON-Schema object for dereferencing.

  • refs (array)

    Any additional schemas used while dereferencing.

Utilities

Aside the basics of $, this function will include:

  • $.refs (object)

    An registry of dereferenced schemas.

  • $.util (object)

    Exposes the internal helpers used by deref.

    • isURL(path)
    • parseURI(href)
    • resolveURL(base, href)
    • getDocumentURI(path)
    • cloneSchema(schema, refs, id)
    • normalizeSchema(fakeroot, schema)

Note that calling $(schema) will not read/download any local/remote files.

Build Status

FAQs

Package last updated on 11 Oct 2014

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