Registry / testing / is-json-schema-subset

is-json-schema-subset

JSON →
library1.1.27jsnpmunverified

Checks if a JSON Schema is a subset of another, useful for verifying compatibility between output and input schemas in data pipelines. Current stable version: 1.1.27. Release cadence: infrequent. Key differentiator: uses ajv for validation and json-schema-merge-allof for schema merging. Ships TypeScript types. Supports optional partial matching.

npm install is-json-schema-subset
INSTALL
IMPORT
SIG · IS-JSON-SCHEMA-SUB
I
is-json-schema-subset
testingjavascriptv1.1.27
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isJsonSchemaSubset
import isJsonSchemaSubset from 'is-json-schema-subset'
const isJsonSchemaSubset = require('is-json-schema-subset')
ESM-only; default export. CommonJS require will fail as package is type module.
isJsonSchemaSubset
import isJsonSchemaSubset from 'is-json-schema-subset'
import { isJsonSchemaSubset } from 'is-json-schema-subset'
Named import is incorrect; it's a default export.
isJsonSchemaSubset
const isJsonSchemaSubset = await import('is-json-schema-subset').then(m => m.default); const result = await isJsonSchemaSubset(subset, superset);
const { isJsonSchemaSubset } = await import('is-json-schema-subset');
Dynamic import requires accessing .default.

Demonstrates basic usage: checks if a simple object schema is a subset of a larger schema.

import isJsonSchemaSubset from 'is-json-schema-subset'; const subset = { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] }; const superset = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'number' } }, required: ['name'] }; async function check() { const result = await isJsonSchemaSubset(subset, superset); console.log('Is subset?', result); // true } check();
Debug
Known issues
gotchaFunction is async and returns a Promise; must be awaited.
fix
Use await or .then() to get the boolean result.
affects: >=1.0.0
gotchaIf allowPartial is false (default), the subset must have all required properties of the superset.
fix
Pass true as third argument to allow subset to only partially cover required properties.
affects: >=1.0.0
deprecatedTravis CI badges and Greenkeeper in README are outdated; no active CI configuration visible.
fix
Ensure you have your own CI process; the package itself works.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: isJsonSchemaSubset is not a function
Using named import instead of default import in ESM environment.
fix
Change to: import isJsonSchemaSubset from 'is-json-schema-subset'
Cannot find module 'is-json-schema-subset'
Not installed or running in CommonJS without proper configuration.
fix
Install with npm install is-json-schema-subset, and ensure package.json has "type": "module" or use .mjs extension.
Upgrade
Version history
1.1.27latest on npm
Audit
Dependencies
ajvrequiredJSON Schema validation
json-schema-merge-allofrequiredSchema merging
Agent activity
11 hits · last 30 days
node
10
Resources
is-json-schema-subset — npm install is-json-schema-subset · libregistry