}
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
-
- let type_text = match schema {
+ match schema {
Schema::Null => String::from("<null>"), // should not happen
Schema::String(_) => String::from("<string>"),
Schema::Boolean(_) => String::from("<boolean>"),
},
Schema::Object(_) => String::from("<object>"),
Schema::Array(_) => String::from("<array>"),
- };
-
- type_text
+ }
}
pub fn get_property_description(
fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option<String> {
match def {
- MethodDefinition::None => return None,
+ MethodDefinition::None => None,
MethodDefinition::Simple(simple_method) => {
let param_descr = dump_api_parameters(&simple_method.parameters);
let return_descr = dump_api_return_schema(&simple_method.returns);
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
- return Some(res);
+ Some(res)
}
MethodDefinition::Async(async_method) => {
let method = if method == "POST" { "UPLOAD" } else { method };
let return_descr = dump_api_return_schema(&async_method.returns);
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
- return Some(res);
+ Some(res)
}
}
}
let kv: Vec<&str> = key_val.splitn(2, '=').collect();
if kv.len() == 2 {
param_list.push((kv[0].into(), kv[1].into()));
+ } else if let Some(key) = object_schema.default_key {
+ param_list.push((key.into(), kv[0].into()));
} else {
- if let Some(key) = object_schema.default_key {
- param_list.push((key.into(), kv[0].into()));
- } 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.");
}
}
}
}
}
- } else {
- if additional_properties {
- match params[key] {
- Value::Null => {
- params[key] = Value::String(value.to_owned());
- },
- Value::String(ref old) => {
- params[key] = Value::Array(
- vec![Value::String(old.to_owned()), Value::String(value.to_owned())]);
- }
- Value::Array(ref mut array) => {
- array.push(Value::String(value.to_string()));
- }
- _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
+ } else if additional_properties {
+ match params[key] {
+ Value::Null => {
+ params[key] = Value::String(value.to_owned());
+ },
+ Value::String(ref old) => {
+ params[key] = Value::Array(
+ vec![Value::String(old.to_owned()), Value::String(value.to_owned())]);
}
- } else {
- errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
+ Value::Array(ref mut array) => {
+ array.push(Value::String(value.to_string()));
+ }
+ _ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
}
+ } else {
+ errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
}
}
}
_ => verify_json(value, prop_schema)?,
}
- } else {
- if !additional_properties {
- bail!("property '{}': schema does not allow additional properties.", key);
- }
+ } else if !additional_properties {
+ bail!("property '{}': schema does not allow additional properties.", key);
}
}