Closed kklash closed 4 years ago
That's the correct per-spec behavior, I believe.
Top-level additionalProperties
rule is checked against empty/missing properties
in the top-level schema, not against sub-schemas in oneOf
.
There doesn't seem to be any related issues in the produced IIFE.
Also, this matches ajv
.
I.e. this is exactly how additionalProperties
and unevaluatedProperties
are different, but the latter is introduced only in draft2019-09
spec which we don't support here. Refs: https://github.com/json-schema-org/json-schema-spec/issues/556
additionalProperties
, unlike unevaluatedProperties
(unsupported), doesn't see through refs and allOf
/anyOf
/oneOf
.
So, this is an issue, but it's an issue of enforceValidation
, not of code generation.
It shouldn't enforce to set additionalProperties
when it has already been set in all anyOf/oneOf/allOf clauses.
I'll fix that.
When you try to use only
oneOf
to describe an object type in strong mode (+ additionalItems = false), it ignores theoneOf
array and always fails to validate any data.Example:
Examining the IIFE code, we see the problem is caused by
oneOf
being ignored in favor ofproperties
orpatternProperties
: