Compare json schemas correctly
npm install json-schema-compare --save
var compare = require('json-schema-compare')
var isEqual = compare({
title: 'title 1',
type: ['object'],
uniqueItems: false,
dependencies: {
name: ['age', 'lastName']
},
required: ['name', 'age', 'name']
}, {
title: 'title 2',
type: 'object',
required: ['age', 'name'],
dependencies: {
name: ['lastName', 'age']
},
properties: {
name: {
minLength: 0
}
}
}, {
ignore: ['title']
})
console.log(isEqual) // => true
Compare json schemas correctly.
undefined
, true
and {}
are equalundefined
and 0
are equalundefined
and false
are equalignore array - default: []
Ignores certain keywords, useful to exclude meta keywords like title, description etc or custom keywords. If all you want to know if they are the same in terms of validation keywords.
Create tests for new functionality and follow the eslint rules.
MIT © Martin Hansen