Does whitelisting work for nested validation?
I have a spec which uses discriminators and all-of.
I tried to whitelist the additional properties problem using
ValidationErrorsWhitelist whitelist = ValidationErrorsWhitelist.create()
.withRule(
"Ignore additional properties",
allOf(
messageHasKey(SchemaValidator.ADDITIONAL_PROPERTIES_KEY)
)
Well, it didn't work so I spent some time in the debugger. It looks to me that the problem is that the whitelist only applies to the "top level" of the spec. The rules in the whitelist don't "inherit down" to the validation of the discriminator and the "all-of", which are recursive/nested validations, but only applies to the top level error messages returned by the outermost ValidationReport.
Or said another way, I checked in the debugger which messages are passed to each WhiteListRule.matches() and the underlying additional properties message is never actually passed to the rule. It rolls up to a "bad discriminator" check, by which time it is too late to whitelist it.
Does this make sense? Is it intended?
I also have a spec that uses
allOf
, but not discriminators. I have a similar symptom to the OP though: errors are apparently whitelisted, but theallOf
validation still fails. Here's what this looks like from the payload ofcom.atlassian.oai.validator.springmvc.InvalidResponseException
(some output transformed to protect the innocent):There is more of the same in the exception, but as in the excerpt the only validation errors are:
validation.response.body.schema.format.date-time
which is properly IGNOREd using my customized level resolver, at least until we fix our API’s datetime formattingvalidation.response.body.schema.allOf
which is the only ERROR level message in the entire exception, so apparently causes the overall validation failure