Open ghost opened 5 years ago
Hi @adityamandhare Thank you for reporting the problem. I have successfully reproduced the problem. I will try to fix it. Sorry for your inconvenience.
Thanks @leadpony 🙂
Hello @adityamandhare
I labeled this issue as a bug, but I changed my mind after further consideration.
additionalProperties
is one of applicator keywords that apply subschemas but assert nothing on JSON instances by themselves.
"additionalProperties": false
means "apply the boolean schema false
to any additional property found". As you know, the boolean schema false
evaluates anything as invalid and the schema has no keywords.
In the reported situation, calling Problem#getSchema()
actually returns JsonSchema.FALSE
which has no keywords. Therefore it is a correct behavior that Problem#getKeyword()
returns null
.
@leadpony thanks for working on this. Although this may not be a bug, having a keyword like additionalField
or unexpectedField
, or invalidField
can always be helpful in case of additional properties are passed in when "additionalProperties": false
.
Hi, currently if we set "additionalProperties": false, and if the input contains additional fields, then the problem.keyword field is returns a null a value. For every other type of invalid format error, we get back proper keywords which help us categorize the type of problem (ex: 'maxLength', 'minLength', 'required'). It would be helpful it the keyword shows some value like 'additionalField'.