json-schema-load-tree
v0.2.0
Published
Load a schema and all child references
Downloads
5
Maintainers
Readme
json-schema-load-tree
Loads all references in a json schema, recursively. Currently a work in progress.
Installation:
npm install json-schema-load-tree
Usage:
example.js
import jsonSchemaLoadTree from 'json-schema-load-tree';
jsonSchemaLoadTree("http://www.example.com/blog-post.json")
.then(result => console.log(result));
Output:
{
"http://www.example.com/blog-post.json": {
"id": "http://www.example.com/blog-post.json",
"type": "object",
"properties": {
"id": { "type": "number" },
"author": { "type": "string" },
"title": { "type": "string" },
"body": { "type": "string" },
"metadata": { "$ref": "http://www.example.com/metadata.json" }
},
"required": [ "title", "author", "id" ]
},
"http://www.example.com/metadata.json": {
"id": "http://www.example.com/metadata.json",
"type": "object",
"properties": {
"created": { "$ref": "types.json#/definitions/timestamp" }
}
},
"http://www.example.com/types.json": {
"id": "http://www.example.com/types.json",
"definitions": {
"timestamp": {
"type": "number",
"description": "UTC Unix timestamp"
}
}
}
}