json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

AdditionalProperties not being applied when value could be array

Open dharanikumar-19 opened this issue 6 years ago • 2 comments

This fix should will resolve this issue #404

Given the following schema:

{ "type": [ "object", "null" ], "properties": { "a_string": { "type": "string" } }, "additionalProperties": false } The sample data object = { "a_string": "this property is allowed by the schema", "an_extra_string": "the schema does not allow this property" }

Previously it does not raise any error

After the fix Following error will throw JSON::Schema::ValidationError: The property '#/' contains additional properties ["an_array"] outside of the schema when none are allowed

dharanikumar-19 avatar Aug 17 '19 09:08 dharanikumar-19

https://github.com/ruby-json-schema/json-schema/issues/423#issuecomment-634811990

pboling avatar Feb 14 '21 01:02 pboling

Hi @dharanikumar-19, thanks for this PR. Are you able to rebase and add tests for the change?

bastelfreak avatar Nov 27 '21 18:11 bastelfreak