Closed Kixiron closed 5 months ago
I've encountered what I beleive is the same error. I believe it's related to multiple iterations of $ref
schemas. In the following minimal repro, you can see the first error has the correct schema_path
, but the second just returns "/enum"
[package]
name = "scratch"
version = "0.1.0"
edition = "2021"
[dependencies]
jsonschema = "0.17.0"
serde_json = "1.0.96"
fn main() {
let json = serde_json::json!({
"things": [
{ "code": "CC" },
{ "code": "CC" },
]
});
let schema = serde_json::json!({
"type": "object",
"properties": {
"things": {
"type": "array",
"items": {
"type": "object",
"properties": {
"code": {
"type": "string",
"$ref": "#/$defs/codes"
}
},
"required": ["code"]
}
}
},
"required": ["things"],
"$defs": { "codes": { "enum": ["AA", "BB"] } }
});
let compiled = jsonschema::JSONSchema::options().compile(&schema).unwrap();
let result = compiled.validate(&json);
if let Err(err_iter) = result {
for err in err_iter {
println!("Schema path {}", err.schema_path);
}
}
}
Schema path /properties/things/items/properties/code/enum
Schema path /enum
Sorry for the delay - the fix will be released soon
Validating this json with this schema yields a
schema_path
of[PathChunk::Keyword("oneOf")]
which points to nothing, I'd expect the schema path to be something like/definitions/Neg
or/definitions/Node/3
, something that actually points to the definition at hand