{"_id":"@fastify/merge-json-schemas","_rev":"11-dc916ae1a81035279d94156bfe2d7118","name":"@fastify/merge-json-schemas","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@fastify/merge-json-schemas","version":"0.1.0","keywords":["json","schema","merge","allOf"],"author":{"name":"Ivan Tymoshenko","email":"ivan@tymoshenko.me"},"license":"MIT","_id":"@fastify/merge-json-schemas@0.1.0","maintainers":[{"name":"gurgunday","email":"gurgun.dayioglu@icloud.com"},{"name":"metcoder95","email":"me@metcoder.dev"},{"name":"galvez","email":"jonasgalvez@gmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":"maksim@sinik.it"},{"name":"airhorns","email":"harry@harry.me"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"}],"homepage":"https://github.com/fastify/merge-json-schemas#readme","bugs":{"url":"https://github.com/fastify/merge-json-schemas/issues"},"dist":{"shasum":"ff175d13a16f322736aaac621dd7fcb0bb3349ea","tarball":"https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.1.0.tgz","fileCount":50,"integrity":"sha512-S5T0Qx3P/t/EpKs+o8UJe4gb73Fz/Hv5YoTOTD3nRPGa4/UGIhXR1AAOsAMWFG8WAZy1WTvj5tI0+x+UZAAz7A==","signatures":[{"sig":"MEYCIQClfdLzaE5MRVux3I0oD7lKu6Lv1JTn8y7K1I/bomznwAIhALjaBTK0Mc4t2xnUKvdjbL+HtzFaD5p+ULGrF1i5m088","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100994},"main":"index.js","type":"commonjs","types":"types/index.d.ts","gitHead":"3e43524cc93f811555739c1620c8fb01bedfe23a","scripts":{"lint":"standard","test":"npm run lint && npm run test:unit && npm run test:types","lint:fix":"standard --fix","test:unit":"c8 --100 node --test","test:types":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/merge-json-schemas.git","type":"git"},"_npmVersion":"10.2.4","description":"Builds a logical conjunction (AND) of multiple JSON schemas","directories":{},"_nodeVersion":"20.11.0","dependencies":{"fast-deep-equal":"^3.1.3"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","tsd":"^0.30.3","standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/merge-json-schemas_0.1.0_1705419542435_0.8764459782311311","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@fastify/merge-json-schemas","version":"0.1.1","keywords":["json","schema","merge","allOf"],"author":{"name":"Ivan Tymoshenko","email":"ivan@tymoshenko.me"},"license":"MIT","_id":"@fastify/merge-json-schemas@0.1.1","maintainers":[{"name":"gurgunday","email":"gurgun.dayioglu@icloud.com"},{"name":"metcoder95","email":"me@metcoder.dev"},{"name":"galvez","email":"jonasgalvez@gmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":"maksim@sinik.it"},{"name":"airhorns","email":"harry@harry.me"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"ivan-tymoshenko","email":"ivan@tymoshenko.me"}],"homepage":"https://github.com/fastify/merge-json-schemas#readme","bugs":{"url":"https://github.com/fastify/merge-json-schemas/issues"},"dist":{"shasum":"3551857b8a17a24e8c799e9f51795edb07baa0bc","tarball":"https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.1.1.tgz","fileCount":50,"integrity":"sha512-fERDVz7topgNjtXsJTTW1JKLy0rhuLRcquYqNR9rF7OcVpCa2OVW49ZPDIhaRRCaUuvVxI+N416xUoF76HNSXA==","signatures":[{"sig":"MEUCIGYFAHAXXdLtMOyxWakee2gqDbJPo7+ebGmd6VjXuLSWAiEA7/H/EMON4evhePddUTr6qDTIWiburC4K7AfmV05VUbk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":101012},"main":"index.js","type":"commonjs","types":"types/index.d.ts","gitHead":"8f46867bec724bad9cd427ecf7c4825ead295cd4","scripts":{"lint":"standard","test":"npm run lint && npm run test:unit && npm run test:types","lint:fix":"standard --fix","test:unit":"c8 --100 node --test","test:types":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/merge-json-schemas.git","type":"git"},"_npmVersion":"10.2.4","description":"Builds a logical conjunction (AND) of multiple JSON schemas","directories":{},"_nodeVersion":"20.11.0","dependencies":{"fast-deep-equal":"^3.1.3"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","tsd":"^0.30.3","standard":"^17.1.0"},"_npmOperationalInternal":{"tmp":"tmp/merge-json-schemas_0.1.1_1705419667696_0.8117343245874205","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@fastify/merge-json-schemas","version":"0.2.0","keywords":["json","schema","merge","allOf"],"author":{"name":"Ivan Tymoshenko","email":"ivan@tymoshenko.me"},"license":"MIT","_id":"@fastify/merge-json-schemas@0.2.0","maintainers":[{"name":"gurgunday","email":"hey@gurgun.day"},{"name":"metcoder95","email":"me@metcoder.dev"},{"name":"galvez","email":"jonasgalvez@gmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":"maksim@sinik.it"},{"name":"airhorns","email":"harry@harry.me"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"ivan-tymoshenko","email":"ivan@tymoshenko.me"}],"homepage":"https://github.com/fastify/merge-json-schemas#readme","bugs":{"url":"https://github.com/fastify/merge-json-schemas/issues"},"dist":{"shasum":"13ebd4f2b57ed3be83421e2e83bc7cbb9cec237d","tarball":"https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.2.0.tgz","fileCount":50,"integrity":"sha512-9ql2tM7wdn7McvOg1V799G6/M6N5MM/Exp9SQvy8rld3xO07YhpxT9taR6vy7FU8o3ppU6M19M7P6GURP5RsPA==","signatures":[{"sig":"MEQCICB0K+D2sKtaHALJNnmiizNHWSaEfHbyogncR7Tkh6sSAiAr/D638dFasGzLEBtlhACyjNT1cBEGEBEI+IFuDlbwuQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100831},"main":"index.js","type":"commonjs","types":"types/index.d.ts","gitHead":"11d70798b3a0dc8f0bc5e0f0b6eb9e079e7bbb2c","scripts":{"lint":"standard","test":"npm run test:unit && npm run test:types","lint:fix":"standard --fix","test:unit":"c8 --100 node --test","test:types":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"repository":{"url":"git+https://github.com/fastify/merge-json-schemas.git","type":"git"},"_npmVersion":"10.8.1","description":"Builds a logical conjunction (AND) of multiple JSON schemas","directories":{},"_nodeVersion":"20.16.0","dependencies":{"dequal":"^2.0.3"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","tsd":"^0.30.3","standard":"^17.1.0","@fastify/pre-commit":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/merge-json-schemas_0.2.0_1725438117363_0.4328192242996358","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@fastify/merge-json-schemas","version":"0.2.1","keywords":["json","schema","merge","allOf"],"author":{"name":"Ivan Tymoshenko","email":"ivan@tymoshenko.me"},"license":"MIT","_id":"@fastify/merge-json-schemas@0.2.1","maintainers":[{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":"maksim@sinik.it"},{"name":"airhorns","email":"harry@harry.me"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"galvez","email":"jonasgalvez@gmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"gurgunday","email":"hey@gurgun.day"},{"name":"metcoder95","email":"me@metcoder.dev"},{"name":"ivan-tymoshenko","email":"ivan@tymoshenko.me"},{"name":"fdawgs","email":"frazer.dev@icloud.com"}],"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"},{"url":"https://heyhey.to/G","name":"Gürgün Dayıoğlu","email":"hey@gurgun.day"}],"homepage":"https://github.com/fastify/merge-json-schemas#readme","bugs":{"url":"https://github.com/fastify/merge-json-schemas/issues"},"dist":{"shasum":"3aa30d2f0c81a8ac5995b6d94ed4eaa2c3055824","tarball":"https://registry.npmjs.org/@fastify/merge-json-schemas/-/merge-json-schemas-0.2.1.tgz","fileCount":52,"integrity":"sha512-OA3KGBCy6KtIvLf8DINC5880o5iBlDX4SxzLQS8HorJAbqluzLRn80UXU0bxZn7UOFhFgpRJDasfwn9nG4FG4A==","signatures":[{"sig":"MEUCIAdo4DIBm6lEtVrNsIIqOytKWGRIfMOzAnBJ9CTHzDsjAiEA7rRxKelmaJLqL1X6HxCZjv7gTlEig6hlZFWbFpzUqjA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":102295},"main":"index.js","type":"commonjs","types":"types/index.d.ts","funding":[{"url":"https://github.com/sponsors/fastify","type":"github"},{"url":"https://opencollective.com/fastify","type":"opencollective"}],"gitHead":"ed66b9028266f09cd7a1b0ba115a042f6f436413","scripts":{"lint":"eslint","test":"npm run test:unit && npm run test:types","lint:fix":"eslint --fix","test:unit":"c8 --100 node --test","test:types":"tsd"},"_npmUser":{"name":"fdawgs","email":"frazer.dev@icloud.com"},"repository":{"url":"git+https://github.com/fastify/merge-json-schemas.git","type":"git"},"_npmVersion":"10.8.2","description":"Builds a logical conjunction (AND) of multiple JSON schemas","directories":{},"_nodeVersion":"20.18.1","dependencies":{"dequal":"^2.0.3"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","tsd":"^0.31.2","eslint":"^9.17.0","neostandard":"^0.12.0","@fastify/pre-commit":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/merge-json-schemas_0.2.1_1736180150828_0.20433204493767043","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2024-01-16T15:39:02.284Z","modified":"2026-03-05T20:02:08.168Z","0.1.0":"2024-01-16T15:39:02.623Z","0.1.1":"2024-01-16T15:41:07.834Z","0.2.0":"2024-09-04T08:21:57.492Z","0.2.1":"2025-01-06T16:15:51.010Z"},"bugs":{"url":"https://github.com/fastify/merge-json-schemas/issues"},"author":{"name":"Ivan Tymoshenko","email":"ivan@tymoshenko.me"},"license":"MIT","homepage":"https://github.com/fastify/merge-json-schemas#readme","keywords":["json","schema","merge","allOf"],"repository":{"url":"git+https://github.com/fastify/merge-json-schemas.git","type":"git"},"description":"Builds a logical conjunction (AND) of multiple JSON schemas","contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"},{"url":"https://heyhey.to/G","name":"Gürgün Dayıoğlu","email":"hey@gurgun.day"}],"maintainers":[{"email":"simone.busoli@gmail.com","name":"simoneb"},{"email":"tommydelved@gmail.com","name":"delvedor"},{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"james.sumners@gmail.com","name":"jsumners"},{"email":"vince.legoff@gmail.com","name":"zekth"},{"email":"behemoth89@gmail.com","name":"eomm"},{"email":"maksim@sinik.it","name":"fox1t"},{"email":"harry@harry.me","name":"airhorns"},{"email":"iselwin@gmail.com","name":"kibertoad"},{"email":"kaka@kakawebsitedemo.com","name":"climba03003"},{"email":"jonasgalvez@gmail.com","name":"galvez"},{"email":"sbekkhus91@gmail.com","name":"simenb"},{"email":"hey@gurgun.day","name":"gurgunday"},{"email":"a.tripodi133@gmail.com","name":"tony133"},{"email":"me@metcoder.dev","name":"metcoder95"},{"email":"jean.antoine.michelet@gmail.com","name":"jean-michelet"},{"email":"ivan@tymoshenko.me","name":"ivan-tymoshenko"},{"email":"frazer.dev@icloud.com","name":"fdawgs"}],"readme":"# @fastify/merge-json-schemas\n\n[![CI](https://github.com/fastify/merge-json-schemas/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/merge-json-schemas/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/@fastify/merge-json-schemas)](https://www.npmjs.com/package/@fastify/merge-json-schemas)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\n__merge-json-schemas__ is a JavaScript library that builds a logical product (AND) for multiple [JSON schemas](https://json-schema.org/draft/2020-12/json-schema-core#name-introduction).\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [mergeSchemas(schemas, options)](#mergeschemasschemas-options)\n  - [resolvers](#resolvers)\n  - [defaultResolver](#defaultresolver)\n- [License](#license)\n\n<a name=\"installation\"></a>\n\n## Installation\n\n```bash\nnpm i @fastify/merge-json-schemas\n```\n\n<a name=\"usage\"></a>\n\n## Usage\n\n```javascript\nconst assert = require('node:assert')\nconst { mergeSchemas } = require('@fastify/merge-json-schemas');\n\nconst schema1 = {\n  $id: 'schema1',\n  type: 'object',\n  properties: {\n    foo: { type: 'string', enum: ['foo1', 'foo2'] },\n    bar: { type: 'string', minLength: 3 }\n  }\n}\n\nconst schema2 = {\n  $id: 'schema1',\n  type: 'object',\n  properties: {\n    foo: { type: 'string', enum: ['foo1', 'foo3'] },\n    bar: { type: 'string', minLength: 5 }\n  },\n  required: ['foo']\n}\n\nconst mergedSchema = mergeSchemas([schema1, schema2])\nassert.deepStrictEqual(mergedSchema, {\n  $id: 'schema1',\n  type: 'object',\n  properties: {\n    foo: { type: 'string', enum: ['foo1'] },\n    bar: { type: 'string', minLength: 5 }\n  },\n  required: ['foo']\n})\n```\n\n<a name=\"api\"></a>\n\n## API\n\n<a name=\"merge-schemas\"></a>\n\n#### mergeSchemas(schemas, options)\n\nBuilds a logical conjunction (AND) of multiple [JSON schemas](https://json-schema.org/draft/2020-12/json-schema-core#name-introduction).\n\n- `schemas` __\\<objects[]\\>__ - list of JSON schemas to merge\n- `options` __\\<object\\>__ - optional options\n  - `resolvers` __\\<object\\>__ - custom resolvers for JSON schema keywords. Each key is the name of a JSON schema keyword. Each value is a resolver function. See [keywordResolver](#keywordresolver-keyword-values-mergedschema-parentschemas-options)\n  - `defaultResolver` __\\<function\\>__ - custom default resolver for JSON schema keywords. See [keywordResolver](#keywordresolver-keyword-values-mergedschema-parentschemas-options)\n  - `onConflict` __\\<string\\>__ - action to take when a conflict is found. Used by the default `defaultResolver`. Default is `throw`. Possible values are:\n    - `throw` - throws an error multiple different schemas for the same keyword are found\n    - `ignore` - do nothing if multiple different schemas for the same keyword are found\n    - `first` - use the value of the first schema if multiple different schemas for the same keyword are found\n\n#### resolvers\n\nA list of default resolvers that __merge-json-schema__ uses to merge JSON schemas. You can override the default resolvers by passing a list of custom resolvers in the `options` argument of `mergeSchemas`. See [keywordResolver](#keywordresolver-keyword-values-mergedschema-parentschemas-options).\n\n#### defaultResolver\n\nA default resolver that __merge-json-schema__ uses to merge JSON schemas. Default resolver is used when no custom resolver is defined for a JSON schema keyword. By default, the default resolver works as follows:\n\n- If only one schema contains the keyword, the value of the keyword is used as the merged value\n- If multiple schemas contain the exact same value for the keyword, the value of the keyword is used as the merged value\n- If multiple schemas contain different values for the keyword, it throws an error\n\n#### keywordResolver (keyword, values, mergedSchema, parentSchemas, options)\n\n__merge-json-schema__ uses a set of resolvers to merge JSON schemas. Each resolver is associated with a JSON schema keyword. The resolver is called when the keyword is found in the schemas to merge. The resolver is called with the following arguments:\n\n- `keyword` __\\<string\\>__ - the name of the keyword to merge\n- `values` __\\<any[]\\>__ - the values of the keyword to merge. The length of the array is equal to the number of schemas to merge. If a schema does not contain the keyword, the value is `undefined`\n- `mergedSchema` __\\<object\\>__ - an instance of the merged schema\n- `parentSchemas` __\\<object[]\\>__ - the list of parent schemas\n- `options` __\\<object\\>__ - the options passed to `mergeSchemas`\n\nThe resolver must set the merged value of the `keyword` in the `mergedSchema` object.\n\n__Example:__ resolver for the `minNumber` keyword.\n\n```javascript\nfunction minNumberResolver (keyword, values, mergedSchema) {\n  mergedSchema[keyword] = Math.min(...values)\n}\n```\n\n<a name=\"license\"></a>\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","readmeFilename":"README.md"}