Incorrect/inconsistent validation result when combining `unevaluatedProperties`/`allOf`/`oneOf`
Closed this issue · 1 comments
GREsau commented
Thanks for the crate, I've started using this to reimplement the tests in schemars to validate its outputs, and doing so has already revealed a few schemars bugs!
I also stumbled upon this odd case though - full repro:
use jsonschema::{Draft, JSONSchema};
use serde_json::json;
fn main() {
let schema = JSONSchema::options()
.with_draft(Draft::Draft202012)
.compile(&json!({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [{}],
"oneOf": [
{
"properties": {
"blah": true
}
}
],
"unevaluatedProperties": false
}))
.unwrap();
let value = json!({
"blah": 1
});
println!(
"Is valid: {}, validate is OK: {}",
schema.is_valid(&value),
schema.validate(&value).is_ok()
);
}
I believe that schema is functionally equivalent to
{
"properties": {
"blah": true
},
"additionalProperties": false
}
So I'd expect the output to be Is valid: true, validate is OK: true
, but it's actually Is valid: false, validate is OK: true
. i.e. validate
correctly passes validation, but is_valid
fails it for some reason
Stranger6667 commented
Thanks for the crate, I've started using this to reimplement the tests in schemars to validate its outputs, and doing so has already revealed a few schemars bugs!
Delighted to hear it!
Indeed, it is a bug! Thanks for reporting :)