# @fastify/merge-json-schema
__merge-json-schema__ is a javascript library that build a logical product (AND) for multiple [JSON schemas](https://json-schema.org/draft/2020-12/json-schema-core#name-introduction).
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [mergeSchemas(schemas, options)](#mergeschemasschemas-options)
- [resolvers](#resolvers)
- [defaultResolver](#defaultresolver)
- [License](#license)
## Installation
```bash
npm install @fastify/merge-json-schema
```
## Usage
```javascript
const assert = require('node:assert')
const { mergeSchemas } = require('merge-json-schema')
const schema1 = {
$id: 'schema1',
type: 'object',
properties: {
foo: { type: 'string', enum: ['foo1', 'foo2'] },
bar: { type: 'string', minLength: 3 }
}
}
const schema2 = {
$id: 'schema1',
type: 'object',
properties: {
foo: { type: 'string', enum: ['foo1', 'foo3'] },
bar: { type: 'string', minLength: 5 }
},
required: ['foo']
}
const mergedSchema = mergeSchemas([schema1, schema2])
assert.deepStrictEqual(mergedSchema, {
$id: 'schema1',
type: 'object',
properties: {
foo: { type: 'string', enum: ['foo1'] },
bar: { type: 'string', minLength: 5 }
},
required: ['foo']
})
```
## API
#### mergeSchemas(schemas, options)
Builds a logical conjunction (AND) of multiple [JSON schemas](https://json-schema.org/draft/2020-12/json-schema-core#name-introduction).
- `schemas` __\__ - list of JSON schemas to merge.
- `options` __\