is-json-schema-subset
v1.1.27
Published
Check if a JSON schema is a subset of another
Downloads
19
Readme
is-json-schema-subset
Check if a JSON schema is a subset of another
Given a schema defining the output of some process A, and a second schema defining the input of some process B, will the output from A be valid input for process B?
Uses ajv and json-schema-merge-allof.
Usage
import isJsonSchemaSubset from 'is-json-schema-subset';
import inputSchema from './input-schema.json';
import outputSchema from './input-schema.json';
async function check() {
if (await isJsonSchemaSubset(inputSchema, outputSchema)) {
console.log('OK');
} else {
console.log('Fail');
}
}
API
import isJsonSchemaSubset from 'is-json-schema-subset';
isJsonSchemaSubset(subset: JSONSchema, superset: JSONSchema[, allowPartial: boolean = false])
Returns a promise resolving to true
if subset
is a compatible subset of superset
,
else false
.
If allowPartial
is false
, subset
must provide all required properties for superset
.
Install
$ yarn add is-json-schema-subset
Debugging
DEBUG=is-json-schema-subset ...
License
MIT