diff --git a/src/printer.rs b/src/printer.rs index 66269fb..043eabc 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -15,6 +15,7 @@ use std::ops::Add; #[derive(Clone, Debug)] +#[allow(dead_code)] pub struct Error; pub trait Printer { diff --git a/src/rust/model_gen.rs b/src/rust/model_gen.rs index 4af14e7..c5ab0aa 100644 --- a/src/rust/model_gen.rs +++ b/src/rust/model_gen.rs @@ -50,6 +50,7 @@ impl RefCache { fn serialize() -> RustPrinter { rust_name("serde", "Serialize") } + fn deserialize() -> RustPrinter { rust_name("serde", "Deserialize") } @@ -316,12 +317,14 @@ fn extract_enum_case( data_type: ref_type_name(reference, ref_cache)?, }) } else { - Err(Error::unimplemented( - "Can't find model type reference in enum case schema.", - )) + Err(Error::unimplemented(format!( + "Can't find model type reference in enum case schema {schema_name}.", + ))) } } - _ => Err(Error::unimplemented("allOf schema expected for enum case")), + _ => Err(Error::unimplemented(format!( + "allOf schema expected for enum case in {schema_name}" + ))), } } @@ -415,7 +418,7 @@ pub fn model_gen(reference: &str, open_api: &OpenAPI, ref_cache: &mut RefCache) .unwrap_or_else(unit); #[rustfmt::skip] - let code = unit() + + let code = unit() + derive_line() + line(unit() + "pub enum " + &name + " {") + indented( @@ -423,17 +426,19 @@ pub fn model_gen(reference: &str, open_api: &OpenAPI, ref_cache: &mut RefCache) ) + line(unit() + "}") + NewLine + + line(unit() + "#[allow(clippy::to_string_trait_impl)]") + + NewLine + line(unit() + "impl ToString for " + &name + "{") + indented( line("fn to_string(&self) -> String {") + - indented( - line("match self {") + indented( - match_cases + line("match self {") + + indented( + match_cases + ) + + line("}") ) + line("}") - ) + - line("}") ) + line("}"); diff --git a/src/rust/printer.rs b/src/rust/printer.rs index 3cc0511..bfe0ee4 100644 --- a/src/rust/printer.rs +++ b/src/rust/printer.rs @@ -42,6 +42,7 @@ impl RustContext { } } +#[allow(clippy::to_string_trait_impl)] impl ToString for RustContext { #[allow(unstable_name_collisions)] fn to_string(&self) -> String { diff --git a/src/rust/types.rs b/src/rust/types.rs index beda103..1927491 100644 --- a/src/rust/types.rs +++ b/src/rust/types.rs @@ -42,6 +42,7 @@ pub enum IntFormat { I64, } +#[allow(clippy::to_string_trait_impl)] impl ToString for IntFormat { fn to_string(&self) -> String { match self {