schema-deref

    2.2.0 • Public • Published

    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

    Install

    npm i schema-deref

    DownloadsWeekly Downloads

    332

    Version

    2.2.0

    License

    AGPLv3

    Last publish

    Collaborators

    • avatar