cargo clippy

This commit is contained in:
Pierre HUBERT 2023-02-02 14:08:57 +01:00
parent 250fdb9f82
commit c6fc5f9123

View File

@ -3,7 +3,7 @@ use okapi::schemars::schema::{InstanceType, Schema, SingleOrVec};
/// Parse OpenAPI 3 schema /// Parse OpenAPI 3 schema
pub fn parse_schema(file_content: &str) -> OpenApi { pub fn parse_schema(file_content: &str) -> OpenApi {
let schema = serde_yaml::from_str::<OpenApi>(&file_content).expect("Failed to parse document"); let schema = serde_yaml::from_str::<OpenApi>(file_content).expect("Failed to parse document");
if schema.components.is_none() { if schema.components.is_none() {
log::error!("components is missing!"); log::error!("components is missing!");
@ -15,7 +15,7 @@ pub fn parse_schema(file_content: &str) -> OpenApi {
fn expect_single<E>(e: &SingleOrVec<E>) -> &E { fn expect_single<E>(e: &SingleOrVec<E>) -> &E {
match e { match e {
SingleOrVec::Single(e) => &e, SingleOrVec::Single(e) => e,
SingleOrVec::Vec(v) => &v[0], SingleOrVec::Vec(v) => &v[0],
} }
} }
@ -76,7 +76,7 @@ impl TreeNode {
}; };
TreeNode { TreeNode {
name: other.name.to_string(), name: self.name.to_string(),
r#type, r#type,
} }
} }
@ -87,7 +87,7 @@ pub fn build_tree(struct_name: &str, components: &Components) -> TreeNode {
let schema = components let schema = components
.schemas .schemas
.get(struct_name) .get(struct_name)
.expect(&format!("Missing {struct_name}")); .unwrap_or_else(|| panic!("Missing {struct_name}"));
build_tree_schema(schema, struct_name, components) build_tree_schema(schema, struct_name, components)
} }