mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-14 21:48:50 +00:00
src/api/schema.rs - verify_json_object: improve error message
This commit is contained in:
parent
c4311d4f11
commit
f62fe221f0
@ -871,15 +871,18 @@ pub fn verify_json_object(data: &Value, schema: &ObjectSchema) -> Result<(), Err
|
|||||||
|
|
||||||
for (key, value) in map {
|
for (key, value) in map {
|
||||||
if let Some((_optional, prop_schema)) = schema.lookup(&key) {
|
if let Some((_optional, prop_schema)) = schema.lookup(&key) {
|
||||||
match prop_schema {
|
let result = match prop_schema {
|
||||||
Schema::Object(object_schema) => {
|
Schema::Object(object_schema) => {
|
||||||
verify_json_object(value, object_schema)?;
|
verify_json_object(value, object_schema)
|
||||||
}
|
}
|
||||||
Schema::Array(array_schema) => {
|
Schema::Array(array_schema) => {
|
||||||
verify_json_array(value, array_schema)?;
|
verify_json_array(value, array_schema)
|
||||||
}
|
|
||||||
_ => verify_json(value, prop_schema)?,
|
|
||||||
}
|
}
|
||||||
|
_ => verify_json(value, prop_schema),
|
||||||
|
};
|
||||||
|
if let Err(err) = result {
|
||||||
|
bail!("property '{}': {}", key, err);
|
||||||
|
};
|
||||||
} else if !additional_properties {
|
} else if !additional_properties {
|
||||||
bail!(
|
bail!(
|
||||||
"property '{}': schema does not allow additional properties.",
|
"property '{}': schema does not allow additional properties.",
|
||||||
|
Loading…
Reference in New Issue
Block a user