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.
import isJsonSchemaSubset from 'is-json-schema-subset';
import inputSchema from './input-schema.json';
import outputSchema from './output-schema.json';
async function check() {
if (await isJsonSchemaSubset(inputSchema, outputSchema)) {
console.log('OK');
} else {
console.log('Fail');
}
}import isJsonSchemaSubset from 'is-json-schema-subset';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.
$ yarn add is-json-schema-subsetDEBUG=is-json-schema-subset ...MIT