JSPM

schema-deref

2.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q42094F
  • License AGPLv3

returns json-schema with any $ref's de-referenced

Package Exports

  • schema-deref

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (schema-deref) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

schema-deref

returns json-schema with any $ref's de-referenced

install

with npm, do:

npm i --save schema-deref

example

var schemaDeRef = require('schema-deref');

var resourceSchema = {
  id: "http://example.org/Resource#",
  properties: {
    name: {
      type: "string",
    },
  },
};

var personSchema = {
  id: "http://example.org/Person#",
  properties: {
    name: {
      type: "string",
    },
    resources: {
      type: 'array',
      items: {
        $ref: "http://example.org/Resource#",
      },
    },
  },
};

var schemas = {};
schemas[resourceSchema.id] = resourceSchema;
schemas[personSchema.id] = personSchema;

var derefd = schemaDeRef(schemas, personSchema);

console.log(JSON.stringify(derefd, null, 2));
//{
//  "id": "http://example.org/Person#",
//  "properties": {
//    "name": {
//      "type": "string"
//    },
//    "resources": {
//      "type": "array",
//      "items": {
//        "id": "http://example.org/Resource#",
//        "properties": {
//          "name": {
//            "type": "string"
//          }
//        }
//      }
//    }
//  }
//}

license

AGPLv3