Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-merge-allof

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-merge-allof

Simplify your schema by combining allOf into the root schema, safely.

  • 0.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
648K
increased by15.6%
Maintainers
1
Weekly downloads
 
Created

What is json-schema-merge-allof?

The json-schema-merge-allof npm package is designed to merge multiple JSON Schemas that use the 'allOf' keyword into a single schema. This can be particularly useful when dealing with complex schemas that need to be simplified or when combining schemas from different sources.

What are json-schema-merge-allof's main functionalities?

Merge Multiple Schemas

This feature allows you to merge multiple JSON Schemas into a single schema. The code sample demonstrates merging two schemas, one with a 'name' property and another with an 'age' property, into a single schema.

const mergeAllOf = require('json-schema-merge-allof');

const schema1 = {
  type: 'object',
  properties: {
    name: { type: 'string' }
  }
};

const schema2 = {
  type: 'object',
  properties: {
    age: { type: 'integer' }
  }
};

const mergedSchema = mergeAllOf({ allOf: [schema1, schema2] });
console.log(JSON.stringify(mergedSchema, null, 2));

Handle Conflicting Schemas

This feature demonstrates how the package handles conflicting schemas. In this example, both schemas have a 'name' property but with different types. The package will throw an error indicating the conflict.

const mergeAllOf = require('json-schema-merge-allof');

const schema1 = {
  type: 'object',
  properties: {
    name: { type: 'string' }
  }
};

const schema2 = {
  type: 'object',
  properties: {
    name: { type: 'integer' }
  }
};

try {
  const mergedSchema = mergeAllOf({ allOf: [schema1, schema2] });
  console.log(JSON.stringify(mergedSchema, null, 2));
} catch (error) {
  console.error('Error merging schemas:', error.message);
}

Other packages similar to json-schema-merge-allof

Keywords

FAQs

Package last updated on 22 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc