more clippy fixups
mostly indentation changes, view with `-w` Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
653b1ca10e
commit
44fed91e17
|
@ -51,8 +51,7 @@ pub fn wrap_text(initial_indent: &str, subsequent_indent: &str, text: &str, colu
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
|
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
|
||||||
|
match schema {
|
||||||
let type_text = match schema {
|
|
||||||
Schema::Null => String::from("<null>"), // should not happen
|
Schema::Null => String::from("<null>"), // should not happen
|
||||||
Schema::String(_) => String::from("<string>"),
|
Schema::String(_) => String::from("<string>"),
|
||||||
Schema::Boolean(_) => String::from("<boolean>"),
|
Schema::Boolean(_) => String::from("<boolean>"),
|
||||||
|
@ -66,9 +65,7 @@ pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> S
|
||||||
},
|
},
|
||||||
Schema::Object(_) => String::from("<object>"),
|
Schema::Object(_) => String::from("<object>"),
|
||||||
Schema::Array(_) => String::from("<array>"),
|
Schema::Array(_) => String::from("<array>"),
|
||||||
};
|
}
|
||||||
|
|
||||||
type_text
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_property_description(
|
pub fn get_property_description(
|
||||||
|
@ -229,14 +226,14 @@ fn dump_api_return_schema(schema: &Schema) -> String {
|
||||||
fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option<String> {
|
fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option<String> {
|
||||||
|
|
||||||
match def {
|
match def {
|
||||||
MethodDefinition::None => return None,
|
MethodDefinition::None => None,
|
||||||
MethodDefinition::Simple(simple_method) => {
|
MethodDefinition::Simple(simple_method) => {
|
||||||
let param_descr = dump_api_parameters(&simple_method.parameters);
|
let param_descr = dump_api_parameters(&simple_method.parameters);
|
||||||
|
|
||||||
let return_descr = dump_api_return_schema(&simple_method.returns);
|
let return_descr = dump_api_return_schema(&simple_method.returns);
|
||||||
|
|
||||||
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
|
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
|
||||||
return Some(res);
|
Some(res)
|
||||||
}
|
}
|
||||||
MethodDefinition::Async(async_method) => {
|
MethodDefinition::Async(async_method) => {
|
||||||
let method = if method == "POST" { "UPLOAD" } else { method };
|
let method = if method == "POST" { "UPLOAD" } else { method };
|
||||||
|
@ -247,7 +244,7 @@ fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> O
|
||||||
let return_descr = dump_api_return_schema(&async_method.returns);
|
let return_descr = dump_api_return_schema(&async_method.returns);
|
||||||
|
|
||||||
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
|
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
|
||||||
return Some(res);
|
Some(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,14 +417,12 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result<Value, Erro
|
||||||
let kv: Vec<&str> = key_val.splitn(2, '=').collect();
|
let kv: Vec<&str> = key_val.splitn(2, '=').collect();
|
||||||
if kv.len() == 2 {
|
if kv.len() == 2 {
|
||||||
param_list.push((kv[0].into(), kv[1].into()));
|
param_list.push((kv[0].into(), kv[1].into()));
|
||||||
} else {
|
} else if let Some(key) = object_schema.default_key {
|
||||||
if let Some(key) = object_schema.default_key {
|
|
||||||
param_list.push((key.into(), kv[0].into()));
|
param_list.push((key.into(), kv[0].into()));
|
||||||
} else {
|
} else {
|
||||||
bail!("Value without key, but schema does not define a default key.");
|
bail!("Value without key, but schema does not define a default key.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
parse_parameter_strings(¶m_list, &object_schema, true)
|
parse_parameter_strings(¶m_list, &object_schema, true)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
|
@ -511,8 +509,7 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &ObjectSche
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if additional_properties {
|
||||||
if additional_properties {
|
|
||||||
match params[key] {
|
match params[key] {
|
||||||
Value::Null => {
|
Value::Null => {
|
||||||
params[key] = Value::String(value.to_owned());
|
params[key] = Value::String(value.to_owned());
|
||||||
|
@ -530,7 +527,6 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &ObjectSche
|
||||||
errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
|
errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if test_required && errors.len() == 0 {
|
if test_required && errors.len() == 0 {
|
||||||
for (name, (optional, _prop_schema)) in properties {
|
for (name, (optional, _prop_schema)) in properties {
|
||||||
|
@ -638,12 +634,10 @@ pub fn verify_json_object(data: &Value, schema: &ObjectSchema) -> Result<(), Err
|
||||||
}
|
}
|
||||||
_ => verify_json(value, prop_schema)?,
|
_ => verify_json(value, prop_schema)?,
|
||||||
}
|
}
|
||||||
} else {
|
} else if !additional_properties {
|
||||||
if !additional_properties {
|
|
||||||
bail!("property '{}': schema does not allow additional properties.", key);
|
bail!("property '{}': schema does not allow additional properties.", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (name, (optional, _prop_schema)) in properties {
|
for (name, (optional, _prop_schema)) in properties {
|
||||||
if *optional == false && data[name] == Value::Null {
|
if *optional == false && data[name] == Value::Null {
|
||||||
|
|
|
@ -494,7 +494,7 @@ impl Drop for BackupReader {
|
||||||
impl BackupReader {
|
impl BackupReader {
|
||||||
|
|
||||||
pub fn new(h2: H2Client, canceller: Canceller) -> Arc<Self> {
|
pub fn new(h2: H2Client, canceller: Canceller) -> Arc<Self> {
|
||||||
Arc::new(Self { h2, canceller: canceller })
|
Arc::new(Self { h2, canceller })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
|
|
Loading…
Reference in New Issue