Closed ktaras closed 7 years ago
Sorry I'm having trouble reproducing that with 2.7.0, can you give me a code example that reproduces the error?
Here's what I'm doing:
require "json-schema"
schema = {
"type" => "object",
"required" => ["data"],
"properties" => {
"data" => {
"type" => "object"
},
"included": {
"type": "array"
}
}
}
JSON::Validator.validate!(schema, { "data" => {} }) # returns true
I have strict: true
and it fails:
JSON::Validator.validate!(schema, { "data" => {} }, strict: true)
It seems like I got it - if you add strict: true
it doesn't matter which fields specified as required in scheme - it requires all of them and just ignores that line. And if you don't use strict: true
you can specify exact fields in scheme which are required, am I right?
Yes, then that's expected behaviour (and it should have been the case in json-schema 2.6.2 as well?).
This is what it says in the readme:
with the
:strict
option, all properties are condisidered to have"required": true
and all objects"additionalProperties": false
Yes, sorry, my fault. But in 2.6.2 it worked fine, strange thing :)
We did fix a lot of bugs in the last release, possibly it was working because of a bug
After updating from 2.6.2 to 2.7.0 it fails validating not required fields. For example, I have following scheme:
So, as I understand the key
included
shouldn't be required, but when I run tests I get an error: