jsonschema-rs
jsonschema-rs copied to clipboard
stack overflow
use jsonschema::JSONSchema;
use serde_json::json;
fn main() {
let schema = json!({
"$defs": {
"root": {
"oneOf": [
{
"type": "object",
"properties": {
"a": {
"type": "number"
}
}
},
{
"$ref": "#/$defs/root"
}
]
}
},
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/root"
}
}
});
let instance = json!({
"x": {
"a": 3
},
"y": {
"x": {
"a": 3
}
}
});
let compiled = JSONSchema::compile(&schema)
.expect("A valid schema");
let result = compiled.validate(&instance);
if let Err(errors) = result {
for error in errors {
println!("Validation error: {}", error);
println!(
"Instance path: {}", error.instance_path
);
}
}
}
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted
[dependencies]
jsonschema = "0.16.0"
serde_json = "1.0.82"