Return unconstrained schema when additionalProperties is true/undefined

This commit is contained in:
toasted-nutbread 2020-01-26 15:45:31 -05:00
parent 203216986e
commit a844698f15

View File

@ -138,7 +138,13 @@ class JsonSchemaProxyHandler {
}
const additionalProperties = schema.additionalProperties;
return JsonSchemaProxyHandler.isObject(additionalProperties) ? additionalProperties : null;
if (additionalProperties === false) {
return null;
} if (JsonSchemaProxyHandler.isObject(additionalProperties)) {
return additionalProperties;
} else {
return JsonSchemaProxyHandler._unconstrainedSchema;
}
}
case 'array':
{
@ -491,6 +497,8 @@ class JsonSchemaProxyHandler {
}
}
JsonSchemaProxyHandler._unconstrainedSchema = {};
class JsonSchema {
static createProxy(target, schema) {
return new Proxy(target, new JsonSchemaProxyHandler(schema));