is-json-schema-subset
TypeScript icon, indicating that this package has built-in type declarations

1.1.27 • Public • Published

Build Status Greenkeeper badge Coverage Status

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

Readme

Keywords

Package Sidebar

Install

npm i is-json-schema-subset

Weekly Downloads

0

Version

1.1.27

License

MIT

Unpacked Size

73.5 kB

Total Files

15

Last publish

Collaborators

  • haggholm