json-schema-merge-allof
Advanced tools
Comparing version 0.8.0 to 0.8.1
{ | ||
"name": "json-schema-merge-allof", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Simplify your schema by combining allOf into the root schema, safely.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -11,3 +11,2 @@ const cloneDeep = require('lodash/cloneDeep') | ||
const isPlainObject = require('lodash/isPlainObject') | ||
const isFunction = require('lodash/isFunction') | ||
const pullAll = require('lodash/pullAll') | ||
@@ -250,2 +249,7 @@ const sortBy = require('lodash/sortBy') | ||
const defaultComplexResolvers = { | ||
properties: propertiesResolver, | ||
items: itemsResolver | ||
} | ||
function merger(rootSchema, options, totalSchemas) { | ||
@@ -255,10 +259,8 @@ totalSchemas = totalSchemas || [] | ||
ignoreAdditionalProperties: false, | ||
resolvers: cloneDeep(defaultResolvers), | ||
resolvers: defaultResolvers, | ||
complexResolvers: defaultComplexResolvers, | ||
deep: true | ||
}) | ||
const allResolverEntries = Object.entries(options.resolvers) | ||
options.resolvers = Object.fromEntries(allResolverEntries.filter(([key, val]) => isFunction(val))) | ||
const complexResolvers = allResolverEntries.filter(([key, val]) => isPlainObject(val)) | ||
options.complexResolvers = Object.fromEntries(complexResolvers) | ||
const complexResolvers = Object.entries(options.complexResolvers) | ||
@@ -295,4 +297,4 @@ function mergeSchemas(schemas, base, parents) { | ||
const complexKeysArr = complexResolvers.map(([resolverKeyword, resolverConf]) => | ||
allKeys.filter(k => [resolverKeyword, ...resolverConf.keywords].includes(k))) | ||
const complexKeysArr = complexResolvers.map(([mainKeyWord, resolverConf]) => | ||
allKeys.filter(k => resolverConf.keywords.includes(k))) | ||
@@ -299,0 +301,0 @@ // remove all complex keys before simple resolvers |
@@ -60,3 +60,3 @@ const chai = require('chai') | ||
const opts = { | ||
resolvers: { | ||
complexResolvers: { | ||
if: { | ||
@@ -63,0 +63,0 @@ // test with same if-then-else resolver |
@@ -40,4 +40,7 @@ const chai = require('chai') | ||
}, { | ||
resolvers: { | ||
properties: stub | ||
complexResolvers: { | ||
properties: { | ||
keywords: ['properties', 'patternProperties', 'additionalProperties'], | ||
resolver: stub | ||
} | ||
} | ||
@@ -44,0 +47,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3392
93852