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.
Files changed (2) hide show
  1. package/lib/resolver.js +4 -1
  2. 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-2-joi",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "license": "Apache 2.0",
5
5
  "description": "Converts json-schema to Joi schema. (Enhanced enjoi)",
6
6
  "main": "./index.js",