schema-prefix-uri

1.0.0 • Public • Published

schema-prefix-uri

returns json-schema with any id's or $ref's prefixed as a uri

install

with npm, do:

npm i --save schema-prefix-uri

example

var schemaPrefixUri = require('schema-prefix-uri');


var agentSchema = {
  id: "Agent",
  oneOf: [{
    $ref: "Person",
  }, {
    $ref: "http://other.org/Group",
  }]
};

var prefix = "http://example.org/";

var prefixedAgentSchema = schemaPrefixUri(prefix, agentSchema);

console.log(JSON.stringify(prefixedAgentSchema, null, 2));
//{
//  "id": "http://example.org/Agent",
//  "oneOf": [
//    {
//      "$ref": "http://example.org/Person"
//    },
//    {
//      "$ref": "http://other.org/Group"
//    }
//  ]
//}

license

AGPLv3

Package Sidebar

Install

npm i schema-prefix-uri

Weekly Downloads

2

Version

1.0.0

License

AGPLv3

Last publish

Collaborators

  • ahdinosaur