json-2-joi 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/resolver.js +4 -1
- package/package.json +1 -1
package/lib/resolver.js
CHANGED
|
@@ -74,6 +74,9 @@ function allowNullIfNeeded(schema, { allowNull = false, forbidArrayNull = true,
|
|
|
74
74
|
// Already has enum restriction
|
|
75
75
|
return schema;
|
|
76
76
|
}
|
|
77
|
+
if (!schema.type && (schema.allOf || schema.anyOf || schema.oneOf || schema.not)) {
|
|
78
|
+
return schema;
|
|
79
|
+
}
|
|
77
80
|
if (forbidArrayNull && schema.type === 'array') {
|
|
78
81
|
return schema;
|
|
79
82
|
}
|
|
@@ -544,7 +547,7 @@ class SchemaResolver {
|
|
|
544
547
|
|
|
545
548
|
if (isObject(schema.additionalProperties)) {
|
|
546
549
|
joischema = joischema.pattern(/^/, this.resolve(schema.additionalProperties, resolveOptions, baseUri));
|
|
547
|
-
} else if (typeof this.joiOptions.allowUnknown === 'undefined') {
|
|
550
|
+
} else if (typeof this.joiOptions.allowUnknown === 'undefined' || typeof schema.additionalProperties !== 'undefined') {
|
|
548
551
|
joischema = joischema.unknown(schema.additionalProperties !== false);
|
|
549
552
|
}
|
|
550
553
|
|