Closed terrisgit closed 6 years ago
After the first look this seems like two separate problems:
jsonmerge assumes that the document is valid for the schema. This has always been the case, but isn't mentioned explicitly the documentation. It might be a good idea for jsonmerge to validate it in merge()
call before running the merge.
jsonmerge
support for schemas that have boolean values for subschemas is buggy (like in your additionalProperties
case) and needs better test coverage. RFC section about boolean schema values for future reference.
I like the current behavior of not validating document fragments that are merged together. E.g., my schema has "requires" which is violated by many of the fragments. When I merge them together they produce a valid document.
A small update regarding the issue of correctly supporting additionalProperties: false
:
Boolean value as a valid schema was added in draft 6 (see changelog). jsonmerge
is currently based on a draft 4 validator from jsonschema
package, which is the most recent draft supported in that package. Hence supporting draft 6 features in jsonmerge
depends on support for these features in jsonschema
.
So until jsonschema
is released with a draft 6 (or later) validator, I will not work on fixing this.
This is the relevant issue for jsonschema
: https://github.com/Julian/jsonschema/issues/337
FWIW just glancing at this ticket because it's linked from that one now, additionalProperties: false
was valid even in draft 4, what draft 6 did was just extend that possibility to other validators.
(Might not change your response here though obviously)
The exception that's raised by jsonmerge when additionalProperties
keyword is a boolean should now be fixed.
@terrisgit if there's still some draft 4-compliant case where you get an error, please provide a test case. Otherwise I will close this issue.
I fed a schema that uses "additionalProperties": false everywhere to a Merger. I then sent a bad document (because a key wasn't defined in properties:) to the Merger and got an AttributeError exception. Partial trace is below. It took me about an hour to figure out that my document was invalid. Great that I got an exception; not so good that the exception made no sense.