recursive-json-schema-loader

1.0.1 • Public • Published

schema loader

provides a easy to use functionality load all schemas in a directory structure. The structure creates the schema ids, so references are easy to handle.

Usage with ajv

const SchemaLoader = require('json-schema-loader')
const schemaLoader = SchemaLoader()

const Ajv = require('ajv');
const ajv = new Ajv();

const dataToValidate = {
    my: "data"
}
schemaId = "/schema/id"

return schemaLoader.loadSchemas('./path/to/schemas', (schema, id) => {
    ajv.addSchema(schema, id)
})
.then(() => {
    const valid = ajv.validate(schemaId, dataToValidate);
    console.log(valid)
})

Readme

Keywords

none

Package Sidebar

Install

npm i recursive-json-schema-loader

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

2.39 kB

Total Files

3

Last publish

Collaborators

  • oliverlorenz