0.2.0 • Published 8 years ago

json-schema-load-tree v0.2.0

Weekly downloads
13
License
MIT
Repository
github
Last release
8 years ago

json-schema-load-tree

Loads all references in a json schema, recursively. Currently a work in progress.

Stability:Experimental NPM Version Travis Issues

Commitizen friendly Semantic Release License Maintenance Downloads

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"
            }
        }
    }
}