rest-server: bump schema to 1.2 and use convenience methods

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-02-11 14:09:45 +01:00
parent fd7f760304
commit 5b93835744
2 changed files with 9 additions and 8 deletions

View File

@ -7,7 +7,7 @@ description = "REST server implementation"
# for example # for example
[dev-dependencies] [dev-dependencies]
proxmox-schema = { version = "1.1", features = [ "api-macro" ] } proxmox-schema = { version = "1.2", features = [ "api-macro" ] }
tokio = { version = "1.6", features = [ "rt-multi-thread", "signal", "process" ] } tokio = { version = "1.6", features = [ "rt-multi-thread", "signal", "process" ] }
[dependencies] [dependencies]
@ -36,6 +36,6 @@ proxmox-io = "1"
proxmox-lang = "1" proxmox-lang = "1"
proxmox-http = { version = "0.6", features = [ "client" ] } proxmox-http = { version = "0.6", features = [ "client" ] }
proxmox-router = "1.1" proxmox-router = "1.1"
proxmox-schema = { version = "1.1", features = [ "api-macro", "upid-api-impl" ] } proxmox-schema = { version = "1.2", features = [ "api-macro", "upid-api-impl" ] }
proxmox-time = "1" proxmox-time = "1"
proxmox-sys = "0.2" proxmox-sys = "0.2"

View File

@ -147,13 +147,14 @@ impl OutputFormatter for ExtJsFormatter {
let message: String; let message: String;
let mut errors = HashMap::new(); let mut errors = HashMap::new();
if let Some(param_err) = err.downcast_ref::<ParameterError>() { match err.downcast::<ParameterError>() {
for (name, err) in param_err.errors().iter() { Ok(param_err) => {
for (name, err) in param_err {
errors.insert(name, err.to_string()); errors.insert(name, err.to_string());
} }
message = String::from("parameter verification errors"); message = String::from("parameter verification errors");
} else { }
message = err.to_string(); Err(err) => message = err.to_string(),
} }
let result = json!({ let result = json!({