From 4f394e1b9412ea7675387f9946d5585bb5b40e07 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 11:47:10 +0900 Subject: [PATCH 01/18] fix(rust-server): Use ok_or_else instead of ok_or --- .../src/main/resources/rust-server/models.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index b3196700380..7aa4b0c81f9 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -415,7 +415,7 @@ impl std::str::FromStr for {{{classname}}} { {{{name}}}: std::result::Result::Err("Nullable types not supported in {{{classname}}}".to_string())?, {{/isNullable}} {{^isNullable}} - {{{name}}}: intermediate_rep.{{{name}}}.into_iter().next(){{#required}}.ok_or("{{{baseName}}} missing in {{{classname}}}".to_string())?{{/required}}, + {{{name}}}: intermediate_rep.{{{name}}}.into_iter().next(){{#required}}.ok_or_else(|| "{{{baseName}}} missing in {{{classname}}}".to_string())?{{/required}}, {{/isNullable}} {{/vars}} }) -- GitLab From 72d9406a512abfcc09f64c1de7c61a7537490524 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 11:48:20 +0900 Subject: [PATCH 02/18] fix(rust-server): Remove empty format string --- .../src/main/resources/rust-server/models.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 7aa4b0c81f9..774a7158583 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -33,7 +33,7 @@ impl std::fmt::Display for {{{classname}}} { match *self { {{#allowableValues}} {{#enumVars}} - {{{classname}}}::{{{name}}} => write!(f, "{}", {{{value}}}), + {{{classname}}}::{{{name}}} => write!(f, {{{value}}}), {{/enumVars}} {{/allowableValues}} } -- GitLab From 10c1e725aac9ea98ed871ef5aefab3dded7822da Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 11:53:26 +0900 Subject: [PATCH 03/18] fix(rust-server): Remove redundant field names in struct initialisation --- .../src/main/resources/rust-server/models.mustache | 2 +- .../main/resources/rust-server/server-service-header.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 774a7158583..fe6d63ddd0f 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -276,7 +276,7 @@ pub struct {{{classname}}} { impl {{{classname}}} { pub fn new({{#vars}}{{^defaultValue}}{{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/vars}}) -> {{{classname}}} { {{{classname}}} { -{{#vars}} {{{name}}}: {{{defaultValue}}}{{^defaultValue}}{{{name}}}{{/defaultValue}}, +{{#vars}} {{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}}, {{/vars}} } } diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache index 76c0e9a8540..73f18f82c51 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache @@ -20,7 +20,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } -- GitLab From 9703b5fc2ba9234b505d6c51172330974c4c4e55 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:02:21 +0900 Subject: [PATCH 04/18] fix(rust-server): Remove redundant clones --- .../src/main/resources/rust-server/models.mustache | 12 ++++++------ .../resources/rust-server/server-operation.mustache | 2 +- .../rust-server/server-service-header.mustache | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index fe6d63ddd0f..524a682ca23 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -220,7 +220,7 @@ impl std::ops::DerefMut for {{{classname}}} { /// Should be implemented in a serde serializer impl std::string::ToString for {{{classname}}} { fn to_string(&self) -> String { - self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string() + self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") } } @@ -314,10 +314,10 @@ impl std::string::ToString for {{{classname}}} { {{/isArray}} {{#isArray}} {{#isNullable}} - params.push(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string())); + params.push(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))); {{/isNullable}} {{^isNullable}} - params.push(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); + params.push(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")); {{/isNullable}} {{/isArray}} {{/required}} @@ -334,17 +334,17 @@ impl std::string::ToString for {{{classname}}} { {{/isArray}} {{#isArray}} {{#isNullable}} - params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string())); + params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))); {{/isNullable}} {{^isNullable}} - params.push({{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); + params.push({{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")); {{/isNullable}} {{/isArray}} } {{/required}} {{/isPrimitiveType}}{{/isMap}}{{/isBinary}}{{/isByteArray}} {{/vars}} - params.join(",").to_string() + params.join(",") } } diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache index 0560d72e7db..b5e1bed5c7d 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache @@ -488,7 +488,7 @@ let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); {{#bodyParams}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache index 73f18f82c51..3da968d23bc 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache @@ -33,7 +33,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } -- GitLab From c384b5515afccc24c4162ecd580bee0fc8f3a841 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:03:18 +0900 Subject: [PATCH 05/18] fix(rust-server): Derive Eq with PartialEq always --- .../src/main/resources/rust-server/models.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 524a682ca23..3a3a5db64f7 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -58,10 +58,10 @@ impl std::str::FromStr for {{{classname}}} { {{^isEnum}} {{#dataType}} {{#isMap}} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] {{/isMap}} {{^isMap}} -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] {{/isMap}} #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] {{#xmlName}} @@ -146,7 +146,7 @@ where {{/x-item-xml-name}} {{/vendorExtensions}} {{! vec}} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct {{{classname}}}( {{#vendorExtensions}} @@ -243,7 +243,7 @@ impl std::str::FromStr for {{{classname}}} { {{/arrayModelType}} {{^arrayModelType}} {{! general struct}} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] {{#xmlName}} #[serde(rename = "{{{.}}}")] -- GitLab From 7885471dae2c30979e7fddd8467387f94b86509e Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:11:36 +0900 Subject: [PATCH 06/18] fix(rust-server): Remove immediately pushes replaced by vec macro --- .../resources/rust-server/models.mustache | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 3a3a5db64f7..942dbab13ab 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -287,63 +287,65 @@ impl {{{classname}}} { /// Should be implemented in a serde serializer impl std::string::ToString for {{{classname}}} { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ {{#vars}} {{#isByteArray}} - // Skipping {{baseName}} in query parameter serialization + // Skipping {{baseName}} in query parameter serialization {{/isByteArray}} {{#isBinary}} - // Skipping {{baseName}} in query parameter serialization + // Skipping {{baseName}} in query parameter serialization {{/isBinary}} {{#isMap}} - // Skipping {{baseName}} in query parameter serialization + // Skipping {{baseName}} in query parameter serialization {{/isMap}} {{^isPrimitiveType}} - // Skipping {{baseName}} in query parameter serialization + // Skipping {{baseName}} in query parameter serialization {{/isPrimitiveType}} {{^isByteArray}}{{^isBinary}}{{^isMap}}{{#isPrimitiveType}} {{#required}} - params.push("{{{baseName}}}".to_string()); + Some("{{{baseName}}}".to_string()), {{^isArray}} {{#isNullable}} - params.push(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string())); + Some(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string())), {{/isNullable}} {{^isNullable}} - params.push(self.{{{name}}}.to_string()); + Some(self.{{{name}}}.to_string()), {{/isNullable}} {{/isArray}} {{#isArray}} {{#isNullable}} - params.push(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))); + Some(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))), {{/isNullable}} {{^isNullable}} - params.push(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")); + Some(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")), {{/isNullable}} {{/isArray}} {{/required}} {{^required}} - if let Some(ref {{{name}}}) = self.{{{name}}} { - params.push("{{{baseName}}}".to_string()); + self.{{{name}}}.as_ref().map(|{{name}}}| { + "{{{baseName}}}".to_string() {{^isArray}} {{#isNullable}} - params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string())); + {{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()) {{/isNullable}} {{^isNullable}} - params.push({{{name}}}.to_string()); + {{{name}}}.to_string() {{/isNullable}} {{/isArray}} {{#isArray}} {{#isNullable}} - params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))); + {{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")) {{/isNullable}} {{^isNullable}} - params.push({{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")); + {{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") {{/isNullable}} {{/isArray}} - } + }, {{/required}} {{/isPrimitiveType}}{{/isMap}}{{/isBinary}}{{/isByteArray}} {{/vars}} + ].into_iter().flatten().collect(); + params.join(",") } } -- GitLab From 846afba4dd7abc2266da9bfd793642521549c6cf Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:12:53 +0900 Subject: [PATCH 07/18] fix(rust-server): Remove useless conversions --- .../src/main/resources/rust-server/models.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 942dbab13ab..2d52a9b9a24 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -368,7 +368,7 @@ impl std::str::FromStr for {{{classname}}} { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -396,7 +396,7 @@ impl std::str::FromStr for {{{classname}}} { "{{{baseName}}}" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in {{{classname}}}".to_string()), {{/isNullable}} {{^isNullable}} - "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), {{/isNullable}} {{/isContainer}} {{/isByteArray}} -- GitLab From d7c63215564e2d52a453c2168d92388fd446998f Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:17:56 +0900 Subject: [PATCH 08/18] fix(rust-server): Dismiss clippy::new_without_default --- .../src/main/resources/rust-server/models.mustache | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 2d52a9b9a24..81f0f343e94 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -274,6 +274,7 @@ pub struct {{{classname}}} { } impl {{{classname}}} { + #[allow(clippy::new_without_default)] pub fn new({{#vars}}{{^defaultValue}}{{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/vars}}) -> {{{classname}}} { {{{classname}}} { {{#vars}} {{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}}, -- GitLab From b3c6fdb79b3749d290edb616227c2082928fe66a Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:29:28 +0900 Subject: [PATCH 09/18] fix(rust-server): Fix compilation failures --- .../main/resources/rust-server/models.mustache | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 81f0f343e94..ef4ce04cbc2 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -323,25 +323,27 @@ impl std::string::ToString for {{{classname}}} { {{/isArray}} {{/required}} {{^required}} - self.{{{name}}}.as_ref().map(|{{name}}}| { - "{{{baseName}}}".to_string() + self.{{{name}}}.as_ref().map(|{{{name}}}| { + vec![ + "{{{baseName}}}".to_string(), {{^isArray}} {{#isNullable}} - {{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()) + {{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()), {{/isNullable}} {{^isNullable}} - {{{name}}}.to_string() + {{{name}}}.to_string(), {{/isNullable}} {{/isArray}} {{#isArray}} {{#isNullable}} - {{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")) + {{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")), {{/isNullable}} {{^isNullable}} - {{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") + {{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), {{/isNullable}} {{/isArray}} - }, + ].join(",") + }), {{/required}} {{/isPrimitiveType}}{{/isMap}}{{/isBinary}}{{/isByteArray}} {{/vars}} -- GitLab From 7e8550635784df3142b2a98895c65c56dd73826b Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:36:17 +0900 Subject: [PATCH 10/18] fix(rust-server): Resolve remaining warnings --- .../src/main/resources/rust-server/models.mustache | 2 +- .../src/main/resources/rust-server/response.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index ef4ce04cbc2..1ade263b22b 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -399,7 +399,7 @@ impl std::str::FromStr for {{{classname}}} { "{{{baseName}}}" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in {{{classname}}}".to_string()), {{/isNullable}} {{^isNullable}} - "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val){{#isString}}.map_err(|x| x.to_string()){{/isString}}?), {{/isNullable}} {{/isContainer}} {{/isByteArray}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/response.mustache b/modules/openapi-generator/src/main/resources/rust-server/response.mustache index ac74c0b4e2a..ac861c89b40 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/response.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/response.mustache @@ -1,4 +1,4 @@ -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] {{#vendorExtensions.x-must-use-response}} #[must_use] {{/vendorExtensions.x-must-use-response}} -- GitLab From 5d8810db139342cece557b2627374ac3d4c7064f Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 12:48:07 +0900 Subject: [PATCH 11/18] build(rust-server): Add newly generated samples of petstore --- .../output/multipart-v3/src/lib.rs | 6 +- .../output/multipart-v3/src/models.rs | 77 +- .../output/multipart-v3/src/server/mod.rs | 10 +- .../output/no-example-v3/src/lib.rs | 2 +- .../output/no-example-v3/src/models.rs | 23 +- .../output/no-example-v3/src/server/mod.rs | 6 +- .../output/openapi-v3/src/client/callbacks.rs | 8 +- .../rust-server/output/openapi-v3/src/lib.rs | 56 +- .../output/openapi-v3/src/models.rs | 410 ++--- .../output/openapi-v3/src/server/mod.rs | 56 +- .../rust-server/output/ops-v3/src/lib.rs | 74 +- .../output/ops-v3/src/server/mod.rs | 78 +- .../src/lib.rs | 70 +- .../src/models.rs | 1353 ++++++++++------- .../src/server/mod.rs | 74 +- .../output/ping-bearer-auth/src/lib.rs | 2 +- .../output/ping-bearer-auth/src/server/mod.rs | 6 +- .../output/rust-server-test/src/lib.rs | 18 +- .../output/rust-server-test/src/models.rs | 191 ++- .../output/rust-server-test/src/server/mod.rs | 22 +- 20 files changed, 1446 insertions(+), 1096 deletions(-) diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs index 8d8eb9a4ba3..32c0a66bd7c 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs @@ -13,19 +13,19 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MultipartRelatedRequestPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MultipartRequestPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MultipleIdenticalMimeTypesPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs index ca528ed40ac..5c40d9710ea 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRelatedRequest { #[serde(rename = "object_field")] @@ -21,11 +21,12 @@ pub struct MultipartRelatedRequest { } impl MultipartRelatedRequest { + #[allow(clippy::new_without_default)] pub fn new(required_binary_field: swagger::ByteArray, ) -> MultipartRelatedRequest { MultipartRelatedRequest { object_field: None, optional_binary_field: None, - required_binary_field: required_binary_field, + required_binary_field, } } } @@ -35,16 +36,18 @@ impl MultipartRelatedRequest { /// Should be implemented in a serde serializer impl std::string::ToString for MultipartRelatedRequest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping object_field in query parameter serialization + let params: Vec<String> = vec![ + // Skipping object_field in query parameter serialization - // Skipping optional_binary_field in query parameter serialization - // Skipping optional_binary_field in query parameter serialization + // Skipping optional_binary_field in query parameter serialization + // Skipping optional_binary_field in query parameter serialization - // Skipping required_binary_field in query parameter serialization - // Skipping required_binary_field in query parameter serialization + // Skipping required_binary_field in query parameter serialization + // Skipping required_binary_field in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -66,7 +69,7 @@ impl std::str::FromStr for MultipartRelatedRequest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -77,7 +80,7 @@ impl std::str::FromStr for MultipartRelatedRequest { if let Some(key) = key_result { match key { - "object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val)?), "optional_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()), "required_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MultipartRelatedRequest".to_string()) @@ -92,7 +95,7 @@ impl std::str::FromStr for MultipartRelatedRequest { std::result::Result::Ok(MultipartRelatedRequest { object_field: intermediate_rep.object_field.into_iter().next(), optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(), - required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or("required_binary_field missing in MultipartRelatedRequest".to_string())?, + required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or_else(|| "required_binary_field missing in MultipartRelatedRequest".to_string())?, }) } } @@ -136,7 +139,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRequestObjectField { #[serde(rename = "field_a")] @@ -149,9 +152,10 @@ pub struct MultipartRequestObjectField { } impl MultipartRequestObjectField { + #[allow(clippy::new_without_default)] pub fn new(field_a: String, ) -> MultipartRequestObjectField { MultipartRequestObjectField { - field_a: field_a, + field_a, field_b: None, } } @@ -162,18 +166,22 @@ impl MultipartRequestObjectField { /// Should be implemented in a serde serializer impl std::string::ToString for MultipartRequestObjectField { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("field_a".to_string()); - params.push(self.field_a.to_string()); + Some("field_a".to_string()), + Some(self.field_a.to_string()), - if let Some(ref field_b) = self.field_b { - params.push("field_b".to_string()); - params.push(field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.field_b.as_ref().map(|field_b| { + vec![ + "field_b".to_string(), + field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -194,7 +202,7 @@ impl std::str::FromStr for MultipartRequestObjectField { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -205,7 +213,7 @@ impl std::str::FromStr for MultipartRequestObjectField { if let Some(key) = key_result { match key { - "field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "field_b" => return std::result::Result::Err("Parsing a container in this style is not supported in MultipartRequestObjectField".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MultipartRequestObjectField".to_string()) } @@ -217,7 +225,7 @@ impl std::str::FromStr for MultipartRequestObjectField { // Use the intermediate representation to return the struct std::result::Result::Ok(MultipartRequestObjectField { - field_a: intermediate_rep.field_a.into_iter().next().ok_or("field_a missing in MultipartRequestObjectField".to_string())?, + field_a: intermediate_rep.field_a.into_iter().next().ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?, field_b: intermediate_rep.field_b.into_iter().next(), }) } @@ -262,7 +270,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipleIdenticalMimeTypesPostRequest { #[serde(rename = "binary1")] @@ -276,6 +284,7 @@ pub struct MultipleIdenticalMimeTypesPostRequest { } impl MultipleIdenticalMimeTypesPostRequest { + #[allow(clippy::new_without_default)] pub fn new() -> MultipleIdenticalMimeTypesPostRequest { MultipleIdenticalMimeTypesPostRequest { binary1: None, @@ -289,14 +298,16 @@ impl MultipleIdenticalMimeTypesPostRequest { /// Should be implemented in a serde serializer impl std::string::ToString for MultipleIdenticalMimeTypesPostRequest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping binary1 in query parameter serialization - // Skipping binary1 in query parameter serialization + let params: Vec<String> = vec![ + // Skipping binary1 in query parameter serialization + // Skipping binary1 in query parameter serialization + + // Skipping binary2 in query parameter serialization + // Skipping binary2 in query parameter serialization - // Skipping binary2 in query parameter serialization - // Skipping binary2 in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -317,7 +328,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs index 3330f223621..5082f49ae1f 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs @@ -109,7 +109,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -122,7 +122,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -257,7 +257,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -414,7 +414,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -523,7 +523,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs index 398896f5207..984b71ecaf3 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs @@ -13,7 +13,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "0.0.1"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum OpGetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs index fa170060bd9..7db39e0182f 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OpGetRequest { #[serde(rename = "propery")] @@ -14,6 +14,7 @@ pub struct OpGetRequest { } impl OpGetRequest { + #[allow(clippy::new_without_default)] pub fn new() -> OpGetRequest { OpGetRequest { propery: None, @@ -26,14 +27,18 @@ impl OpGetRequest { /// Should be implemented in a serde serializer impl std::string::ToString for OpGetRequest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref propery) = self.propery { - params.push("propery".to_string()); - params.push(propery.to_string()); - } + self.propery.as_ref().map(|propery| { + vec![ + "propery".to_string(), + propery.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -53,7 +58,7 @@ impl std::str::FromStr for OpGetRequest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -64,7 +69,7 @@ impl std::str::FromStr for OpGetRequest { if let Some(key) = key_result { match key { - "propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing OpGetRequest".to_string()) } } diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs index c8cced13d34..5a4f69112c7 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs @@ -98,7 +98,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -111,7 +111,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -178,7 +178,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index 082ae5911b1..ec3970b2bcb 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -112,7 +112,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -125,7 +125,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -193,7 +193,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -233,7 +233,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 87ddda8a314..09fd361799e 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -13,7 +13,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum AnyOfGetResponse { /// Success @@ -29,44 +29,44 @@ pub enum AnyOfGetResponse { (models::AnyOfGet202Response) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CallbackWithHeaderPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ComplexQueryParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum EnumInPathPathParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum JsonComplexQueryParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MandatoryRequestHeaderGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MergePatchJsonGetResponse { /// merge-patch+json-encoded response Merge (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum MultigetGetResponse { /// JSON rsp @@ -98,51 +98,51 @@ pub enum MultigetGetResponse { (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MultipleAuthSchemeGetResponse { /// Check that limiting to multiple required auth schemes works CheckThatLimitingToMultipleRequiredAuthSchemesWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum OneOfGetResponse { /// Success Success (models::OneOfGet200Response) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum OverrideServerGetResponse { /// Success. Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ParamgetGetResponse { /// JSON rsp JSONRsp (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ReadonlyAuthSchemeGetResponse { /// Check that limiting to a single required auth scheme works CheckThatLimitingToASingleRequiredAuthSchemeWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum RegisterCallbackPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum RequiredOctetStreamPutResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum ResponsesWithHeadersGetResponse { /// Success @@ -178,7 +178,7 @@ pub enum ResponsesWithHeadersGetResponse { } } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum Rfc7807GetResponse { /// OK @@ -194,20 +194,20 @@ pub enum Rfc7807GetResponse { (models::ObjectWithArrayOfObjects) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum UntypedPropertyGetResponse { /// Check that untyped properties works CheckThatUntypedPropertiesWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum UuidGetResponse { /// Duplicate Response long text. One. DuplicateResponseLongText (uuid::Uuid) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum XmlExtraPostResponse { /// OK @@ -217,7 +217,7 @@ pub enum XmlExtraPostResponse { BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum XmlOtherPostResponse { /// OK @@ -228,7 +228,7 @@ pub enum XmlOtherPostResponse { BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum XmlOtherPutResponse { /// OK @@ -238,7 +238,7 @@ pub enum XmlOtherPutResponse { BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum XmlPostResponse { /// OK @@ -248,7 +248,7 @@ pub enum XmlPostResponse { BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum XmlPutResponse { /// OK @@ -258,13 +258,13 @@ pub enum XmlPutResponse { BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CreateRepoResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum GetRepoInfoResponse { /// OK OK @@ -798,13 +798,13 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CallbackCallbackWithHeaderPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CallbackCallbackPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs index 6a7a2fab482..1ce0ffd70be 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesWithList(std::collections::HashMap<String, Vec<String>>); @@ -72,7 +72,7 @@ where serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner") } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnotherXmlArray( #[serde(serialize_with = "wrap_in_snake_another_xml_inner")] @@ -142,7 +142,7 @@ impl std::ops::DerefMut for AnotherXmlArray { /// Should be implemented in a serde serializer impl std::string::ToString for AnotherXmlArray { fn to_string(&self) -> String { - self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string() + self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") } } @@ -211,7 +211,7 @@ impl AnotherXmlArray { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "snake_another_xml_inner")] pub struct AnotherXmlInner(String); @@ -265,7 +265,7 @@ impl AnotherXmlInner { } /// An XML object -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "snake_another_xml_object")] pub struct AnotherXmlObject { @@ -276,6 +276,7 @@ pub struct AnotherXmlObject { } impl AnotherXmlObject { + #[allow(clippy::new_without_default)] pub fn new() -> AnotherXmlObject { AnotherXmlObject { inner_string: None, @@ -288,14 +289,18 @@ impl AnotherXmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for AnotherXmlObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref inner_string) = self.inner_string { - params.push("inner_string".to_string()); - params.push(inner_string.to_string()); - } + self.inner_string.as_ref().map(|inner_string| { + vec![ + "inner_string".to_string(), + inner_string.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -315,7 +320,7 @@ impl std::str::FromStr for AnotherXmlObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -326,7 +331,7 @@ impl std::str::FromStr for AnotherXmlObject { if let Some(key) = key_result { match key { - "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing AnotherXmlObject".to_string()) } } @@ -399,12 +404,13 @@ impl AnotherXmlObject { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfGet202Response { } impl AnyOfGet202Response { + #[allow(clippy::new_without_default)] pub fn new() -> AnyOfGet202Response { AnyOfGet202Response { } @@ -416,8 +422,10 @@ impl AnyOfGet202Response { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfGet202Response { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - params.join(",").to_string() + let params: Vec<String> = vec![ + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -436,7 +444,7 @@ impl std::str::FromStr for AnyOfGet202Response { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -510,12 +518,13 @@ impl AnyOfGet202Response { } /// Test a model containing an anyOf -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfObject { } impl AnyOfObject { + #[allow(clippy::new_without_default)] pub fn new() -> AnyOfObject { AnyOfObject { } @@ -527,8 +536,10 @@ impl AnyOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - params.join(",").to_string() + let params: Vec<String> = vec![ + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -547,7 +558,7 @@ impl std::str::FromStr for AnyOfObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -637,8 +648,8 @@ pub enum AnyOfObjectAnyOf { impl std::fmt::Display for AnyOfObjectAnyOf { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - AnyOfObjectAnyOf::Foo => write!(f, "{}", "FOO"), - AnyOfObjectAnyOf::Bar => write!(f, "{}", "BAR"), + AnyOfObjectAnyOf::Foo => write!(f, "FOO"), + AnyOfObjectAnyOf::Bar => write!(f, "BAR"), } } } @@ -665,7 +676,7 @@ impl AnyOfObjectAnyOf { } /// Test containing an anyOf object -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfProperty { #[serde(rename = "requiredAnyOf")] @@ -678,9 +689,10 @@ pub struct AnyOfProperty { } impl AnyOfProperty { + #[allow(clippy::new_without_default)] pub fn new(required_any_of: models::AnyOfObject, ) -> AnyOfProperty { AnyOfProperty { - required_any_of: required_any_of, + required_any_of, optional_any_of: None, } } @@ -691,12 +703,14 @@ impl AnyOfProperty { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfProperty { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping requiredAnyOf in query parameter serialization + let params: Vec<String> = vec![ + // Skipping requiredAnyOf in query parameter serialization - // Skipping optionalAnyOf in query parameter serialization + // Skipping optionalAnyOf in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -717,7 +731,7 @@ impl std::str::FromStr for AnyOfProperty { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -728,8 +742,8 @@ impl std::str::FromStr for AnyOfProperty { if let Some(key) = key_result { match key { - "requiredAnyOf" => intermediate_rep.required_any_of.push(<models::AnyOfObject as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "optionalAnyOf" => intermediate_rep.optional_any_of.push(<models::Model12345AnyOfObject as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "requiredAnyOf" => intermediate_rep.required_any_of.push(<models::AnyOfObject as std::str::FromStr>::from_str(val)?), + "optionalAnyOf" => intermediate_rep.optional_any_of.push(<models::Model12345AnyOfObject as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing AnyOfProperty".to_string()) } } @@ -740,7 +754,7 @@ impl std::str::FromStr for AnyOfProperty { // Use the intermediate representation to return the struct std::result::Result::Ok(AnyOfProperty { - required_any_of: intermediate_rep.required_any_of.into_iter().next().ok_or("requiredAnyOf missing in AnyOfProperty".to_string())?, + required_any_of: intermediate_rep.required_any_of.into_iter().next().ok_or_else(|| "requiredAnyOf missing in AnyOfProperty".to_string())?, optional_any_of: intermediate_rep.optional_any_of.into_iter().next(), }) } @@ -795,7 +809,7 @@ impl AnyOfProperty { } /// An XML object -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelDuplicateXmlObject")] pub struct DuplicateXmlObject { @@ -810,10 +824,11 @@ pub struct DuplicateXmlObject { } impl DuplicateXmlObject { + #[allow(clippy::new_without_default)] pub fn new(inner_array: models::XmlArray, ) -> DuplicateXmlObject { DuplicateXmlObject { inner_string: None, - inner_array: inner_array, + inner_array, } } } @@ -823,16 +838,20 @@ impl DuplicateXmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for DuplicateXmlObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref inner_string) = self.inner_string { - params.push("inner_string".to_string()); - params.push(inner_string.to_string()); - } + self.inner_string.as_ref().map(|inner_string| { + vec![ + "inner_string".to_string(), + inner_string.to_string(), + ].join(",") + }), + + // Skipping inner_array in query parameter serialization - // Skipping inner_array in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -853,7 +872,7 @@ impl std::str::FromStr for DuplicateXmlObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -864,8 +883,8 @@ impl std::str::FromStr for DuplicateXmlObject { if let Some(key) = key_result { match key { - "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "inner_array" => intermediate_rep.inner_array.push(<models::XmlArray as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "inner_array" => intermediate_rep.inner_array.push(<models::XmlArray as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing DuplicateXmlObject".to_string()) } } @@ -877,7 +896,7 @@ impl std::str::FromStr for DuplicateXmlObject { // Use the intermediate representation to return the struct std::result::Result::Ok(DuplicateXmlObject { inner_string: intermediate_rep.inner_string.into_iter().next(), - inner_array: intermediate_rep.inner_array.into_iter().next().ok_or("inner_array missing in DuplicateXmlObject".to_string())?, + inner_array: intermediate_rep.inner_array.into_iter().next().ok_or_else(|| "inner_array missing in DuplicateXmlObject".to_string())?, }) } } @@ -959,9 +978,9 @@ pub enum EnumWithStarObject { impl std::fmt::Display for EnumWithStarObject { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - EnumWithStarObject::Foo => write!(f, "{}", "FOO"), - EnumWithStarObject::Bar => write!(f, "{}", "BAR"), - EnumWithStarObject::Star => write!(f, "{}", "*"), + EnumWithStarObject::Foo => write!(f, "FOO"), + EnumWithStarObject::Bar => write!(f, "BAR"), + EnumWithStarObject::Star => write!(f, "*"), } } } @@ -988,7 +1007,7 @@ impl EnumWithStarObject { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Err(String); @@ -1040,7 +1059,7 @@ impl Err { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Error(String); @@ -1093,12 +1112,13 @@ impl Error { } /// Test a model containing an anyOf that starts with a number -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Model12345AnyOfObject { } impl Model12345AnyOfObject { + #[allow(clippy::new_without_default)] pub fn new() -> Model12345AnyOfObject { Model12345AnyOfObject { } @@ -1110,8 +1130,10 @@ impl Model12345AnyOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for Model12345AnyOfObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - params.join(",").to_string() + let params: Vec<String> = vec![ + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -1130,7 +1152,7 @@ impl std::str::FromStr for Model12345AnyOfObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1222,9 +1244,9 @@ pub enum Model12345AnyOfObjectAnyOf { impl std::fmt::Display for Model12345AnyOfObjectAnyOf { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - Model12345AnyOfObjectAnyOf::Foo => write!(f, "{}", "FOO"), - Model12345AnyOfObjectAnyOf::Bar => write!(f, "{}", "BAR"), - Model12345AnyOfObjectAnyOf::Star => write!(f, "{}", "*"), + Model12345AnyOfObjectAnyOf::Foo => write!(f, "FOO"), + Model12345AnyOfObjectAnyOf::Bar => write!(f, "BAR"), + Model12345AnyOfObjectAnyOf::Star => write!(f, "*"), } } } @@ -1251,7 +1273,7 @@ impl Model12345AnyOfObjectAnyOf { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultigetGet201Response { #[serde(rename = "foo")] @@ -1261,6 +1283,7 @@ pub struct MultigetGet201Response { } impl MultigetGet201Response { + #[allow(clippy::new_without_default)] pub fn new() -> MultigetGet201Response { MultigetGet201Response { foo: None, @@ -1273,14 +1296,18 @@ impl MultigetGet201Response { /// Should be implemented in a serde serializer impl std::string::ToString for MultigetGet201Response { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref foo) = self.foo { - params.push("foo".to_string()); - params.push(foo.to_string()); - } + self.foo.as_ref().map(|foo| { + vec![ + "foo".to_string(), + foo.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1300,7 +1327,7 @@ impl std::str::FromStr for MultigetGet201Response { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1311,7 +1338,7 @@ impl std::str::FromStr for MultigetGet201Response { if let Some(key) = key_result { match key { - "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing MultigetGet201Response".to_string()) } } @@ -1375,7 +1402,7 @@ impl MultigetGet201Response { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyId(i32); @@ -1414,7 +1441,7 @@ impl MyId { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyIdList( Vec<i32> @@ -1483,7 +1510,7 @@ impl std::ops::DerefMut for MyIdList { /// Should be implemented in a serde serializer impl std::string::ToString for MyIdList { fn to_string(&self) -> String { - self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string() + self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") } } @@ -1552,7 +1579,7 @@ impl MyIdList { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NullableTest { #[serde(rename = "nullable")] @@ -1585,9 +1612,10 @@ pub struct NullableTest { } impl NullableTest { + #[allow(clippy::new_without_default)] pub fn new(nullable: swagger::Nullable<String>, ) -> NullableTest { NullableTest { - nullable: nullable, + nullable, nullable_with_null_default: None, nullable_with_present_default: Some(swagger::Nullable::Present("default".to_string())), nullable_with_no_default: None, @@ -1601,36 +1629,46 @@ impl NullableTest { /// Should be implemented in a serde serializer impl std::string::ToString for NullableTest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("nullable".to_string()); - params.push(self.nullable.as_ref().map_or("null".to_string(), |x| x.to_string())); + Some("nullable".to_string()), + Some(self.nullable.as_ref().map_or("null".to_string(), |x| x.to_string())), - if let Some(ref nullable_with_null_default) = self.nullable_with_null_default { - params.push("nullableWithNullDefault".to_string()); - params.push(nullable_with_null_default.as_ref().map_or("null".to_string(), |x| x.to_string())); - } + self.nullable_with_null_default.as_ref().map(|nullable_with_null_default| { + vec![ + "nullableWithNullDefault".to_string(), + nullable_with_null_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), - if let Some(ref nullable_with_present_default) = self.nullable_with_present_default { - params.push("nullableWithPresentDefault".to_string()); - params.push(nullable_with_present_default.as_ref().map_or("null".to_string(), |x| x.to_string())); - } + self.nullable_with_present_default.as_ref().map(|nullable_with_present_default| { + vec![ + "nullableWithPresentDefault".to_string(), + nullable_with_present_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), - if let Some(ref nullable_with_no_default) = self.nullable_with_no_default { - params.push("nullableWithNoDefault".to_string()); - params.push(nullable_with_no_default.as_ref().map_or("null".to_string(), |x| x.to_string())); - } + self.nullable_with_no_default.as_ref().map(|nullable_with_no_default| { + vec![ + "nullableWithNoDefault".to_string(), + nullable_with_no_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), - if let Some(ref nullable_array) = self.nullable_array { - params.push("nullableArray".to_string()); - params.push(nullable_array.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string())); - } + self.nullable_array.as_ref().map(|nullable_array| { + vec![ + "nullableArray".to_string(), + nullable_array.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1654,7 +1692,7 @@ impl std::str::FromStr for NullableTest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1737,7 +1775,7 @@ impl NullableTest { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectHeader { #[serde(rename = "requiredObjectHeader")] @@ -1750,9 +1788,10 @@ pub struct ObjectHeader { } impl ObjectHeader { + #[allow(clippy::new_without_default)] pub fn new(required_object_header: bool, ) -> ObjectHeader { ObjectHeader { - required_object_header: required_object_header, + required_object_header, optional_object_header: None, } } @@ -1763,18 +1802,22 @@ impl ObjectHeader { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectHeader { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("requiredObjectHeader".to_string()); - params.push(self.required_object_header.to_string()); + Some("requiredObjectHeader".to_string()), + Some(self.required_object_header.to_string()), - if let Some(ref optional_object_header) = self.optional_object_header { - params.push("optionalObjectHeader".to_string()); - params.push(optional_object_header.to_string()); - } + self.optional_object_header.as_ref().map(|optional_object_header| { + vec![ + "optionalObjectHeader".to_string(), + optional_object_header.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1795,7 +1838,7 @@ impl std::str::FromStr for ObjectHeader { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1806,8 +1849,8 @@ impl std::str::FromStr for ObjectHeader { if let Some(key) = key_result { match key { - "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "optionalObjectHeader" => intermediate_rep.optional_object_header.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val)?), + "optionalObjectHeader" => intermediate_rep.optional_object_header.push(<isize as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectHeader".to_string()) } } @@ -1818,7 +1861,7 @@ impl std::str::FromStr for ObjectHeader { // Use the intermediate representation to return the struct std::result::Result::Ok(ObjectHeader { - required_object_header: intermediate_rep.required_object_header.into_iter().next().ok_or("requiredObjectHeader missing in ObjectHeader".to_string())?, + required_object_header: intermediate_rep.required_object_header.into_iter().next().ok_or_else(|| "requiredObjectHeader missing in ObjectHeader".to_string())?, optional_object_header: intermediate_rep.optional_object_header.into_iter().next(), }) } @@ -1872,7 +1915,7 @@ impl ObjectHeader { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectParam { #[serde(rename = "requiredParam")] @@ -1885,9 +1928,10 @@ pub struct ObjectParam { } impl ObjectParam { + #[allow(clippy::new_without_default)] pub fn new(required_param: bool, ) -> ObjectParam { ObjectParam { - required_param: required_param, + required_param, optional_param: None, } } @@ -1898,18 +1942,22 @@ impl ObjectParam { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectParam { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("requiredParam".to_string()); - params.push(self.required_param.to_string()); + Some("requiredParam".to_string()), + Some(self.required_param.to_string()), - if let Some(ref optional_param) = self.optional_param { - params.push("optionalParam".to_string()); - params.push(optional_param.to_string()); - } + self.optional_param.as_ref().map(|optional_param| { + vec![ + "optionalParam".to_string(), + optional_param.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1930,7 +1978,7 @@ impl std::str::FromStr for ObjectParam { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1941,8 +1989,8 @@ impl std::str::FromStr for ObjectParam { if let Some(key) = key_result { match key { - "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "optionalParam" => intermediate_rep.optional_param.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val)?), + "optionalParam" => intermediate_rep.optional_param.push(<isize as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectParam".to_string()) } } @@ -1953,7 +2001,7 @@ impl std::str::FromStr for ObjectParam { // Use the intermediate representation to return the struct std::result::Result::Ok(ObjectParam { - required_param: intermediate_rep.required_param.into_iter().next().ok_or("requiredParam missing in ObjectParam".to_string())?, + required_param: intermediate_rep.required_param.into_iter().next().ok_or_else(|| "requiredParam missing in ObjectParam".to_string())?, optional_param: intermediate_rep.optional_param.into_iter().next(), }) } @@ -2007,7 +2055,7 @@ impl ObjectParam { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectUntypedProps { #[serde(rename = "required_untyped")] @@ -2027,10 +2075,11 @@ pub struct ObjectUntypedProps { } impl ObjectUntypedProps { + #[allow(clippy::new_without_default)] pub fn new(required_untyped: serde_json::Value, required_untyped_nullable: swagger::Nullable<serde_json::Value>, ) -> ObjectUntypedProps { ObjectUntypedProps { - required_untyped: required_untyped, - required_untyped_nullable: required_untyped_nullable, + required_untyped, + required_untyped_nullable, not_required_untyped: None, not_required_untyped_nullable: None, } @@ -2042,16 +2091,18 @@ impl ObjectUntypedProps { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectUntypedProps { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping required_untyped in query parameter serialization + let params: Vec<String> = vec![ + // Skipping required_untyped in query parameter serialization + + // Skipping required_untyped_nullable in query parameter serialization - // Skipping required_untyped_nullable in query parameter serialization + // Skipping not_required_untyped in query parameter serialization - // Skipping not_required_untyped in query parameter serialization + // Skipping not_required_untyped_nullable in query parameter serialization - // Skipping not_required_untyped_nullable in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2074,7 +2125,7 @@ impl std::str::FromStr for ObjectUntypedProps { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2085,10 +2136,10 @@ impl std::str::FromStr for ObjectUntypedProps { if let Some(key) = key_result { match key { - "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), "required_untyped_nullable" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ObjectUntypedProps".to_string()), - "not_required_untyped" => intermediate_rep.not_required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "not_required_untyped_nullable" => intermediate_rep.not_required_untyped_nullable.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "not_required_untyped" => intermediate_rep.not_required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), + "not_required_untyped_nullable" => intermediate_rep.not_required_untyped_nullable.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectUntypedProps".to_string()) } } @@ -2099,7 +2150,7 @@ impl std::str::FromStr for ObjectUntypedProps { // Use the intermediate representation to return the struct std::result::Result::Ok(ObjectUntypedProps { - required_untyped: intermediate_rep.required_untyped.into_iter().next().ok_or("required_untyped missing in ObjectUntypedProps".to_string())?, + required_untyped: intermediate_rep.required_untyped.into_iter().next().ok_or_else(|| "required_untyped missing in ObjectUntypedProps".to_string())?, required_untyped_nullable: std::result::Result::Err("Nullable types not supported in ObjectUntypedProps".to_string())?, not_required_untyped: intermediate_rep.not_required_untyped.into_iter().next(), not_required_untyped_nullable: intermediate_rep.not_required_untyped_nullable.into_iter().next(), @@ -2155,7 +2206,7 @@ impl ObjectUntypedProps { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithArrayOfObjects { #[serde(rename = "objectArray")] @@ -2165,6 +2216,7 @@ pub struct ObjectWithArrayOfObjects { } impl ObjectWithArrayOfObjects { + #[allow(clippy::new_without_default)] pub fn new() -> ObjectWithArrayOfObjects { ObjectWithArrayOfObjects { object_array: None, @@ -2177,14 +2229,18 @@ impl ObjectWithArrayOfObjects { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectWithArrayOfObjects { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref object_array) = self.object_array { - params.push("objectArray".to_string()); - params.push(object_array.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.object_array.as_ref().map(|object_array| { + vec![ + "objectArray".to_string(), + object_array.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2204,7 +2260,7 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2279,7 +2335,7 @@ impl ObjectWithArrayOfObjects { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Ok(String); @@ -2331,12 +2387,13 @@ impl Ok { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OneOfGet200Response { } impl OneOfGet200Response { + #[allow(clippy::new_without_default)] pub fn new() -> OneOfGet200Response { OneOfGet200Response { } @@ -2348,8 +2405,10 @@ impl OneOfGet200Response { /// Should be implemented in a serde serializer impl std::string::ToString for OneOfGet200Response { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - params.join(",").to_string() + let params: Vec<String> = vec![ + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -2368,7 +2427,7 @@ impl std::str::FromStr for OneOfGet200Response { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2441,7 +2500,7 @@ impl OneOfGet200Response { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OptionalObjectHeader(i32); @@ -2480,7 +2539,7 @@ impl OptionalObjectHeader { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct RequiredObjectHeader(bool); @@ -2519,7 +2578,7 @@ impl RequiredObjectHeader { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Result(String); @@ -2588,8 +2647,8 @@ pub enum StringEnum { impl std::fmt::Display for StringEnum { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - StringEnum::Foo => write!(f, "{}", "FOO"), - StringEnum::Bar => write!(f, "{}", "BAR"), + StringEnum::Foo => write!(f, "FOO"), + StringEnum::Bar => write!(f, "BAR"), } } } @@ -2615,7 +2674,7 @@ impl StringEnum { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct StringObject(String); @@ -2668,7 +2727,7 @@ impl StringObject { } /// Test a model containing a UUID -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct UuidObject(uuid::Uuid); @@ -2716,7 +2775,7 @@ where serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner") } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct XmlArray( #[serde(serialize_with = "wrap_in_camelXmlInner")] @@ -2786,7 +2845,7 @@ impl std::ops::DerefMut for XmlArray { /// Should be implemented in a serde serializer impl std::string::ToString for XmlArray { fn to_string(&self) -> String { - self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string() + self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") } } @@ -2855,7 +2914,7 @@ impl XmlArray { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelXmlInner")] pub struct XmlInner(String); @@ -2909,7 +2968,7 @@ impl XmlInner { } /// An XML object -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelXmlObject")] pub struct XmlObject { @@ -2924,6 +2983,7 @@ pub struct XmlObject { } impl XmlObject { + #[allow(clippy::new_without_default)] pub fn new() -> XmlObject { XmlObject { inner_string: None, @@ -2937,20 +2997,26 @@ impl XmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for XmlObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref inner_string) = self.inner_string { - params.push("innerString".to_string()); - params.push(inner_string.to_string()); - } + self.inner_string.as_ref().map(|inner_string| { + vec![ + "innerString".to_string(), + inner_string.to_string(), + ].join(",") + }), - if let Some(ref other_inner_rename) = self.other_inner_rename { - params.push("other_inner_rename".to_string()); - params.push(other_inner_rename.to_string()); - } + self.other_inner_rename.as_ref().map(|other_inner_rename| { + vec![ + "other_inner_rename".to_string(), + other_inner_rename.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2971,7 +3037,7 @@ impl std::str::FromStr for XmlObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2982,8 +3048,8 @@ impl std::str::FromStr for XmlObject { if let Some(key) = key_result { match key { - "innerString" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "other_inner_rename" => intermediate_rep.other_inner_rename.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "innerString" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "other_inner_rename" => intermediate_rep.other_inner_rename.push(<isize as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing XmlObject".to_string()) } } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index 813b8d962d0..94dd4f34988 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -181,7 +181,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -194,7 +194,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -242,7 +242,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -328,7 +328,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -369,7 +369,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -422,7 +422,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -472,7 +472,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -525,7 +525,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -554,7 +554,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -590,7 +590,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -722,7 +722,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -751,7 +751,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -787,7 +787,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -873,7 +873,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -938,7 +938,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -995,7 +995,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1044,7 +1044,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1079,7 +1079,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1206,7 +1206,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1285,7 +1285,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1327,7 +1327,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1384,7 +1384,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1451,7 +1451,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1529,7 +1529,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1596,7 +1596,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1663,7 +1663,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1740,7 +1740,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1806,7 +1806,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs index 2c47196b1dd..4e56aec86df 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs @@ -13,223 +13,223 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "0.0.1"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op10GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op11GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op12GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op13GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op14GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op15GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op16GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op17GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op18GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op19GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op1GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op20GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op21GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op22GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op23GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op24GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op25GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op26GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op27GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op28GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op29GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op2GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op30GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op31GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op32GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op33GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op34GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op35GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op36GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op37GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op3GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op4GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op5GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op6GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op7GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op8GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Op9GetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index 438fe894ae9..1e020af6477 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -206,7 +206,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -219,7 +219,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -255,7 +255,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -284,7 +284,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -313,7 +313,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -342,7 +342,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -371,7 +371,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -400,7 +400,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -429,7 +429,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -458,7 +458,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -487,7 +487,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -516,7 +516,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -545,7 +545,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -574,7 +574,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -603,7 +603,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -632,7 +632,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -661,7 +661,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -690,7 +690,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -719,7 +719,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -748,7 +748,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -777,7 +777,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -806,7 +806,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -835,7 +835,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -864,7 +864,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -893,7 +893,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -922,7 +922,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -951,7 +951,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -980,7 +980,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1009,7 +1009,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1038,7 +1038,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1067,7 +1067,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1096,7 +1096,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1125,7 +1125,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1154,7 +1154,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1183,7 +1183,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1212,7 +1212,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1241,7 +1241,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1270,7 +1270,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1299,7 +1299,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index f011e13ecb2..e6112b13787 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -13,73 +13,73 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = "/v2"; pub const API_VERSION: &str = "1.0.0"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestSpecialTagsResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Call123exampleResponse { /// success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FakeOuterBooleanSerializeResponse { /// Output boolean OutputBoolean (bool) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FakeOuterCompositeSerializeResponse { /// Output composite OutputComposite (models::OuterComposite) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FakeOuterNumberSerializeResponse { /// Output number OutputNumber (f64) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FakeOuterStringSerializeResponse { /// Output string OutputString (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FakeResponseWithNumericalDescriptionResponse { /// 1234 Status200 } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum HyphenParamResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestBodyWithQueryParamsResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestClientModelResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum TestEndpointParametersResponse { /// Invalid username supplied @@ -89,7 +89,7 @@ pub enum TestEndpointParametersResponse { UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum TestEnumParametersResponse { /// Invalid request @@ -99,38 +99,38 @@ pub enum TestEnumParametersResponse { NotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestInlineAdditionalPropertiesResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestJsonFormDataResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TestClassnameResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum AddPetResponse { /// Invalid input InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum DeletePetResponse { /// Invalid pet value InvalidPetValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum FindPetsByStatusResponse { /// successful operation @@ -141,7 +141,7 @@ pub enum FindPetsByStatusResponse { InvalidStatusValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum FindPetsByTagsResponse { /// successful operation @@ -152,7 +152,7 @@ pub enum FindPetsByTagsResponse { InvalidTagValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum GetPetByIdResponse { /// successful operation @@ -166,7 +166,7 @@ pub enum GetPetByIdResponse { PetNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum UpdatePetResponse { /// Invalid ID supplied @@ -179,20 +179,20 @@ pub enum UpdatePetResponse { ValidationException } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum UpdatePetWithFormResponse { /// Invalid input InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum UploadFileResponse { /// successful operation SuccessfulOperation (models::ApiResponse) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum DeleteOrderResponse { /// Invalid ID supplied @@ -202,14 +202,14 @@ pub enum DeleteOrderResponse { OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum GetInventoryResponse { /// successful operation SuccessfulOperation (std::collections::HashMap<String, i32>) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum GetOrderByIdResponse { /// successful operation @@ -223,7 +223,7 @@ pub enum GetOrderByIdResponse { OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum PlaceOrderResponse { /// successful operation @@ -234,25 +234,25 @@ pub enum PlaceOrderResponse { InvalidOrder } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CreateUserResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CreateUsersWithArrayInputResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CreateUsersWithListInputResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum DeleteUserResponse { /// Invalid username supplied @@ -262,7 +262,7 @@ pub enum DeleteUserResponse { UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum GetUserByNameResponse { /// successful operation @@ -276,7 +276,7 @@ pub enum GetUserByNameResponse { UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum LoginUserResponse { /// successful operation @@ -298,13 +298,13 @@ pub enum LoginUserResponse { InvalidUsername } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum LogoutUserResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[must_use] pub enum UpdateUserResponse { /// Invalid user supplied diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index df387fdf1d5..63823a6e680 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesClass { #[serde(rename = "map_property")] @@ -18,6 +18,7 @@ pub struct AdditionalPropertiesClass { } impl AdditionalPropertiesClass { + #[allow(clippy::new_without_default)] pub fn new() -> AdditionalPropertiesClass { AdditionalPropertiesClass { map_property: None, @@ -31,13 +32,15 @@ impl AdditionalPropertiesClass { /// Should be implemented in a serde serializer impl std::string::ToString for AdditionalPropertiesClass { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping map_property in query parameter serialization + let params: Vec<String> = vec![ + // Skipping map_property in query parameter serialization - // Skipping map_of_map_property in query parameter serialization - // Skipping map_of_map_property in query parameter serialization + // Skipping map_of_map_property in query parameter serialization + // Skipping map_of_map_property in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -58,7 +61,7 @@ impl std::str::FromStr for AdditionalPropertiesClass { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -135,7 +138,7 @@ impl AdditionalPropertiesClass { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Animal { #[serde(rename = "className")] @@ -148,9 +151,10 @@ pub struct Animal { } impl Animal { + #[allow(clippy::new_without_default)] pub fn new(class_name: String, ) -> Animal { Animal { - class_name: class_name, + class_name, color: Some("red".to_string()), } } @@ -161,18 +165,22 @@ impl Animal { /// Should be implemented in a serde serializer impl std::string::ToString for Animal { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("className".to_string()); - params.push(self.class_name.to_string()); + Some("className".to_string()), + Some(self.class_name.to_string()), - if let Some(ref color) = self.color { - params.push("color".to_string()); - params.push(color.to_string()); - } + self.color.as_ref().map(|color| { + vec![ + "color".to_string(), + color.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -193,7 +201,7 @@ impl std::str::FromStr for Animal { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -204,8 +212,8 @@ impl std::str::FromStr for Animal { if let Some(key) = key_result { match key { - "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Animal".to_string()) } } @@ -216,7 +224,7 @@ impl std::str::FromStr for Animal { // Use the intermediate representation to return the struct std::result::Result::Ok(Animal { - class_name: intermediate_rep.class_name.into_iter().next().ok_or("className missing in Animal".to_string())?, + class_name: intermediate_rep.class_name.into_iter().next().ok_or_else(|| "className missing in Animal".to_string())?, color: intermediate_rep.color.into_iter().next(), }) } @@ -270,7 +278,7 @@ impl Animal { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnimalFarm( Vec<Animal> @@ -339,7 +347,7 @@ impl std::ops::DerefMut for AnimalFarm { /// Should be implemented in a serde serializer impl std::string::ToString for AnimalFarm { fn to_string(&self) -> String { - self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string() + self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",") } } @@ -408,7 +416,7 @@ impl AnimalFarm { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ApiResponse { #[serde(rename = "code")] @@ -426,6 +434,7 @@ pub struct ApiResponse { } impl ApiResponse { + #[allow(clippy::new_without_default)] pub fn new() -> ApiResponse { ApiResponse { code: None, @@ -440,26 +449,34 @@ impl ApiResponse { /// Should be implemented in a serde serializer impl std::string::ToString for ApiResponse { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref code) = self.code { - params.push("code".to_string()); - params.push(code.to_string()); - } + self.code.as_ref().map(|code| { + vec![ + "code".to_string(), + code.to_string(), + ].join(",") + }), - if let Some(ref r#type) = self.r#type { - params.push("type".to_string()); - params.push(r#type.to_string()); - } + self.r#type.as_ref().map(|r#type| { + vec![ + "type".to_string(), + r#type.to_string(), + ].join(",") + }), - if let Some(ref message) = self.message { - params.push("message".to_string()); - params.push(message.to_string()); - } + self.message.as_ref().map(|message| { + vec![ + "message".to_string(), + message.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -481,7 +498,7 @@ impl std::str::FromStr for ApiResponse { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -492,9 +509,9 @@ impl std::str::FromStr for ApiResponse { if let Some(key) = key_result { match key { - "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "type" => intermediate_rep.r#type.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "message" => intermediate_rep.message.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val)?), + "type" => intermediate_rep.r#type.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "message" => intermediate_rep.message.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ApiResponse".to_string()) } } @@ -560,7 +577,7 @@ impl ApiResponse { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfArrayOfNumberOnly { #[serde(rename = "ArrayArrayNumber")] @@ -570,6 +587,7 @@ pub struct ArrayOfArrayOfNumberOnly { } impl ArrayOfArrayOfNumberOnly { + #[allow(clippy::new_without_default)] pub fn new() -> ArrayOfArrayOfNumberOnly { ArrayOfArrayOfNumberOnly { array_array_number: None, @@ -582,10 +600,12 @@ impl ArrayOfArrayOfNumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayOfArrayOfNumberOnly { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping ArrayArrayNumber in query parameter serialization + let params: Vec<String> = vec![ + // Skipping ArrayArrayNumber in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -605,7 +625,7 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -680,7 +700,7 @@ impl ArrayOfArrayOfNumberOnly { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfNumberOnly { #[serde(rename = "ArrayNumber")] @@ -690,6 +710,7 @@ pub struct ArrayOfNumberOnly { } impl ArrayOfNumberOnly { + #[allow(clippy::new_without_default)] pub fn new() -> ArrayOfNumberOnly { ArrayOfNumberOnly { array_number: None, @@ -702,14 +723,18 @@ impl ArrayOfNumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayOfNumberOnly { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref array_number) = self.array_number { - params.push("ArrayNumber".to_string()); - params.push(array_number.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.array_number.as_ref().map(|array_number| { + vec![ + "ArrayNumber".to_string(), + array_number.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -729,7 +754,7 @@ impl std::str::FromStr for ArrayOfNumberOnly { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -804,7 +829,7 @@ impl ArrayOfNumberOnly { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayTest { #[serde(rename = "array_of_string")] @@ -827,6 +852,7 @@ pub struct ArrayTest { } impl ArrayTest { + #[allow(clippy::new_without_default)] pub fn new() -> ArrayTest { ArrayTest { array_of_string: None, @@ -842,24 +868,30 @@ impl ArrayTest { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayTest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref array_of_string) = self.array_of_string { - params.push("array_of_string".to_string()); - params.push(array_of_string.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.array_of_string.as_ref().map(|array_of_string| { + vec![ + "array_of_string".to_string(), + array_of_string.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), - // Skipping array_array_of_integer in query parameter serialization + // Skipping array_array_of_integer in query parameter serialization - // Skipping array_array_of_model in query parameter serialization + // Skipping array_array_of_model in query parameter serialization - if let Some(ref array_of_enum) = self.array_of_enum { - params.push("array_of_enum".to_string()); - params.push(array_of_enum.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.array_of_enum.as_ref().map(|array_of_enum| { + vec![ + "array_of_enum".to_string(), + array_of_enum.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -882,7 +914,7 @@ impl std::str::FromStr for ArrayTest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -963,7 +995,7 @@ impl ArrayTest { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Capitalization { #[serde(rename = "smallCamel")] @@ -994,6 +1026,7 @@ pub struct Capitalization { } impl Capitalization { + #[allow(clippy::new_without_default)] pub fn new() -> Capitalization { Capitalization { small_camel: None, @@ -1011,44 +1044,58 @@ impl Capitalization { /// Should be implemented in a serde serializer impl std::string::ToString for Capitalization { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref small_camel) = self.small_camel { - params.push("smallCamel".to_string()); - params.push(small_camel.to_string()); - } + self.small_camel.as_ref().map(|small_camel| { + vec![ + "smallCamel".to_string(), + small_camel.to_string(), + ].join(",") + }), - if let Some(ref capital_camel) = self.capital_camel { - params.push("CapitalCamel".to_string()); - params.push(capital_camel.to_string()); - } + self.capital_camel.as_ref().map(|capital_camel| { + vec![ + "CapitalCamel".to_string(), + capital_camel.to_string(), + ].join(",") + }), - if let Some(ref small_snake) = self.small_snake { - params.push("small_Snake".to_string()); - params.push(small_snake.to_string()); - } + self.small_snake.as_ref().map(|small_snake| { + vec![ + "small_Snake".to_string(), + small_snake.to_string(), + ].join(",") + }), - if let Some(ref capital_snake) = self.capital_snake { - params.push("Capital_Snake".to_string()); - params.push(capital_snake.to_string()); - } + self.capital_snake.as_ref().map(|capital_snake| { + vec![ + "Capital_Snake".to_string(), + capital_snake.to_string(), + ].join(",") + }), - if let Some(ref sca_eth_flow_points) = self.sca_eth_flow_points { - params.push("SCA_ETH_Flow_Points".to_string()); - params.push(sca_eth_flow_points.to_string()); - } + self.sca_eth_flow_points.as_ref().map(|sca_eth_flow_points| { + vec![ + "SCA_ETH_Flow_Points".to_string(), + sca_eth_flow_points.to_string(), + ].join(",") + }), - if let Some(ref att_name) = self.att_name { - params.push("ATT_NAME".to_string()); - params.push(att_name.to_string()); - } + self.att_name.as_ref().map(|att_name| { + vec![ + "ATT_NAME".to_string(), + att_name.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -1073,7 +1120,7 @@ impl std::str::FromStr for Capitalization { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1084,12 +1131,12 @@ impl std::str::FromStr for Capitalization { if let Some(key) = key_result { match key { - "smallCamel" => intermediate_rep.small_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "CapitalCamel" => intermediate_rep.capital_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "small_Snake" => intermediate_rep.small_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "Capital_Snake" => intermediate_rep.capital_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "SCA_ETH_Flow_Points" => intermediate_rep.sca_eth_flow_points.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "ATT_NAME" => intermediate_rep.att_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "smallCamel" => intermediate_rep.small_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "CapitalCamel" => intermediate_rep.capital_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "small_Snake" => intermediate_rep.small_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "Capital_Snake" => intermediate_rep.capital_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "SCA_ETH_Flow_Points" => intermediate_rep.sca_eth_flow_points.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "ATT_NAME" => intermediate_rep.att_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Capitalization".to_string()) } } @@ -1158,7 +1205,7 @@ impl Capitalization { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Cat { #[serde(rename = "className")] @@ -1175,9 +1222,10 @@ pub struct Cat { } impl Cat { + #[allow(clippy::new_without_default)] pub fn new(class_name: String, ) -> Cat { Cat { - class_name: class_name, + class_name, color: Some("red".to_string()), declawed: None, } @@ -1189,24 +1237,30 @@ impl Cat { /// Should be implemented in a serde serializer impl std::string::ToString for Cat { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("className".to_string()); - params.push(self.class_name.to_string()); + Some("className".to_string()), + Some(self.class_name.to_string()), - if let Some(ref color) = self.color { - params.push("color".to_string()); - params.push(color.to_string()); - } + self.color.as_ref().map(|color| { + vec![ + "color".to_string(), + color.to_string(), + ].join(",") + }), - if let Some(ref declawed) = self.declawed { - params.push("declawed".to_string()); - params.push(declawed.to_string()); - } + self.declawed.as_ref().map(|declawed| { + vec![ + "declawed".to_string(), + declawed.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -1228,7 +1282,7 @@ impl std::str::FromStr for Cat { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1239,9 +1293,9 @@ impl std::str::FromStr for Cat { if let Some(key) = key_result { match key { - "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing Cat".to_string()) } } @@ -1252,7 +1306,7 @@ impl std::str::FromStr for Cat { // Use the intermediate representation to return the struct std::result::Result::Ok(Cat { - class_name: intermediate_rep.class_name.into_iter().next().ok_or("className missing in Cat".to_string())?, + class_name: intermediate_rep.class_name.into_iter().next().ok_or_else(|| "className missing in Cat".to_string())?, color: intermediate_rep.color.into_iter().next(), declawed: intermediate_rep.declawed.into_iter().next(), }) @@ -1307,7 +1361,7 @@ impl Cat { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct CatAllOf { #[serde(rename = "declawed")] @@ -1317,6 +1371,7 @@ pub struct CatAllOf { } impl CatAllOf { + #[allow(clippy::new_without_default)] pub fn new() -> CatAllOf { CatAllOf { declawed: None, @@ -1329,14 +1384,18 @@ impl CatAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for CatAllOf { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref declawed) = self.declawed { - params.push("declawed".to_string()); - params.push(declawed.to_string()); - } + self.declawed.as_ref().map(|declawed| { + vec![ + "declawed".to_string(), + declawed.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1356,7 +1415,7 @@ impl std::str::FromStr for CatAllOf { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1367,7 +1426,7 @@ impl std::str::FromStr for CatAllOf { if let Some(key) = key_result { match key { - "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing CatAllOf".to_string()) } } @@ -1431,7 +1490,7 @@ impl CatAllOf { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Category")] pub struct Category { @@ -1446,6 +1505,7 @@ pub struct Category { } impl Category { + #[allow(clippy::new_without_default)] pub fn new() -> Category { Category { id: None, @@ -1459,20 +1519,26 @@ impl Category { /// Should be implemented in a serde serializer impl std::string::ToString for Category { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref id) = self.id { - params.push("id".to_string()); - params.push(id.to_string()); - } + self.id.as_ref().map(|id| { + vec![ + "id".to_string(), + id.to_string(), + ].join(",") + }), - if let Some(ref name) = self.name { - params.push("name".to_string()); - params.push(name.to_string()); - } + self.name.as_ref().map(|name| { + vec![ + "name".to_string(), + name.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -1493,7 +1559,7 @@ impl std::str::FromStr for Category { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1504,8 +1570,8 @@ impl std::str::FromStr for Category { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Category".to_string()) } } @@ -1571,7 +1637,7 @@ impl Category { } /// Model for testing model with \"_class\" property -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ClassModel { #[serde(rename = "_class")] @@ -1581,6 +1647,7 @@ pub struct ClassModel { } impl ClassModel { + #[allow(clippy::new_without_default)] pub fn new() -> ClassModel { ClassModel { _class: None, @@ -1593,14 +1660,18 @@ impl ClassModel { /// Should be implemented in a serde serializer impl std::string::ToString for ClassModel { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref _class) = self._class { - params.push("_class".to_string()); - params.push(_class.to_string()); - } + self._class.as_ref().map(|_class| { + vec![ + "_class".to_string(), + _class.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -1620,7 +1691,7 @@ impl std::str::FromStr for ClassModel { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1631,7 +1702,7 @@ impl std::str::FromStr for ClassModel { if let Some(key) = key_result { match key { - "_class" => intermediate_rep._class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "_class" => intermediate_rep._class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ClassModel".to_string()) } } @@ -1695,7 +1766,7 @@ impl ClassModel { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Client { #[serde(rename = "client")] @@ -1705,6 +1776,7 @@ pub struct Client { } impl Client { + #[allow(clippy::new_without_default)] pub fn new() -> Client { Client { client: None, @@ -1717,14 +1789,18 @@ impl Client { /// Should be implemented in a serde serializer impl std::string::ToString for Client { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref client) = self.client { - params.push("client".to_string()); - params.push(client.to_string()); - } + self.client.as_ref().map(|client| { + vec![ + "client".to_string(), + client.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1744,7 +1820,7 @@ impl std::str::FromStr for Client { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1755,7 +1831,7 @@ impl std::str::FromStr for Client { if let Some(key) = key_result { match key { - "client" => intermediate_rep.client.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "client" => intermediate_rep.client.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Client".to_string()) } } @@ -1819,7 +1895,7 @@ impl Client { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Dog { #[serde(rename = "className")] @@ -1836,9 +1912,10 @@ pub struct Dog { } impl Dog { + #[allow(clippy::new_without_default)] pub fn new(class_name: String, ) -> Dog { Dog { - class_name: class_name, + class_name, color: Some("red".to_string()), breed: None, } @@ -1850,24 +1927,30 @@ impl Dog { /// Should be implemented in a serde serializer impl std::string::ToString for Dog { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("className".to_string()); - params.push(self.class_name.to_string()); + Some("className".to_string()), + Some(self.class_name.to_string()), - if let Some(ref color) = self.color { - params.push("color".to_string()); - params.push(color.to_string()); - } + self.color.as_ref().map(|color| { + vec![ + "color".to_string(), + color.to_string(), + ].join(",") + }), - if let Some(ref breed) = self.breed { - params.push("breed".to_string()); - params.push(breed.to_string()); - } + self.breed.as_ref().map(|breed| { + vec![ + "breed".to_string(), + breed.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -1889,7 +1972,7 @@ impl std::str::FromStr for Dog { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -1900,9 +1983,9 @@ impl std::str::FromStr for Dog { if let Some(key) = key_result { match key { - "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Dog".to_string()) } } @@ -1913,7 +1996,7 @@ impl std::str::FromStr for Dog { // Use the intermediate representation to return the struct std::result::Result::Ok(Dog { - class_name: intermediate_rep.class_name.into_iter().next().ok_or("className missing in Dog".to_string())?, + class_name: intermediate_rep.class_name.into_iter().next().ok_or_else(|| "className missing in Dog".to_string())?, color: intermediate_rep.color.into_iter().next(), breed: intermediate_rep.breed.into_iter().next(), }) @@ -1968,7 +2051,7 @@ impl Dog { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DogAllOf { #[serde(rename = "breed")] @@ -1978,6 +2061,7 @@ pub struct DogAllOf { } impl DogAllOf { + #[allow(clippy::new_without_default)] pub fn new() -> DogAllOf { DogAllOf { breed: None, @@ -1990,14 +2074,18 @@ impl DogAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for DogAllOf { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref breed) = self.breed { - params.push("breed".to_string()); - params.push(breed.to_string()); - } + self.breed.as_ref().map(|breed| { + vec![ + "breed".to_string(), + breed.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2017,7 +2105,7 @@ impl std::str::FromStr for DogAllOf { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2028,7 +2116,7 @@ impl std::str::FromStr for DogAllOf { if let Some(key) = key_result { match key { - "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DogAllOf".to_string()) } } @@ -2092,7 +2180,7 @@ impl DogAllOf { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "$special[model.name]")] pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { @@ -2103,6 +2191,7 @@ pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { } impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { + #[allow(clippy::new_without_default)] pub fn new() -> DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { dollar_special_left_square_bracket_property_period_name_right_square_bracket: None, @@ -2115,14 +2204,18 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { /// Should be implemented in a serde serializer impl std::string::ToString for DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref dollar_special_left_square_bracket_property_period_name_right_square_bracket) = self.dollar_special_left_square_bracket_property_period_name_right_square_bracket { - params.push("$special[property.name]".to_string()); - params.push(dollar_special_left_square_bracket_property_period_name_right_square_bracket.to_string()); - } + self.dollar_special_left_square_bracket_property_period_name_right_square_bracket.as_ref().map(|dollar_special_left_square_bracket_property_period_name_right_square_bracket| { + vec![ + "$special[property.name]".to_string(), + dollar_special_left_square_bracket_property_period_name_right_square_bracket.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -2142,7 +2235,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2153,7 +2246,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu if let Some(key) = key_result { match key { - "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket".to_string()) } } @@ -2217,7 +2310,7 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumArrays { // Note: inline enums are not fully supported by openapi-generator @@ -2238,6 +2331,7 @@ pub struct EnumArrays { } impl EnumArrays { + #[allow(clippy::new_without_default)] pub fn new() -> EnumArrays { EnumArrays { just_symbol: None, @@ -2252,22 +2346,28 @@ impl EnumArrays { /// Should be implemented in a serde serializer impl std::string::ToString for EnumArrays { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref just_symbol) = self.just_symbol { - params.push("just_symbol".to_string()); - params.push(just_symbol.to_string()); - } + self.just_symbol.as_ref().map(|just_symbol| { + vec![ + "just_symbol".to_string(), + just_symbol.to_string(), + ].join(",") + }), - if let Some(ref array_enum) = self.array_enum { - params.push("array_enum".to_string()); - params.push(array_enum.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); - } + self.array_enum.as_ref().map(|array_enum| { + vec![ + "array_enum".to_string(), + array_enum.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","), + ].join(",") + }), - // Skipping array_array_enum in query parameter serialization + // Skipping array_array_enum in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -2289,7 +2389,7 @@ impl std::str::FromStr for EnumArrays { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2300,7 +2400,7 @@ impl std::str::FromStr for EnumArrays { if let Some(key) = key_result { match key { - "just_symbol" => intermediate_rep.just_symbol.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "just_symbol" => intermediate_rep.just_symbol.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), "array_array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing EnumArrays".to_string()) @@ -2387,9 +2487,9 @@ pub enum EnumClass { impl std::fmt::Display for EnumClass { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - EnumClass::Abc => write!(f, "{}", "_abc"), - EnumClass::Efg => write!(f, "{}", "-efg"), - EnumClass::LeftParenthesisXyzRightParenthesis => write!(f, "{}", "(xyz)"), + EnumClass::Abc => write!(f, "_abc"), + EnumClass::Efg => write!(f, "-efg"), + EnumClass::LeftParenthesisXyzRightParenthesis => write!(f, "(xyz)"), } } } @@ -2416,7 +2516,7 @@ impl EnumClass { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumTest { // Note: inline enums are not fully supported by openapi-generator @@ -2445,10 +2545,11 @@ pub struct EnumTest { } impl EnumTest { + #[allow(clippy::new_without_default)] pub fn new(enum_string_required: String, ) -> EnumTest { EnumTest { enum_string: None, - enum_string_required: enum_string_required, + enum_string_required, enum_integer: None, enum_number: None, outer_enum: None, @@ -2461,32 +2562,40 @@ impl EnumTest { /// Should be implemented in a serde serializer impl std::string::ToString for EnumTest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref enum_string) = self.enum_string { - params.push("enum_string".to_string()); - params.push(enum_string.to_string()); - } + self.enum_string.as_ref().map(|enum_string| { + vec![ + "enum_string".to_string(), + enum_string.to_string(), + ].join(",") + }), - params.push("enum_string_required".to_string()); - params.push(self.enum_string_required.to_string()); + Some("enum_string_required".to_string()), + Some(self.enum_string_required.to_string()), - if let Some(ref enum_integer) = self.enum_integer { - params.push("enum_integer".to_string()); - params.push(enum_integer.to_string()); - } + self.enum_integer.as_ref().map(|enum_integer| { + vec![ + "enum_integer".to_string(), + enum_integer.to_string(), + ].join(",") + }), - if let Some(ref enum_number) = self.enum_number { - params.push("enum_number".to_string()); - params.push(enum_number.to_string()); - } + self.enum_number.as_ref().map(|enum_number| { + vec![ + "enum_number".to_string(), + enum_number.to_string(), + ].join(",") + }), + + // Skipping outerEnum in query parameter serialization - // Skipping outerEnum in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2510,7 +2619,7 @@ impl std::str::FromStr for EnumTest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2521,11 +2630,11 @@ impl std::str::FromStr for EnumTest { if let Some(key) = key_result { match key { - "enum_string" => intermediate_rep.enum_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "enum_string_required" => intermediate_rep.enum_string_required.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "enum_integer" => intermediate_rep.enum_integer.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "enum_number" => intermediate_rep.enum_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "outerEnum" => intermediate_rep.outer_enum.push(<models::OuterEnum as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "enum_string" => intermediate_rep.enum_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "enum_string_required" => intermediate_rep.enum_string_required.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "enum_integer" => intermediate_rep.enum_integer.push(<i32 as std::str::FromStr>::from_str(val)?), + "enum_number" => intermediate_rep.enum_number.push(<f64 as std::str::FromStr>::from_str(val)?), + "outerEnum" => intermediate_rep.outer_enum.push(<models::OuterEnum as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing EnumTest".to_string()) } } @@ -2537,7 +2646,7 @@ impl std::str::FromStr for EnumTest { // Use the intermediate representation to return the struct std::result::Result::Ok(EnumTest { enum_string: intermediate_rep.enum_string.into_iter().next(), - enum_string_required: intermediate_rep.enum_string_required.into_iter().next().ok_or("enum_string_required missing in EnumTest".to_string())?, + enum_string_required: intermediate_rep.enum_string_required.into_iter().next().ok_or_else(|| "enum_string_required missing in EnumTest".to_string())?, enum_integer: intermediate_rep.enum_integer.into_iter().next(), enum_number: intermediate_rep.enum_number.into_iter().next(), outer_enum: intermediate_rep.outer_enum.into_iter().next(), @@ -2593,7 +2702,7 @@ impl EnumTest { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct FormatTest { #[serde(rename = "integer")] @@ -2647,21 +2756,22 @@ pub struct FormatTest { } impl FormatTest { + #[allow(clippy::new_without_default)] pub fn new(number: f64, byte: swagger::ByteArray, date: chrono::DateTime::<chrono::Utc>, password: String, ) -> FormatTest { FormatTest { integer: None, int32: None, int64: None, - number: number, + number, float: None, double: None, string: None, - byte: byte, + byte, binary: None, - date: date, + date, date_time: None, uuid: None, - password: password, + password, } } } @@ -2671,64 +2781,78 @@ impl FormatTest { /// Should be implemented in a serde serializer impl std::string::ToString for FormatTest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref integer) = self.integer { - params.push("integer".to_string()); - params.push(integer.to_string()); - } + self.integer.as_ref().map(|integer| { + vec![ + "integer".to_string(), + integer.to_string(), + ].join(",") + }), - if let Some(ref int32) = self.int32 { - params.push("int32".to_string()); - params.push(int32.to_string()); - } + self.int32.as_ref().map(|int32| { + vec![ + "int32".to_string(), + int32.to_string(), + ].join(",") + }), - if let Some(ref int64) = self.int64 { - params.push("int64".to_string()); - params.push(int64.to_string()); - } + self.int64.as_ref().map(|int64| { + vec![ + "int64".to_string(), + int64.to_string(), + ].join(",") + }), - params.push("number".to_string()); - params.push(self.number.to_string()); + Some("number".to_string()), + Some(self.number.to_string()), - if let Some(ref float) = self.float { - params.push("float".to_string()); - params.push(float.to_string()); - } + self.float.as_ref().map(|float| { + vec![ + "float".to_string(), + float.to_string(), + ].join(",") + }), - if let Some(ref double) = self.double { - params.push("double".to_string()); - params.push(double.to_string()); - } + self.double.as_ref().map(|double| { + vec![ + "double".to_string(), + double.to_string(), + ].join(",") + }), - if let Some(ref string) = self.string { - params.push("string".to_string()); - params.push(string.to_string()); - } + self.string.as_ref().map(|string| { + vec![ + "string".to_string(), + string.to_string(), + ].join(",") + }), - // Skipping byte in query parameter serialization - // Skipping byte in query parameter serialization + // Skipping byte in query parameter serialization + // Skipping byte in query parameter serialization - // Skipping binary in query parameter serialization - // Skipping binary in query parameter serialization + // Skipping binary in query parameter serialization + // Skipping binary in query parameter serialization - // Skipping date in query parameter serialization + // Skipping date in query parameter serialization - // Skipping dateTime in query parameter serialization + // Skipping dateTime in query parameter serialization - // Skipping uuid in query parameter serialization + // Skipping uuid in query parameter serialization - params.push("password".to_string()); - params.push(self.password.to_string()); + Some("password".to_string()), + Some(self.password.to_string()), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -2760,7 +2884,7 @@ impl std::str::FromStr for FormatTest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2771,19 +2895,19 @@ impl std::str::FromStr for FormatTest { if let Some(key) = key_result { match key { - "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "int32" => intermediate_rep.int32.push(<u32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "int64" => intermediate_rep.int64.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "number" => intermediate_rep.number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "float" => intermediate_rep.float.push(<f32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "double" => intermediate_rep.double.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "string" => intermediate_rep.string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val)?), + "int32" => intermediate_rep.int32.push(<u32 as std::str::FromStr>::from_str(val)?), + "int64" => intermediate_rep.int64.push(<i64 as std::str::FromStr>::from_str(val)?), + "number" => intermediate_rep.number.push(<f64 as std::str::FromStr>::from_str(val)?), + "float" => intermediate_rep.float.push(<f32 as std::str::FromStr>::from_str(val)?), + "double" => intermediate_rep.double.push(<f64 as std::str::FromStr>::from_str(val)?), + "string" => intermediate_rep.string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "byte" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), "binary" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), - "date" => intermediate_rep.date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "date" => intermediate_rep.date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing FormatTest".to_string()) } } @@ -2797,16 +2921,16 @@ impl std::str::FromStr for FormatTest { integer: intermediate_rep.integer.into_iter().next(), int32: intermediate_rep.int32.into_iter().next(), int64: intermediate_rep.int64.into_iter().next(), - number: intermediate_rep.number.into_iter().next().ok_or("number missing in FormatTest".to_string())?, + number: intermediate_rep.number.into_iter().next().ok_or_else(|| "number missing in FormatTest".to_string())?, float: intermediate_rep.float.into_iter().next(), double: intermediate_rep.double.into_iter().next(), string: intermediate_rep.string.into_iter().next(), - byte: intermediate_rep.byte.into_iter().next().ok_or("byte missing in FormatTest".to_string())?, + byte: intermediate_rep.byte.into_iter().next().ok_or_else(|| "byte missing in FormatTest".to_string())?, binary: intermediate_rep.binary.into_iter().next(), - date: intermediate_rep.date.into_iter().next().ok_or("date missing in FormatTest".to_string())?, + date: intermediate_rep.date.into_iter().next().ok_or_else(|| "date missing in FormatTest".to_string())?, date_time: intermediate_rep.date_time.into_iter().next(), uuid: intermediate_rep.uuid.into_iter().next(), - password: intermediate_rep.password.into_iter().next().ok_or("password missing in FormatTest".to_string())?, + password: intermediate_rep.password.into_iter().next().ok_or_else(|| "password missing in FormatTest".to_string())?, }) } } @@ -2859,7 +2983,7 @@ impl FormatTest { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct HasOnlyReadOnly { #[serde(rename = "bar")] @@ -2873,6 +2997,7 @@ pub struct HasOnlyReadOnly { } impl HasOnlyReadOnly { + #[allow(clippy::new_without_default)] pub fn new() -> HasOnlyReadOnly { HasOnlyReadOnly { bar: None, @@ -2886,20 +3011,26 @@ impl HasOnlyReadOnly { /// Should be implemented in a serde serializer impl std::string::ToString for HasOnlyReadOnly { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref bar) = self.bar { - params.push("bar".to_string()); - params.push(bar.to_string()); - } + self.bar.as_ref().map(|bar| { + vec![ + "bar".to_string(), + bar.to_string(), + ].join(",") + }), - if let Some(ref foo) = self.foo { - params.push("foo".to_string()); - params.push(foo.to_string()); - } + self.foo.as_ref().map(|foo| { + vec![ + "foo".to_string(), + foo.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -2920,7 +3051,7 @@ impl std::str::FromStr for HasOnlyReadOnly { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -2931,8 +3062,8 @@ impl std::str::FromStr for HasOnlyReadOnly { if let Some(key) = key_result { match key { - "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing HasOnlyReadOnly".to_string()) } } @@ -2997,7 +3128,7 @@ impl HasOnlyReadOnly { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct List { #[serde(rename = "123-list")] @@ -3007,6 +3138,7 @@ pub struct List { } impl List { + #[allow(clippy::new_without_default)] pub fn new() -> List { List { param_123_list: None, @@ -3019,14 +3151,18 @@ impl List { /// Should be implemented in a serde serializer impl std::string::ToString for List { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref param_123_list) = self.param_123_list { - params.push("123-list".to_string()); - params.push(param_123_list.to_string()); - } + self.param_123_list.as_ref().map(|param_123_list| { + vec![ + "123-list".to_string(), + param_123_list.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -3046,7 +3182,7 @@ impl std::str::FromStr for List { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3057,7 +3193,7 @@ impl std::str::FromStr for List { if let Some(key) = key_result { match key { - "123-list" => intermediate_rep.param_123_list.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "123-list" => intermediate_rep.param_123_list.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing List".to_string()) } } @@ -3121,7 +3257,7 @@ impl List { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MapTest { #[serde(rename = "map_map_of_string")] @@ -3141,6 +3277,7 @@ pub struct MapTest { } impl MapTest { + #[allow(clippy::new_without_default)] pub fn new() -> MapTest { MapTest { map_map_of_string: None, @@ -3155,16 +3292,18 @@ impl MapTest { /// Should be implemented in a serde serializer impl std::string::ToString for MapTest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping map_map_of_string in query parameter serialization - // Skipping map_map_of_string in query parameter serialization + let params: Vec<String> = vec![ + // Skipping map_map_of_string in query parameter serialization + // Skipping map_map_of_string in query parameter serialization + + // Skipping map_map_of_enum in query parameter serialization + // Skipping map_map_of_enum in query parameter serialization - // Skipping map_map_of_enum in query parameter serialization - // Skipping map_map_of_enum in query parameter serialization + // Skipping map_of_enum_string in query parameter serialization - // Skipping map_of_enum_string in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -3186,7 +3325,7 @@ impl std::str::FromStr for MapTest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3265,7 +3404,7 @@ impl MapTest { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MixedPropertiesAndAdditionalPropertiesClass { #[serde(rename = "uuid")] @@ -3283,6 +3422,7 @@ pub struct MixedPropertiesAndAdditionalPropertiesClass { } impl MixedPropertiesAndAdditionalPropertiesClass { + #[allow(clippy::new_without_default)] pub fn new() -> MixedPropertiesAndAdditionalPropertiesClass { MixedPropertiesAndAdditionalPropertiesClass { uuid: None, @@ -3297,15 +3437,17 @@ impl MixedPropertiesAndAdditionalPropertiesClass { /// Should be implemented in a serde serializer impl std::string::ToString for MixedPropertiesAndAdditionalPropertiesClass { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping uuid in query parameter serialization + let params: Vec<String> = vec![ + // Skipping uuid in query parameter serialization + + // Skipping dateTime in query parameter serialization - // Skipping dateTime in query parameter serialization + // Skipping map in query parameter serialization + // Skipping map in query parameter serialization - // Skipping map in query parameter serialization - // Skipping map in query parameter serialization + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -3327,7 +3469,7 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3338,8 +3480,8 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { if let Some(key) = key_result { match key { - "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), "map" => return std::result::Result::Err("Parsing a container in this style is not supported in MixedPropertiesAndAdditionalPropertiesClass".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MixedPropertiesAndAdditionalPropertiesClass".to_string()) } @@ -3407,7 +3549,7 @@ impl MixedPropertiesAndAdditionalPropertiesClass { } /// Model for testing model name starting with number -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Name")] pub struct Model200Response { @@ -3422,6 +3564,7 @@ pub struct Model200Response { } impl Model200Response { + #[allow(clippy::new_without_default)] pub fn new() -> Model200Response { Model200Response { name: None, @@ -3435,20 +3578,26 @@ impl Model200Response { /// Should be implemented in a serde serializer impl std::string::ToString for Model200Response { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref name) = self.name { - params.push("name".to_string()); - params.push(name.to_string()); - } + self.name.as_ref().map(|name| { + vec![ + "name".to_string(), + name.to_string(), + ].join(",") + }), - if let Some(ref class) = self.class { - params.push("class".to_string()); - params.push(class.to_string()); - } + self.class.as_ref().map(|class| { + vec![ + "class".to_string(), + class.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -3469,7 +3618,7 @@ impl std::str::FromStr for Model200Response { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3480,8 +3629,8 @@ impl std::str::FromStr for Model200Response { if let Some(key) = key_result { match key { - "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "class" => intermediate_rep.class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val)?), + "class" => intermediate_rep.class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Model200Response".to_string()) } } @@ -3547,7 +3696,7 @@ impl Model200Response { } /// Model for testing model name same as property name -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Name")] pub struct Name { @@ -3569,9 +3718,10 @@ pub struct Name { } impl Name { + #[allow(clippy::new_without_default)] pub fn new(name: i32, ) -> Name { Name { - name: name, + name, snake_case: None, property: None, param_123_number: None, @@ -3584,30 +3734,38 @@ impl Name { /// Should be implemented in a serde serializer impl std::string::ToString for Name { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("name".to_string()); - params.push(self.name.to_string()); + Some("name".to_string()), + Some(self.name.to_string()), - if let Some(ref snake_case) = self.snake_case { - params.push("snake_case".to_string()); - params.push(snake_case.to_string()); - } + self.snake_case.as_ref().map(|snake_case| { + vec![ + "snake_case".to_string(), + snake_case.to_string(), + ].join(",") + }), - if let Some(ref property) = self.property { - params.push("property".to_string()); - params.push(property.to_string()); - } + self.property.as_ref().map(|property| { + vec![ + "property".to_string(), + property.to_string(), + ].join(",") + }), - if let Some(ref param_123_number) = self.param_123_number { - params.push("123Number".to_string()); - params.push(param_123_number.to_string()); - } + self.param_123_number.as_ref().map(|param_123_number| { + vec![ + "123Number".to_string(), + param_123_number.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -3630,7 +3788,7 @@ impl std::str::FromStr for Name { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3641,10 +3799,10 @@ impl std::str::FromStr for Name { if let Some(key) = key_result { match key { - "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "snake_case" => intermediate_rep.snake_case.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "property" => intermediate_rep.property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "123Number" => intermediate_rep.param_123_number.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val)?), + "snake_case" => intermediate_rep.snake_case.push(<i32 as std::str::FromStr>::from_str(val)?), + "property" => intermediate_rep.property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "123Number" => intermediate_rep.param_123_number.push(<isize as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing Name".to_string()) } } @@ -3655,7 +3813,7 @@ impl std::str::FromStr for Name { // Use the intermediate representation to return the struct std::result::Result::Ok(Name { - name: intermediate_rep.name.into_iter().next().ok_or("name missing in Name".to_string())?, + name: intermediate_rep.name.into_iter().next().ok_or_else(|| "name missing in Name".to_string())?, snake_case: intermediate_rep.snake_case.into_iter().next(), property: intermediate_rep.property.into_iter().next(), param_123_number: intermediate_rep.param_123_number.into_iter().next(), @@ -3711,7 +3869,7 @@ impl Name { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NumberOnly { #[serde(rename = "JustNumber")] @@ -3721,6 +3879,7 @@ pub struct NumberOnly { } impl NumberOnly { + #[allow(clippy::new_without_default)] pub fn new() -> NumberOnly { NumberOnly { just_number: None, @@ -3733,14 +3892,18 @@ impl NumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for NumberOnly { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref just_number) = self.just_number { - params.push("JustNumber".to_string()); - params.push(just_number.to_string()); - } + self.just_number.as_ref().map(|just_number| { + vec![ + "JustNumber".to_string(), + just_number.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -3760,7 +3923,7 @@ impl std::str::FromStr for NumberOnly { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3771,7 +3934,7 @@ impl std::str::FromStr for NumberOnly { if let Some(key) = key_result { match key { - "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing NumberOnly".to_string()) } } @@ -3835,7 +3998,7 @@ impl NumberOnly { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectContainingObjectWithOnlyAdditionalProperties { #[serde(rename = "inner")] @@ -3845,6 +4008,7 @@ pub struct ObjectContainingObjectWithOnlyAdditionalProperties { } impl ObjectContainingObjectWithOnlyAdditionalProperties { + #[allow(clippy::new_without_default)] pub fn new() -> ObjectContainingObjectWithOnlyAdditionalProperties { ObjectContainingObjectWithOnlyAdditionalProperties { inner: None, @@ -3857,10 +4021,12 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectContainingObjectWithOnlyAdditionalProperties { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping inner in query parameter serialization + let params: Vec<String> = vec![ + // Skipping inner in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -3880,7 +4046,7 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -3891,7 +4057,7 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { if let Some(key) = key_result { match key { - "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectContainingObjectWithOnlyAdditionalProperties".to_string()) } } @@ -3955,7 +4121,7 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithOnlyAdditionalProperties(std::collections::HashMap<String, String>); @@ -4014,7 +4180,7 @@ impl ObjectWithOnlyAdditionalProperties { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Order")] pub struct Order { @@ -4047,6 +4213,7 @@ pub struct Order { } impl Order { + #[allow(clippy::new_without_default)] pub fn new() -> Order { Order { id: None, @@ -4064,40 +4231,52 @@ impl Order { /// Should be implemented in a serde serializer impl std::string::ToString for Order { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref id) = self.id { - params.push("id".to_string()); - params.push(id.to_string()); - } + self.id.as_ref().map(|id| { + vec![ + "id".to_string(), + id.to_string(), + ].join(",") + }), - if let Some(ref pet_id) = self.pet_id { - params.push("petId".to_string()); - params.push(pet_id.to_string()); - } + self.pet_id.as_ref().map(|pet_id| { + vec![ + "petId".to_string(), + pet_id.to_string(), + ].join(",") + }), - if let Some(ref quantity) = self.quantity { - params.push("quantity".to_string()); - params.push(quantity.to_string()); - } + self.quantity.as_ref().map(|quantity| { + vec![ + "quantity".to_string(), + quantity.to_string(), + ].join(",") + }), - // Skipping shipDate in query parameter serialization + // Skipping shipDate in query parameter serialization - if let Some(ref status) = self.status { - params.push("status".to_string()); - params.push(status.to_string()); - } + self.status.as_ref().map(|status| { + vec![ + "status".to_string(), + status.to_string(), + ].join(",") + }), - if let Some(ref complete) = self.complete { - params.push("complete".to_string()); - params.push(complete.to_string()); - } + self.complete.as_ref().map(|complete| { + vec![ + "complete".to_string(), + complete.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -4122,7 +4301,7 @@ impl std::str::FromStr for Order { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -4133,12 +4312,12 @@ impl std::str::FromStr for Order { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "petId" => intermediate_rep.pet_id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "quantity" => intermediate_rep.quantity.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "shipDate" => intermediate_rep.ship_date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "complete" => intermediate_rep.complete.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "petId" => intermediate_rep.pet_id.push(<i64 as std::str::FromStr>::from_str(val)?), + "quantity" => intermediate_rep.quantity.push(<i32 as std::str::FromStr>::from_str(val)?), + "shipDate" => intermediate_rep.ship_date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "complete" => intermediate_rep.complete.push(<bool as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) } } @@ -4207,7 +4386,7 @@ impl Order { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterBoolean(bool); @@ -4246,7 +4425,7 @@ impl OuterBoolean { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterComposite { #[serde(rename = "my_number")] @@ -4264,6 +4443,7 @@ pub struct OuterComposite { } impl OuterComposite { + #[allow(clippy::new_without_default)] pub fn new() -> OuterComposite { OuterComposite { my_number: None, @@ -4278,26 +4458,34 @@ impl OuterComposite { /// Should be implemented in a serde serializer impl std::string::ToString for OuterComposite { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref my_number) = self.my_number { - params.push("my_number".to_string()); - params.push(my_number.to_string()); - } + self.my_number.as_ref().map(|my_number| { + vec![ + "my_number".to_string(), + my_number.to_string(), + ].join(",") + }), - if let Some(ref my_string) = self.my_string { - params.push("my_string".to_string()); - params.push(my_string.to_string()); - } + self.my_string.as_ref().map(|my_string| { + vec![ + "my_string".to_string(), + my_string.to_string(), + ].join(",") + }), - if let Some(ref my_boolean) = self.my_boolean { - params.push("my_boolean".to_string()); - params.push(my_boolean.to_string()); - } + self.my_boolean.as_ref().map(|my_boolean| { + vec![ + "my_boolean".to_string(), + my_boolean.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -4319,7 +4507,7 @@ impl std::str::FromStr for OuterComposite { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -4330,9 +4518,9 @@ impl std::str::FromStr for OuterComposite { if let Some(key) = key_result { match key { - "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "my_string" => intermediate_rep.my_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "my_boolean" => intermediate_rep.my_boolean.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val)?), + "my_string" => intermediate_rep.my_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "my_boolean" => intermediate_rep.my_boolean.push(<bool as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing OuterComposite".to_string()) } } @@ -4417,9 +4605,9 @@ pub enum OuterEnum { impl std::fmt::Display for OuterEnum { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - OuterEnum::Placed => write!(f, "{}", "placed"), - OuterEnum::Approved => write!(f, "{}", "approved"), - OuterEnum::Delivered => write!(f, "{}", "delivered"), + OuterEnum::Placed => write!(f, "placed"), + OuterEnum::Approved => write!(f, "approved"), + OuterEnum::Delivered => write!(f, "delivered"), } } } @@ -4446,7 +4634,7 @@ impl OuterEnum { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterNumber(f64); @@ -4485,7 +4673,7 @@ impl OuterNumber { } } -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterString(String); @@ -4537,7 +4725,7 @@ impl OuterString { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Pet")] pub struct Pet { @@ -4568,12 +4756,13 @@ pub struct Pet { } impl Pet { + #[allow(clippy::new_without_default)] pub fn new(name: String, photo_urls: Vec<String>, ) -> Pet { Pet { id: None, category: None, - name: name, - photo_urls: photo_urls, + name, + photo_urls, tags: None, status: None, } @@ -4585,32 +4774,38 @@ impl Pet { /// Should be implemented in a serde serializer impl std::string::ToString for Pet { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref id) = self.id { - params.push("id".to_string()); - params.push(id.to_string()); - } + self.id.as_ref().map(|id| { + vec![ + "id".to_string(), + id.to_string(), + ].join(",") + }), - // Skipping category in query parameter serialization + // Skipping category in query parameter serialization - params.push("name".to_string()); - params.push(self.name.to_string()); + Some("name".to_string()), + Some(self.name.to_string()), - params.push("photoUrls".to_string()); - params.push(self.photo_urls.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()); + Some("photoUrls".to_string()), + Some(self.photo_urls.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")), - // Skipping tags in query parameter serialization + // Skipping tags in query parameter serialization - if let Some(ref status) = self.status { - params.push("status".to_string()); - params.push(status.to_string()); - } + self.status.as_ref().map(|status| { + vec![ + "status".to_string(), + status.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -4635,7 +4830,7 @@ impl std::str::FromStr for Pet { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -4646,12 +4841,12 @@ impl std::str::FromStr for Pet { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "category" => intermediate_rep.category.push(<models::Category as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "category" => intermediate_rep.category.push(<models::Category as std::str::FromStr>::from_str(val)?), + "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "photoUrls" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), "tags" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), - "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Pet".to_string()) } } @@ -4664,8 +4859,8 @@ impl std::str::FromStr for Pet { std::result::Result::Ok(Pet { id: intermediate_rep.id.into_iter().next(), category: intermediate_rep.category.into_iter().next(), - name: intermediate_rep.name.into_iter().next().ok_or("name missing in Pet".to_string())?, - photo_urls: intermediate_rep.photo_urls.into_iter().next().ok_or("photoUrls missing in Pet".to_string())?, + name: intermediate_rep.name.into_iter().next().ok_or_else(|| "name missing in Pet".to_string())?, + photo_urls: intermediate_rep.photo_urls.into_iter().next().ok_or_else(|| "photoUrls missing in Pet".to_string())?, tags: intermediate_rep.tags.into_iter().next(), status: intermediate_rep.status.into_iter().next(), }) @@ -4720,7 +4915,7 @@ impl Pet { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ReadOnlyFirst { #[serde(rename = "bar")] @@ -4734,6 +4929,7 @@ pub struct ReadOnlyFirst { } impl ReadOnlyFirst { + #[allow(clippy::new_without_default)] pub fn new() -> ReadOnlyFirst { ReadOnlyFirst { bar: None, @@ -4747,20 +4943,26 @@ impl ReadOnlyFirst { /// Should be implemented in a serde serializer impl std::string::ToString for ReadOnlyFirst { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref bar) = self.bar { - params.push("bar".to_string()); - params.push(bar.to_string()); - } + self.bar.as_ref().map(|bar| { + vec![ + "bar".to_string(), + bar.to_string(), + ].join(",") + }), - if let Some(ref baz) = self.baz { - params.push("baz".to_string()); - params.push(baz.to_string()); - } + self.baz.as_ref().map(|baz| { + vec![ + "baz".to_string(), + baz.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -4781,7 +4983,7 @@ impl std::str::FromStr for ReadOnlyFirst { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -4792,8 +4994,8 @@ impl std::str::FromStr for ReadOnlyFirst { if let Some(key) = key_result { match key { - "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "baz" => intermediate_rep.baz.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "baz" => intermediate_rep.baz.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ReadOnlyFirst".to_string()) } } @@ -4859,7 +5061,7 @@ impl ReadOnlyFirst { } /// Model for testing reserved words -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Return")] pub struct Return { @@ -4870,6 +5072,7 @@ pub struct Return { } impl Return { + #[allow(clippy::new_without_default)] pub fn new() -> Return { Return { r#return: None, @@ -4882,14 +5085,18 @@ impl Return { /// Should be implemented in a serde serializer impl std::string::ToString for Return { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref r#return) = self.r#return { - params.push("return".to_string()); - params.push(r#return.to_string()); - } + self.r#return.as_ref().map(|r#return| { + vec![ + "return".to_string(), + r#return.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -4909,7 +5116,7 @@ impl std::str::FromStr for Return { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -4920,7 +5127,7 @@ impl std::str::FromStr for Return { if let Some(key) = key_result { match key { - "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing Return".to_string()) } } @@ -4984,7 +5191,7 @@ impl Return { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Tag")] pub struct Tag { @@ -4999,6 +5206,7 @@ pub struct Tag { } impl Tag { + #[allow(clippy::new_without_default)] pub fn new() -> Tag { Tag { id: None, @@ -5012,20 +5220,26 @@ impl Tag { /// Should be implemented in a serde serializer impl std::string::ToString for Tag { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref id) = self.id { - params.push("id".to_string()); - params.push(id.to_string()); - } + self.id.as_ref().map(|id| { + vec![ + "id".to_string(), + id.to_string(), + ].join(",") + }), - if let Some(ref name) = self.name { - params.push("name".to_string()); - params.push(name.to_string()); - } + self.name.as_ref().map(|name| { + vec![ + "name".to_string(), + name.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -5046,7 +5260,7 @@ impl std::str::FromStr for Tag { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -5057,8 +5271,8 @@ impl std::str::FromStr for Tag { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Tag".to_string()) } } @@ -5123,7 +5337,7 @@ impl Tag { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "User")] pub struct User { @@ -5163,6 +5377,7 @@ pub struct User { } impl User { + #[allow(clippy::new_without_default)] pub fn new() -> User { User { id: None, @@ -5182,56 +5397,74 @@ impl User { /// Should be implemented in a serde serializer impl std::string::ToString for User { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref id) = self.id { - params.push("id".to_string()); - params.push(id.to_string()); - } + self.id.as_ref().map(|id| { + vec![ + "id".to_string(), + id.to_string(), + ].join(",") + }), - if let Some(ref username) = self.username { - params.push("username".to_string()); - params.push(username.to_string()); - } + self.username.as_ref().map(|username| { + vec![ + "username".to_string(), + username.to_string(), + ].join(",") + }), - if let Some(ref first_name) = self.first_name { - params.push("firstName".to_string()); - params.push(first_name.to_string()); - } + self.first_name.as_ref().map(|first_name| { + vec![ + "firstName".to_string(), + first_name.to_string(), + ].join(",") + }), - if let Some(ref last_name) = self.last_name { - params.push("lastName".to_string()); - params.push(last_name.to_string()); - } + self.last_name.as_ref().map(|last_name| { + vec![ + "lastName".to_string(), + last_name.to_string(), + ].join(",") + }), - if let Some(ref email) = self.email { - params.push("email".to_string()); - params.push(email.to_string()); - } + self.email.as_ref().map(|email| { + vec![ + "email".to_string(), + email.to_string(), + ].join(",") + }), - if let Some(ref password) = self.password { - params.push("password".to_string()); - params.push(password.to_string()); - } + self.password.as_ref().map(|password| { + vec![ + "password".to_string(), + password.to_string(), + ].join(",") + }), - if let Some(ref phone) = self.phone { - params.push("phone".to_string()); - params.push(phone.to_string()); - } + self.phone.as_ref().map(|phone| { + vec![ + "phone".to_string(), + phone.to_string(), + ].join(",") + }), - if let Some(ref user_status) = self.user_status { - params.push("userStatus".to_string()); - params.push(user_status.to_string()); - } + self.user_status.as_ref().map(|user_status| { + vec![ + "userStatus".to_string(), + user_status.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -5258,7 +5491,7 @@ impl std::str::FromStr for User { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -5269,14 +5502,14 @@ impl std::str::FromStr for User { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "username" => intermediate_rep.username.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "firstName" => intermediate_rep.first_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "lastName" => intermediate_rep.last_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "email" => intermediate_rep.email.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "phone" => intermediate_rep.phone.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "userStatus" => intermediate_rep.user_status.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "username" => intermediate_rep.username.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "firstName" => intermediate_rep.first_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "lastName" => intermediate_rep.last_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "email" => intermediate_rep.email.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "phone" => intermediate_rep.phone.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "userStatus" => intermediate_rep.user_status.push(<i32 as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing User".to_string()) } } diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 20736c12402..104af6e332c 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -211,7 +211,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -224,7 +224,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -291,7 +291,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -340,7 +340,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -390,7 +390,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -460,7 +460,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -530,7 +530,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -600,7 +600,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -649,7 +649,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -702,7 +702,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -790,7 +790,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -863,7 +863,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -952,7 +952,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1095,7 +1095,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1159,7 +1159,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1207,7 +1207,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1277,7 +1277,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1387,7 +1387,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1504,7 +1504,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1570,7 +1570,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1647,7 +1647,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1721,7 +1721,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -1826,7 +1826,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -1936,7 +1936,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2097,7 +2097,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2163,7 +2163,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2206,7 +2206,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2266,7 +2266,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2341,7 +2341,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -2425,7 +2425,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -2498,7 +2498,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -2571,7 +2571,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -2637,7 +2637,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2694,7 +2694,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2791,7 +2791,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2867,7 +2867,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -2951,7 +2951,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs index 4c5d7e2de9d..553cc3be995 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs @@ -13,7 +13,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum PingGetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs index c62110ced8f..6a19617d356 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs @@ -98,7 +98,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -111,7 +111,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -157,7 +157,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs index eb37814cb8f..a2951a5a6ca 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs @@ -13,60 +13,60 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "2.3.4"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum AllOfGetResponse { /// OK OK (models::AllOfObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum DummyGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum DummyPutResponse { /// Success Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum FileResponseGetResponse { /// Success Success (swagger::ByteArray) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum GetStructuredYamlResponse { /// OK OK (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum HtmlPostResponse { /// Success Success (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum PostYamlResponse { /// OK OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum RawJsonGetResponse { /// Success Success (serde_json::Value) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum SoloObjectPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs index 381b7632a6a..ebea234c19d 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ANullableContainer { #[serde(rename = "NullableThing")] @@ -19,10 +19,11 @@ pub struct ANullableContainer { } impl ANullableContainer { + #[allow(clippy::new_without_default)] pub fn new(required_nullable_thing: swagger::Nullable<String>, ) -> ANullableContainer { ANullableContainer { nullable_thing: None, - required_nullable_thing: required_nullable_thing, + required_nullable_thing, } } } @@ -32,18 +33,22 @@ impl ANullableContainer { /// Should be implemented in a serde serializer impl std::string::ToString for ANullableContainer { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ + + self.nullable_thing.as_ref().map(|nullable_thing| { + vec![ + "NullableThing".to_string(), + nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), - if let Some(ref nullable_thing) = self.nullable_thing { - params.push("NullableThing".to_string()); - params.push(nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())); - } + Some("RequiredNullableThing".to_string()), + Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())), - params.push("RequiredNullableThing".to_string()); - params.push(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())); + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -64,7 +69,7 @@ impl std::str::FromStr for ANullableContainer { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -133,7 +138,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// An additionalPropertiesObject -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesObject(std::collections::HashMap<String, String>); @@ -183,7 +188,7 @@ impl ::std::str::FromStr for AdditionalPropertiesObject { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AllOfObject { #[serde(rename = "sampleProperty")] @@ -197,6 +202,7 @@ pub struct AllOfObject { } impl AllOfObject { + #[allow(clippy::new_without_default)] pub fn new() -> AllOfObject { AllOfObject { sample_property: None, @@ -210,20 +216,26 @@ impl AllOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for AllOfObject { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref sample_property) = self.sample_property { - params.push("sampleProperty".to_string()); - params.push(sample_property.to_string()); - } + self.sample_property.as_ref().map(|sample_property| { + vec![ + "sampleProperty".to_string(), + sample_property.to_string(), + ].join(",") + }), - if let Some(ref sample_base_propery) = self.sample_base_propery { - params.push("sampleBasePropery".to_string()); - params.push(sample_base_propery.to_string()); - } + self.sample_base_propery.as_ref().map(|sample_base_propery| { + vec![ + "sampleBasePropery".to_string(), + sample_base_propery.to_string(), + ].join(",") + }), - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -244,7 +256,7 @@ impl std::str::FromStr for AllOfObject { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -255,8 +267,8 @@ impl std::str::FromStr for AllOfObject { if let Some(key) = key_result { match key { - "sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string()) } } @@ -312,7 +324,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct BaseAllOf { #[serde(rename = "sampleBasePropery")] @@ -322,6 +334,7 @@ pub struct BaseAllOf { } impl BaseAllOf { + #[allow(clippy::new_without_default)] pub fn new() -> BaseAllOf { BaseAllOf { sample_base_propery: None, @@ -334,14 +347,18 @@ impl BaseAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for BaseAllOf { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref sample_base_propery) = self.sample_base_propery { - params.push("sampleBasePropery".to_string()); - params.push(sample_base_propery.to_string()); - } + self.sample_base_propery.as_ref().map(|sample_base_propery| { + vec![ + "sampleBasePropery".to_string(), + sample_base_propery.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -361,7 +378,7 @@ impl std::str::FromStr for BaseAllOf { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -372,7 +389,7 @@ impl std::str::FromStr for BaseAllOf { if let Some(key) = key_result { match key { - "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string()) } } @@ -427,7 +444,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DummyPutRequest { #[serde(rename = "id")] @@ -440,9 +457,10 @@ pub struct DummyPutRequest { } impl DummyPutRequest { + #[allow(clippy::new_without_default)] pub fn new(id: String, ) -> DummyPutRequest { DummyPutRequest { - id: id, + id, password: None, } } @@ -453,18 +471,22 @@ impl DummyPutRequest { /// Should be implemented in a serde serializer impl std::string::ToString for DummyPutRequest { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("id".to_string()); - params.push(self.id.to_string()); + Some("id".to_string()), + Some(self.id.to_string()), - if let Some(ref password) = self.password { - params.push("password".to_string()); - params.push(password.to_string()); - } + self.password.as_ref().map(|password| { + vec![ + "password".to_string(), + password.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -485,7 +507,7 @@ impl std::str::FromStr for DummyPutRequest { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -496,8 +518,8 @@ impl std::str::FromStr for DummyPutRequest { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string()) } } @@ -508,7 +530,7 @@ impl std::str::FromStr for DummyPutRequest { // Use the intermediate representation to return the struct std::result::Result::Ok(DummyPutRequest { - id: intermediate_rep.id.into_iter().next().ok_or("id missing in DummyPutRequest".to_string())?, + id: intermediate_rep.id.into_iter().next().ok_or_else(|| "id missing in DummyPutRequest".to_string())?, password: intermediate_rep.password.into_iter().next(), }) } @@ -554,7 +576,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// structured response -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct GetYamlResponse { /// Inner string @@ -565,6 +587,7 @@ pub struct GetYamlResponse { } impl GetYamlResponse { + #[allow(clippy::new_without_default)] pub fn new() -> GetYamlResponse { GetYamlResponse { value: None, @@ -577,14 +600,18 @@ impl GetYamlResponse { /// Should be implemented in a serde serializer impl std::string::ToString for GetYamlResponse { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - if let Some(ref value) = self.value { - params.push("value".to_string()); - params.push(value.to_string()); - } + self.value.as_ref().map(|value| { + vec![ + "value".to_string(), + value.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -604,7 +631,7 @@ impl std::str::FromStr for GetYamlResponse { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -615,7 +642,7 @@ impl std::str::FromStr for GetYamlResponse { if let Some(key) = key_result { match key { - "value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string()) } } @@ -671,7 +698,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// An object of objects -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjects { #[serde(rename = "inner")] @@ -681,6 +708,7 @@ pub struct ObjectOfObjects { } impl ObjectOfObjects { + #[allow(clippy::new_without_default)] pub fn new() -> ObjectOfObjects { ObjectOfObjects { inner: None, @@ -693,10 +721,12 @@ impl ObjectOfObjects { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectOfObjects { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; - // Skipping inner in query parameter serialization + let params: Vec<String> = vec![ + // Skipping inner in query parameter serialization - params.join(",").to_string() + ].into_iter().flatten().collect(); + + params.join(",") } } @@ -716,7 +746,7 @@ impl std::str::FromStr for ObjectOfObjects { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -727,7 +757,7 @@ impl std::str::FromStr for ObjectOfObjects { if let Some(key) = key_result { match key { - "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string()) } } @@ -782,7 +812,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjectsInner { #[serde(rename = "required_thing")] @@ -795,9 +825,10 @@ pub struct ObjectOfObjectsInner { } impl ObjectOfObjectsInner { + #[allow(clippy::new_without_default)] pub fn new(required_thing: String, ) -> ObjectOfObjectsInner { ObjectOfObjectsInner { - required_thing: required_thing, + required_thing, optional_thing: None, } } @@ -808,18 +839,22 @@ impl ObjectOfObjectsInner { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectOfObjectsInner { fn to_string(&self) -> String { - let mut params: Vec<String> = vec![]; + let params: Vec<String> = vec![ - params.push("required_thing".to_string()); - params.push(self.required_thing.to_string()); + Some("required_thing".to_string()), + Some(self.required_thing.to_string()), - if let Some(ref optional_thing) = self.optional_thing { - params.push("optional_thing".to_string()); - params.push(optional_thing.to_string()); - } + self.optional_thing.as_ref().map(|optional_thing| { + vec![ + "optional_thing".to_string(), + optional_thing.to_string(), + ].join(",") + }), + + ].into_iter().flatten().collect(); - params.join(",").to_string() + params.join(",") } } @@ -840,7 +875,7 @@ impl std::str::FromStr for ObjectOfObjectsInner { let mut intermediate_rep = IntermediateRep::default(); // Parse into intermediate representation - let mut string_iter = s.split(',').into_iter(); + let mut string_iter = s.split(','); let mut key_result = string_iter.next(); while key_result.is_some() { @@ -851,8 +886,8 @@ impl std::str::FromStr for ObjectOfObjectsInner { if let Some(key) = key_result { match key { - "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), - "optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?), + "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val)?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string()) } } @@ -863,7 +898,7 @@ impl std::str::FromStr for ObjectOfObjectsInner { // Use the intermediate representation to return the struct std::result::Result::Ok(ObjectOfObjectsInner { - required_thing: intermediate_rep.required_thing.into_iter().next().ok_or("required_thing missing in ObjectOfObjectsInner".to_string())?, + required_thing: intermediate_rep.required_thing.into_iter().next().ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?, optional_thing: intermediate_rep.optional_thing.into_iter().next(), }) } diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index 2b63c4e1d2c..dacae95911e 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -120,7 +120,7 @@ impl<T, C> Service<T, C> where { pub fn new(api_impl: T) -> Self { Service { - api_impl: api_impl, + api_impl, marker: PhantomData } } @@ -133,7 +133,7 @@ impl<T, C> Clone for Service<T, C> where fn clone(&self) -> Self { Service { api_impl: self.api_impl.clone(), - marker: self.marker.clone(), + marker: self.marker, } } } @@ -169,7 +169,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -205,7 +205,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -265,7 +265,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { @@ -307,7 +307,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -343,7 +343,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -405,7 +405,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -473,7 +473,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -508,7 +508,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); match result { @@ -575,7 +575,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let mut response = Response::new(Body::empty()); response.headers_mut().insert( HeaderName::from_static("x-span-id"), - HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str()) + HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().as_str()) .expect("Unable to create X-Span-ID header value")); if !unused_elements.is_empty() { -- GitLab From e279d40d6459cdf162bb60ee9e0bd11a1744a226 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 13:10:34 +0900 Subject: [PATCH 12/18] fix(rust-server): Allow clippy::derive_partial_eq_without_eq to avoid float types try to derive Eq --- .../src/main/resources/rust-server/lib.mustache | 1 + .../src/main/resources/rust-server/models.mustache | 8 ++++---- .../src/main/resources/rust-server/response.mustache | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache index 7603c82c6cc..586210bf0e0 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 1ade263b22b..0daad25bce6 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -58,10 +58,10 @@ impl std::str::FromStr for {{{classname}}} { {{^isEnum}} {{#dataType}} {{#isMap}} -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] {{/isMap}} {{^isMap}} -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] {{/isMap}} #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] {{#xmlName}} @@ -146,7 +146,7 @@ where {{/x-item-xml-name}} {{/vendorExtensions}} {{! vec}} -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct {{{classname}}}( {{#vendorExtensions}} @@ -243,7 +243,7 @@ impl std::str::FromStr for {{{classname}}} { {{/arrayModelType}} {{^arrayModelType}} {{! general struct}} -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] {{#xmlName}} #[serde(rename = "{{{.}}}")] diff --git a/modules/openapi-generator/src/main/resources/rust-server/response.mustache b/modules/openapi-generator/src/main/resources/rust-server/response.mustache index ac861c89b40..ac74c0b4e2a 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/response.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/response.mustache @@ -1,4 +1,4 @@ -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] {{#vendorExtensions.x-must-use-response}} #[must_use] {{/vendorExtensions.x-must-use-response}} -- GitLab From 58e7a7c9284e95c29dfb78675ed5b952d7f71d17 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 13:20:56 +0900 Subject: [PATCH 13/18] fix(rust-server): Fix parts to compile samples successfully --- .../resources/rust-server/models.mustache | 8 +- .../output/multipart-v3/src/lib.rs | 7 +- .../output/multipart-v3/src/models.rs | 24 +- .../output/no-example-v3/src/lib.rs | 3 +- .../output/no-example-v3/src/models.rs | 8 +- .../rust-server/output/openapi-v3/src/lib.rs | 57 +-- .../output/openapi-v3/src/models.rs | 160 ++++---- .../rust-server/output/ops-v3/src/lib.rs | 75 ++-- .../src/lib.rs | 71 ++-- .../src/models.rs | 344 +++++++++--------- .../output/ping-bearer-auth/src/lib.rs | 3 +- .../output/rust-server-test/src/lib.rs | 19 +- .../output/rust-server-test/src/models.rs | 60 +-- 13 files changed, 423 insertions(+), 416 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 0daad25bce6..5a25de0d286 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -288,7 +288,7 @@ impl {{{classname}}} { /// Should be implemented in a serde serializer impl std::string::ToString for {{{classname}}} { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ {{#vars}} {{#isByteArray}} // Skipping {{baseName}} in query parameter serialization @@ -347,9 +347,9 @@ impl std::string::ToString for {{{classname}}} { {{/required}} {{/isPrimitiveType}}{{/isMap}}{{/isBinary}}{{/isByteArray}} {{/vars}} - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -399,7 +399,7 @@ impl std::str::FromStr for {{{classname}}} { "{{{baseName}}}" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in {{{classname}}}".to_string()), {{/isNullable}} {{^isNullable}} - "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val){{#isString}}.map_err(|x| x.to_string()){{/isString}}?), + "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val){{^isModel}}.map_err(|x| x.to_string()){{/isModel}}?), {{/isNullable}} {{/isContainer}} {{/isByteArray}} diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs index 32c0a66bd7c..3bf0b01757b 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,19 +14,19 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MultipartRelatedRequestPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MultipartRequestPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MultipleIdenticalMimeTypesPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs index 5c40d9710ea..e0c8cbea9d7 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRelatedRequest { #[serde(rename = "object_field")] @@ -36,7 +36,7 @@ impl MultipartRelatedRequest { /// Should be implemented in a serde serializer impl std::string::ToString for MultipartRelatedRequest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping object_field in query parameter serialization // Skipping optional_binary_field in query parameter serialization @@ -45,9 +45,9 @@ impl std::string::ToString for MultipartRelatedRequest { // Skipping required_binary_field in query parameter serialization // Skipping required_binary_field in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -139,7 +139,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRequestObjectField { #[serde(rename = "field_a")] @@ -166,7 +166,7 @@ impl MultipartRequestObjectField { /// Should be implemented in a serde serializer impl std::string::ToString for MultipartRequestObjectField { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("field_a".to_string()), Some(self.field_a.to_string()), @@ -179,9 +179,9 @@ impl std::string::ToString for MultipartRequestObjectField { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -270,7 +270,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipleIdenticalMimeTypesPostRequest { #[serde(rename = "binary1")] @@ -298,16 +298,16 @@ impl MultipleIdenticalMimeTypesPostRequest { /// Should be implemented in a serde serializer impl std::string::ToString for MultipleIdenticalMimeTypesPostRequest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping binary1 in query parameter serialization // Skipping binary1 in query parameter serialization // Skipping binary2 in query parameter serialization // Skipping binary2 in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs index 984b71ecaf3..1f85575086f 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,7 +14,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "0.0.1"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum OpGetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs index 7db39e0182f..a74bfb18249 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OpGetRequest { #[serde(rename = "propery")] @@ -27,7 +27,7 @@ impl OpGetRequest { /// Should be implemented in a serde serializer impl std::string::ToString for OpGetRequest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.propery.as_ref().map(|propery| { vec![ @@ -36,9 +36,9 @@ impl std::string::ToString for OpGetRequest { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 09fd361799e..86abc5eb0ab 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,7 +14,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum AnyOfGetResponse { /// Success @@ -29,44 +30,44 @@ pub enum AnyOfGetResponse { (models::AnyOfGet202Response) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CallbackWithHeaderPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum ComplexQueryParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum EnumInPathPathParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum JsonComplexQueryParamGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MandatoryRequestHeaderGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MergePatchJsonGetResponse { /// merge-patch+json-encoded response Merge (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum MultigetGetResponse { /// JSON rsp @@ -98,51 +99,51 @@ pub enum MultigetGetResponse { (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum MultipleAuthSchemeGetResponse { /// Check that limiting to multiple required auth schemes works CheckThatLimitingToMultipleRequiredAuthSchemesWorks } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum OneOfGetResponse { /// Success Success (models::OneOfGet200Response) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum OverrideServerGetResponse { /// Success. Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum ParamgetGetResponse { /// JSON rsp JSONRsp (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum ReadonlyAuthSchemeGetResponse { /// Check that limiting to a single required auth scheme works CheckThatLimitingToASingleRequiredAuthSchemeWorks } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum RegisterCallbackPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum RequiredOctetStreamPutResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum ResponsesWithHeadersGetResponse { /// Success @@ -178,7 +179,7 @@ pub enum ResponsesWithHeadersGetResponse { } } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum Rfc7807GetResponse { /// OK @@ -194,20 +195,20 @@ pub enum Rfc7807GetResponse { (models::ObjectWithArrayOfObjects) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum UntypedPropertyGetResponse { /// Check that untyped properties works CheckThatUntypedPropertiesWorks } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum UuidGetResponse { /// Duplicate Response long text. One. DuplicateResponseLongText (uuid::Uuid) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum XmlExtraPostResponse { /// OK @@ -217,7 +218,7 @@ pub enum XmlExtraPostResponse { BadRequest } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum XmlOtherPostResponse { /// OK @@ -228,7 +229,7 @@ pub enum XmlOtherPostResponse { BadRequest } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum XmlOtherPutResponse { /// OK @@ -238,7 +239,7 @@ pub enum XmlOtherPutResponse { BadRequest } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum XmlPostResponse { /// OK @@ -248,7 +249,7 @@ pub enum XmlPostResponse { BadRequest } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum XmlPutResponse { /// OK @@ -258,13 +259,13 @@ pub enum XmlPutResponse { BadRequest } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateRepoResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum GetRepoInfoResponse { /// OK OK @@ -798,13 +799,13 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CallbackCallbackWithHeaderPostResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CallbackCallbackPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs index 1ce0ffd70be..63fe98547a5 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesWithList(std::collections::HashMap<String, Vec<String>>); @@ -72,7 +72,7 @@ where serde_xml_rs::wrap_primitives(item, serializer, "snake_another_xml_inner") } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnotherXmlArray( #[serde(serialize_with = "wrap_in_snake_another_xml_inner")] @@ -211,7 +211,7 @@ impl AnotherXmlArray { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "snake_another_xml_inner")] pub struct AnotherXmlInner(String); @@ -265,7 +265,7 @@ impl AnotherXmlInner { } /// An XML object -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "snake_another_xml_object")] pub struct AnotherXmlObject { @@ -289,7 +289,7 @@ impl AnotherXmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for AnotherXmlObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.inner_string.as_ref().map(|inner_string| { vec![ @@ -298,9 +298,9 @@ impl std::string::ToString for AnotherXmlObject { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -404,7 +404,7 @@ impl AnotherXmlObject { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfGet202Response { } @@ -422,10 +422,10 @@ impl AnyOfGet202Response { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfGet202Response { fn to_string(&self) -> String { - let params: Vec<String> = vec![ - ].into_iter().flatten().collect(); + let params: Vec<Option<String>> = vec![ + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -518,7 +518,7 @@ impl AnyOfGet202Response { } /// Test a model containing an anyOf -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfObject { } @@ -536,10 +536,10 @@ impl AnyOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ - ].into_iter().flatten().collect(); + let params: Vec<Option<String>> = vec![ + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -676,7 +676,7 @@ impl AnyOfObjectAnyOf { } /// Test containing an anyOf object -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfProperty { #[serde(rename = "requiredAnyOf")] @@ -703,14 +703,14 @@ impl AnyOfProperty { /// Should be implemented in a serde serializer impl std::string::ToString for AnyOfProperty { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping requiredAnyOf in query parameter serialization // Skipping optionalAnyOf in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -809,7 +809,7 @@ impl AnyOfProperty { } /// An XML object -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelDuplicateXmlObject")] pub struct DuplicateXmlObject { @@ -838,7 +838,7 @@ impl DuplicateXmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for DuplicateXmlObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.inner_string.as_ref().map(|inner_string| { vec![ @@ -849,9 +849,9 @@ impl std::string::ToString for DuplicateXmlObject { // Skipping inner_array in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -884,7 +884,7 @@ impl std::str::FromStr for DuplicateXmlObject { if let Some(key) = key_result { match key { "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "inner_array" => intermediate_rep.inner_array.push(<models::XmlArray as std::str::FromStr>::from_str(val)?), + "inner_array" => intermediate_rep.inner_array.push(<models::XmlArray as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DuplicateXmlObject".to_string()) } } @@ -1007,7 +1007,7 @@ impl EnumWithStarObject { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Err(String); @@ -1059,7 +1059,7 @@ impl Err { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Error(String); @@ -1112,7 +1112,7 @@ impl Error { } /// Test a model containing an anyOf that starts with a number -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Model12345AnyOfObject { } @@ -1130,10 +1130,10 @@ impl Model12345AnyOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for Model12345AnyOfObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ - ].into_iter().flatten().collect(); + let params: Vec<Option<String>> = vec![ + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1273,7 +1273,7 @@ impl Model12345AnyOfObjectAnyOf { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultigetGet201Response { #[serde(rename = "foo")] @@ -1296,7 +1296,7 @@ impl MultigetGet201Response { /// Should be implemented in a serde serializer impl std::string::ToString for MultigetGet201Response { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.foo.as_ref().map(|foo| { vec![ @@ -1305,9 +1305,9 @@ impl std::string::ToString for MultigetGet201Response { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1402,7 +1402,7 @@ impl MultigetGet201Response { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyId(i32); @@ -1441,7 +1441,7 @@ impl MyId { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyIdList( Vec<i32> @@ -1579,7 +1579,7 @@ impl MyIdList { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NullableTest { #[serde(rename = "nullable")] @@ -1629,7 +1629,7 @@ impl NullableTest { /// Should be implemented in a serde serializer impl std::string::ToString for NullableTest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("nullable".to_string()), Some(self.nullable.as_ref().map_or("null".to_string(), |x| x.to_string())), @@ -1666,9 +1666,9 @@ impl std::string::ToString for NullableTest { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1775,7 +1775,7 @@ impl NullableTest { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectHeader { #[serde(rename = "requiredObjectHeader")] @@ -1802,7 +1802,7 @@ impl ObjectHeader { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectHeader { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("requiredObjectHeader".to_string()), Some(self.required_object_header.to_string()), @@ -1815,9 +1815,9 @@ impl std::string::ToString for ObjectHeader { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1849,8 +1849,8 @@ impl std::str::FromStr for ObjectHeader { if let Some(key) = key_result { match key { - "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val)?), - "optionalObjectHeader" => intermediate_rep.optional_object_header.push(<isize as std::str::FromStr>::from_str(val)?), + "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "optionalObjectHeader" => intermediate_rep.optional_object_header.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectHeader".to_string()) } } @@ -1915,7 +1915,7 @@ impl ObjectHeader { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectParam { #[serde(rename = "requiredParam")] @@ -1942,7 +1942,7 @@ impl ObjectParam { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectParam { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("requiredParam".to_string()), Some(self.required_param.to_string()), @@ -1955,9 +1955,9 @@ impl std::string::ToString for ObjectParam { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1989,8 +1989,8 @@ impl std::str::FromStr for ObjectParam { if let Some(key) = key_result { match key { - "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val)?), - "optionalParam" => intermediate_rep.optional_param.push(<isize as std::str::FromStr>::from_str(val)?), + "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "optionalParam" => intermediate_rep.optional_param.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectParam".to_string()) } } @@ -2055,7 +2055,7 @@ impl ObjectParam { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectUntypedProps { #[serde(rename = "required_untyped")] @@ -2091,7 +2091,7 @@ impl ObjectUntypedProps { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectUntypedProps { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping required_untyped in query parameter serialization // Skipping required_untyped_nullable in query parameter serialization @@ -2100,9 +2100,9 @@ impl std::string::ToString for ObjectUntypedProps { // Skipping not_required_untyped_nullable in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2136,10 +2136,10 @@ impl std::str::FromStr for ObjectUntypedProps { if let Some(key) = key_result { match key { - "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), + "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "required_untyped_nullable" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ObjectUntypedProps".to_string()), - "not_required_untyped" => intermediate_rep.not_required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), - "not_required_untyped_nullable" => intermediate_rep.not_required_untyped_nullable.push(<serde_json::Value as std::str::FromStr>::from_str(val)?), + "not_required_untyped" => intermediate_rep.not_required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "not_required_untyped_nullable" => intermediate_rep.not_required_untyped_nullable.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectUntypedProps".to_string()) } } @@ -2206,7 +2206,7 @@ impl ObjectUntypedProps { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithArrayOfObjects { #[serde(rename = "objectArray")] @@ -2229,7 +2229,7 @@ impl ObjectWithArrayOfObjects { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectWithArrayOfObjects { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.object_array.as_ref().map(|object_array| { vec![ @@ -2238,9 +2238,9 @@ impl std::string::ToString for ObjectWithArrayOfObjects { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2335,7 +2335,7 @@ impl ObjectWithArrayOfObjects { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Ok(String); @@ -2387,7 +2387,7 @@ impl Ok { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OneOfGet200Response { } @@ -2405,10 +2405,10 @@ impl OneOfGet200Response { /// Should be implemented in a serde serializer impl std::string::ToString for OneOfGet200Response { fn to_string(&self) -> String { - let params: Vec<String> = vec![ - ].into_iter().flatten().collect(); + let params: Vec<Option<String>> = vec![ + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2500,7 +2500,7 @@ impl OneOfGet200Response { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OptionalObjectHeader(i32); @@ -2539,7 +2539,7 @@ impl OptionalObjectHeader { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct RequiredObjectHeader(bool); @@ -2578,7 +2578,7 @@ impl RequiredObjectHeader { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Result(String); @@ -2674,7 +2674,7 @@ impl StringEnum { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct StringObject(String); @@ -2727,7 +2727,7 @@ impl StringObject { } /// Test a model containing a UUID -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct UuidObject(uuid::Uuid); @@ -2775,7 +2775,7 @@ where serde_xml_rs::wrap_primitives(item, serializer, "camelXmlInner") } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct XmlArray( #[serde(serialize_with = "wrap_in_camelXmlInner")] @@ -2914,7 +2914,7 @@ impl XmlArray { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelXmlInner")] pub struct XmlInner(String); @@ -2968,7 +2968,7 @@ impl XmlInner { } /// An XML object -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "camelXmlObject")] pub struct XmlObject { @@ -2997,7 +2997,7 @@ impl XmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for XmlObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.inner_string.as_ref().map(|inner_string| { vec![ @@ -3014,9 +3014,9 @@ impl std::string::ToString for XmlObject { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3049,7 +3049,7 @@ impl std::str::FromStr for XmlObject { if let Some(key) = key_result { match key { "innerString" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "other_inner_rename" => intermediate_rep.other_inner_rename.push(<isize as std::str::FromStr>::from_str(val)?), + "other_inner_rename" => intermediate_rep.other_inner_rename.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing XmlObject".to_string()) } } diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs index 4e56aec86df..676ef8a5a75 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,223 +14,223 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "0.0.1"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op10GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op11GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op12GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op13GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op14GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op15GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op16GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op17GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op18GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op19GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op1GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op20GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op21GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op22GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op23GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op24GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op25GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op26GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op27GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op28GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op29GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op2GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op30GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op31GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op32GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op33GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op34GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op35GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op36GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op37GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op3GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op4GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op5GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op6GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op7GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op8GetResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Op9GetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index e6112b13787..e0776dbcea5 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,73 +14,73 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = "/v2"; pub const API_VERSION: &str = "1.0.0"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestSpecialTagsResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum Call123exampleResponse { /// success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FakeOuterBooleanSerializeResponse { /// Output boolean OutputBoolean (bool) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FakeOuterCompositeSerializeResponse { /// Output composite OutputComposite (models::OuterComposite) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FakeOuterNumberSerializeResponse { /// Output number OutputNumber (f64) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FakeOuterStringSerializeResponse { /// Output string OutputString (String) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FakeResponseWithNumericalDescriptionResponse { /// 1234 Status200 } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum HyphenParamResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestBodyWithQueryParamsResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestClientModelResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum TestEndpointParametersResponse { /// Invalid username supplied @@ -89,7 +90,7 @@ pub enum TestEndpointParametersResponse { UserNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum TestEnumParametersResponse { /// Invalid request @@ -99,38 +100,38 @@ pub enum TestEnumParametersResponse { NotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestInlineAdditionalPropertiesResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestJsonFormDataResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum TestClassnameResponse { /// successful operation SuccessfulOperation (models::Client) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum AddPetResponse { /// Invalid input InvalidInput } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum DeletePetResponse { /// Invalid pet value InvalidPetValue } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum FindPetsByStatusResponse { /// successful operation @@ -141,7 +142,7 @@ pub enum FindPetsByStatusResponse { InvalidStatusValue } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum FindPetsByTagsResponse { /// successful operation @@ -152,7 +153,7 @@ pub enum FindPetsByTagsResponse { InvalidTagValue } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum GetPetByIdResponse { /// successful operation @@ -166,7 +167,7 @@ pub enum GetPetByIdResponse { PetNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum UpdatePetResponse { /// Invalid ID supplied @@ -179,20 +180,20 @@ pub enum UpdatePetResponse { ValidationException } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum UpdatePetWithFormResponse { /// Invalid input InvalidInput } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum UploadFileResponse { /// successful operation SuccessfulOperation (models::ApiResponse) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum DeleteOrderResponse { /// Invalid ID supplied @@ -202,14 +203,14 @@ pub enum DeleteOrderResponse { OrderNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum GetInventoryResponse { /// successful operation SuccessfulOperation (std::collections::HashMap<String, i32>) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum GetOrderByIdResponse { /// successful operation @@ -223,7 +224,7 @@ pub enum GetOrderByIdResponse { OrderNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum PlaceOrderResponse { /// successful operation @@ -234,25 +235,25 @@ pub enum PlaceOrderResponse { InvalidOrder } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateUserResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateUsersWithArrayInputResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum CreateUsersWithListInputResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum DeleteUserResponse { /// Invalid username supplied @@ -262,7 +263,7 @@ pub enum DeleteUserResponse { UserNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum GetUserByNameResponse { /// successful operation @@ -276,7 +277,7 @@ pub enum GetUserByNameResponse { UserNotFound } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum LoginUserResponse { /// successful operation @@ -298,13 +299,13 @@ pub enum LoginUserResponse { InvalidUsername } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum LogoutUserResponse { /// successful operation SuccessfulOperation } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] pub enum UpdateUserResponse { /// Invalid user supplied diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 63823a6e680..80fe54cab64 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesClass { #[serde(rename = "map_property")] @@ -32,15 +32,15 @@ impl AdditionalPropertiesClass { /// Should be implemented in a serde serializer impl std::string::ToString for AdditionalPropertiesClass { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping map_property in query parameter serialization // Skipping map_of_map_property in query parameter serialization // Skipping map_of_map_property in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -138,7 +138,7 @@ impl AdditionalPropertiesClass { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Animal { #[serde(rename = "className")] @@ -165,7 +165,7 @@ impl Animal { /// Should be implemented in a serde serializer impl std::string::ToString for Animal { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("className".to_string()), Some(self.class_name.to_string()), @@ -178,9 +178,9 @@ impl std::string::ToString for Animal { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -278,7 +278,7 @@ impl Animal { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnimalFarm( Vec<Animal> @@ -416,7 +416,7 @@ impl AnimalFarm { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ApiResponse { #[serde(rename = "code")] @@ -449,7 +449,7 @@ impl ApiResponse { /// Should be implemented in a serde serializer impl std::string::ToString for ApiResponse { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.code.as_ref().map(|code| { vec![ @@ -474,9 +474,9 @@ impl std::string::ToString for ApiResponse { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -509,7 +509,7 @@ impl std::str::FromStr for ApiResponse { if let Some(key) = key_result { match key { - "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val)?), + "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "type" => intermediate_rep.r#type.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "message" => intermediate_rep.message.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ApiResponse".to_string()) @@ -577,7 +577,7 @@ impl ApiResponse { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfArrayOfNumberOnly { #[serde(rename = "ArrayArrayNumber")] @@ -600,12 +600,12 @@ impl ArrayOfArrayOfNumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayOfArrayOfNumberOnly { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping ArrayArrayNumber in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -700,7 +700,7 @@ impl ArrayOfArrayOfNumberOnly { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfNumberOnly { #[serde(rename = "ArrayNumber")] @@ -723,7 +723,7 @@ impl ArrayOfNumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayOfNumberOnly { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.array_number.as_ref().map(|array_number| { vec![ @@ -732,9 +732,9 @@ impl std::string::ToString for ArrayOfNumberOnly { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -829,7 +829,7 @@ impl ArrayOfNumberOnly { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayTest { #[serde(rename = "array_of_string")] @@ -868,7 +868,7 @@ impl ArrayTest { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayTest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.array_of_string.as_ref().map(|array_of_string| { vec![ @@ -889,9 +889,9 @@ impl std::string::ToString for ArrayTest { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -995,7 +995,7 @@ impl ArrayTest { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Capitalization { #[serde(rename = "smallCamel")] @@ -1044,7 +1044,7 @@ impl Capitalization { /// Should be implemented in a serde serializer impl std::string::ToString for Capitalization { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.small_camel.as_ref().map(|small_camel| { vec![ @@ -1093,9 +1093,9 @@ impl std::string::ToString for Capitalization { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1205,7 +1205,7 @@ impl Capitalization { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Cat { #[serde(rename = "className")] @@ -1237,7 +1237,7 @@ impl Cat { /// Should be implemented in a serde serializer impl std::string::ToString for Cat { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("className".to_string()), Some(self.class_name.to_string()), @@ -1258,9 +1258,9 @@ impl std::string::ToString for Cat { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1295,7 +1295,7 @@ impl std::str::FromStr for Cat { match key { "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val)?), + "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Cat".to_string()) } } @@ -1361,7 +1361,7 @@ impl Cat { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct CatAllOf { #[serde(rename = "declawed")] @@ -1384,7 +1384,7 @@ impl CatAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for CatAllOf { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.declawed.as_ref().map(|declawed| { vec![ @@ -1393,9 +1393,9 @@ impl std::string::ToString for CatAllOf { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1426,7 +1426,7 @@ impl std::str::FromStr for CatAllOf { if let Some(key) = key_result { match key { - "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val)?), + "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing CatAllOf".to_string()) } } @@ -1490,7 +1490,7 @@ impl CatAllOf { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Category")] pub struct Category { @@ -1519,7 +1519,7 @@ impl Category { /// Should be implemented in a serde serializer impl std::string::ToString for Category { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.id.as_ref().map(|id| { vec![ @@ -1536,9 +1536,9 @@ impl std::string::ToString for Category { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1570,7 +1570,7 @@ impl std::str::FromStr for Category { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Category".to_string()) } @@ -1637,7 +1637,7 @@ impl Category { } /// Model for testing model with \"_class\" property -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ClassModel { #[serde(rename = "_class")] @@ -1660,7 +1660,7 @@ impl ClassModel { /// Should be implemented in a serde serializer impl std::string::ToString for ClassModel { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self._class.as_ref().map(|_class| { vec![ @@ -1669,9 +1669,9 @@ impl std::string::ToString for ClassModel { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1766,7 +1766,7 @@ impl ClassModel { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Client { #[serde(rename = "client")] @@ -1789,7 +1789,7 @@ impl Client { /// Should be implemented in a serde serializer impl std::string::ToString for Client { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.client.as_ref().map(|client| { vec![ @@ -1798,9 +1798,9 @@ impl std::string::ToString for Client { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -1895,7 +1895,7 @@ impl Client { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Dog { #[serde(rename = "className")] @@ -1927,7 +1927,7 @@ impl Dog { /// Should be implemented in a serde serializer impl std::string::ToString for Dog { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("className".to_string()), Some(self.class_name.to_string()), @@ -1948,9 +1948,9 @@ impl std::string::ToString for Dog { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2051,7 +2051,7 @@ impl Dog { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DogAllOf { #[serde(rename = "breed")] @@ -2074,7 +2074,7 @@ impl DogAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for DogAllOf { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.breed.as_ref().map(|breed| { vec![ @@ -2083,9 +2083,9 @@ impl std::string::ToString for DogAllOf { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2180,7 +2180,7 @@ impl DogAllOf { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "$special[model.name]")] pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { @@ -2204,7 +2204,7 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { /// Should be implemented in a serde serializer impl std::string::ToString for DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.dollar_special_left_square_bracket_property_period_name_right_square_bracket.as_ref().map(|dollar_special_left_square_bracket_property_period_name_right_square_bracket| { vec![ @@ -2213,9 +2213,9 @@ impl std::string::ToString for DollarSpecialLeftSquareBracketModelPeriodNameRigh ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2246,7 +2246,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu if let Some(key) = key_result { match key { - "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val)?), + "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket".to_string()) } } @@ -2310,7 +2310,7 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumArrays { // Note: inline enums are not fully supported by openapi-generator @@ -2346,7 +2346,7 @@ impl EnumArrays { /// Should be implemented in a serde serializer impl std::string::ToString for EnumArrays { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.just_symbol.as_ref().map(|just_symbol| { vec![ @@ -2365,9 +2365,9 @@ impl std::string::ToString for EnumArrays { // Skipping array_array_enum in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2516,7 +2516,7 @@ impl EnumClass { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumTest { // Note: inline enums are not fully supported by openapi-generator @@ -2562,7 +2562,7 @@ impl EnumTest { /// Should be implemented in a serde serializer impl std::string::ToString for EnumTest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.enum_string.as_ref().map(|enum_string| { vec![ @@ -2593,9 +2593,9 @@ impl std::string::ToString for EnumTest { // Skipping outerEnum in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2632,9 +2632,9 @@ impl std::str::FromStr for EnumTest { match key { "enum_string" => intermediate_rep.enum_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "enum_string_required" => intermediate_rep.enum_string_required.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "enum_integer" => intermediate_rep.enum_integer.push(<i32 as std::str::FromStr>::from_str(val)?), - "enum_number" => intermediate_rep.enum_number.push(<f64 as std::str::FromStr>::from_str(val)?), - "outerEnum" => intermediate_rep.outer_enum.push(<models::OuterEnum as std::str::FromStr>::from_str(val)?), + "enum_integer" => intermediate_rep.enum_integer.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "enum_number" => intermediate_rep.enum_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "outerEnum" => intermediate_rep.outer_enum.push(<models::OuterEnum as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing EnumTest".to_string()) } } @@ -2702,7 +2702,7 @@ impl EnumTest { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct FormatTest { #[serde(rename = "integer")] @@ -2781,7 +2781,7 @@ impl FormatTest { /// Should be implemented in a serde serializer impl std::string::ToString for FormatTest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.integer.as_ref().map(|integer| { vec![ @@ -2850,9 +2850,9 @@ impl std::string::ToString for FormatTest { Some("password".to_string()), Some(self.password.to_string()), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -2895,17 +2895,17 @@ impl std::str::FromStr for FormatTest { if let Some(key) = key_result { match key { - "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val)?), - "int32" => intermediate_rep.int32.push(<u32 as std::str::FromStr>::from_str(val)?), - "int64" => intermediate_rep.int64.push(<i64 as std::str::FromStr>::from_str(val)?), - "number" => intermediate_rep.number.push(<f64 as std::str::FromStr>::from_str(val)?), - "float" => intermediate_rep.float.push(<f32 as std::str::FromStr>::from_str(val)?), - "double" => intermediate_rep.double.push(<f64 as std::str::FromStr>::from_str(val)?), + "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "int32" => intermediate_rep.int32.push(<u32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "int64" => intermediate_rep.int64.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "number" => intermediate_rep.number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "float" => intermediate_rep.float.push(<f32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "double" => intermediate_rep.double.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "string" => intermediate_rep.string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "byte" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), "binary" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), - "date" => intermediate_rep.date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), - "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "date" => intermediate_rep.date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing FormatTest".to_string()) @@ -2983,7 +2983,7 @@ impl FormatTest { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct HasOnlyReadOnly { #[serde(rename = "bar")] @@ -3011,7 +3011,7 @@ impl HasOnlyReadOnly { /// Should be implemented in a serde serializer impl std::string::ToString for HasOnlyReadOnly { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.bar.as_ref().map(|bar| { vec![ @@ -3028,9 +3028,9 @@ impl std::string::ToString for HasOnlyReadOnly { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3128,7 +3128,7 @@ impl HasOnlyReadOnly { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct List { #[serde(rename = "123-list")] @@ -3151,7 +3151,7 @@ impl List { /// Should be implemented in a serde serializer impl std::string::ToString for List { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.param_123_list.as_ref().map(|param_123_list| { vec![ @@ -3160,9 +3160,9 @@ impl std::string::ToString for List { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3257,7 +3257,7 @@ impl List { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MapTest { #[serde(rename = "map_map_of_string")] @@ -3292,7 +3292,7 @@ impl MapTest { /// Should be implemented in a serde serializer impl std::string::ToString for MapTest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping map_map_of_string in query parameter serialization // Skipping map_map_of_string in query parameter serialization @@ -3301,9 +3301,9 @@ impl std::string::ToString for MapTest { // Skipping map_of_enum_string in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3404,7 +3404,7 @@ impl MapTest { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MixedPropertiesAndAdditionalPropertiesClass { #[serde(rename = "uuid")] @@ -3437,7 +3437,7 @@ impl MixedPropertiesAndAdditionalPropertiesClass { /// Should be implemented in a serde serializer impl std::string::ToString for MixedPropertiesAndAdditionalPropertiesClass { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping uuid in query parameter serialization // Skipping dateTime in query parameter serialization @@ -3445,9 +3445,9 @@ impl std::string::ToString for MixedPropertiesAndAdditionalPropertiesClass { // Skipping map in query parameter serialization // Skipping map in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3481,7 +3481,7 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { if let Some(key) = key_result { match key { "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "map" => return std::result::Result::Err("Parsing a container in this style is not supported in MixedPropertiesAndAdditionalPropertiesClass".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MixedPropertiesAndAdditionalPropertiesClass".to_string()) } @@ -3549,7 +3549,7 @@ impl MixedPropertiesAndAdditionalPropertiesClass { } /// Model for testing model name starting with number -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Name")] pub struct Model200Response { @@ -3578,7 +3578,7 @@ impl Model200Response { /// Should be implemented in a serde serializer impl std::string::ToString for Model200Response { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.name.as_ref().map(|name| { vec![ @@ -3595,9 +3595,9 @@ impl std::string::ToString for Model200Response { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3629,7 +3629,7 @@ impl std::str::FromStr for Model200Response { if let Some(key) = key_result { match key { - "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val)?), + "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "class" => intermediate_rep.class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Model200Response".to_string()) } @@ -3696,7 +3696,7 @@ impl Model200Response { } /// Model for testing model name same as property name -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Name")] pub struct Name { @@ -3734,7 +3734,7 @@ impl Name { /// Should be implemented in a serde serializer impl std::string::ToString for Name { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("name".to_string()), Some(self.name.to_string()), @@ -3763,9 +3763,9 @@ impl std::string::ToString for Name { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3799,10 +3799,10 @@ impl std::str::FromStr for Name { if let Some(key) = key_result { match key { - "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val)?), - "snake_case" => intermediate_rep.snake_case.push(<i32 as std::str::FromStr>::from_str(val)?), + "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "snake_case" => intermediate_rep.snake_case.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "property" => intermediate_rep.property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "123Number" => intermediate_rep.param_123_number.push(<isize as std::str::FromStr>::from_str(val)?), + "123Number" => intermediate_rep.param_123_number.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Name".to_string()) } } @@ -3869,7 +3869,7 @@ impl Name { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NumberOnly { #[serde(rename = "JustNumber")] @@ -3892,7 +3892,7 @@ impl NumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for NumberOnly { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.just_number.as_ref().map(|just_number| { vec![ @@ -3901,9 +3901,9 @@ impl std::string::ToString for NumberOnly { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -3934,7 +3934,7 @@ impl std::str::FromStr for NumberOnly { if let Some(key) = key_result { match key { - "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val)?), + "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing NumberOnly".to_string()) } } @@ -3998,7 +3998,7 @@ impl NumberOnly { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectContainingObjectWithOnlyAdditionalProperties { #[serde(rename = "inner")] @@ -4021,12 +4021,12 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectContainingObjectWithOnlyAdditionalProperties { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping inner in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -4057,7 +4057,7 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { if let Some(key) = key_result { match key { - "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val)?), + "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectContainingObjectWithOnlyAdditionalProperties".to_string()) } } @@ -4121,7 +4121,7 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithOnlyAdditionalProperties(std::collections::HashMap<String, String>); @@ -4180,7 +4180,7 @@ impl ObjectWithOnlyAdditionalProperties { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Order")] pub struct Order { @@ -4231,7 +4231,7 @@ impl Order { /// Should be implemented in a serde serializer impl std::string::ToString for Order { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.id.as_ref().map(|id| { vec![ @@ -4274,9 +4274,9 @@ impl std::string::ToString for Order { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -4312,12 +4312,12 @@ impl std::str::FromStr for Order { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), - "petId" => intermediate_rep.pet_id.push(<i64 as std::str::FromStr>::from_str(val)?), - "quantity" => intermediate_rep.quantity.push(<i32 as std::str::FromStr>::from_str(val)?), - "shipDate" => intermediate_rep.ship_date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val)?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "petId" => intermediate_rep.pet_id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "quantity" => intermediate_rep.quantity.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + "shipDate" => intermediate_rep.ship_date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "complete" => intermediate_rep.complete.push(<bool as std::str::FromStr>::from_str(val)?), + "complete" => intermediate_rep.complete.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) } } @@ -4386,7 +4386,7 @@ impl Order { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterBoolean(bool); @@ -4425,7 +4425,7 @@ impl OuterBoolean { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterComposite { #[serde(rename = "my_number")] @@ -4458,7 +4458,7 @@ impl OuterComposite { /// Should be implemented in a serde serializer impl std::string::ToString for OuterComposite { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.my_number.as_ref().map(|my_number| { vec![ @@ -4483,9 +4483,9 @@ impl std::string::ToString for OuterComposite { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -4518,9 +4518,9 @@ impl std::str::FromStr for OuterComposite { if let Some(key) = key_result { match key { - "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val)?), + "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "my_string" => intermediate_rep.my_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "my_boolean" => intermediate_rep.my_boolean.push(<bool as std::str::FromStr>::from_str(val)?), + "my_boolean" => intermediate_rep.my_boolean.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing OuterComposite".to_string()) } } @@ -4634,7 +4634,7 @@ impl OuterEnum { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterNumber(f64); @@ -4673,7 +4673,7 @@ impl OuterNumber { } } -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterString(String); @@ -4725,7 +4725,7 @@ impl OuterString { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Pet")] pub struct Pet { @@ -4774,7 +4774,7 @@ impl Pet { /// Should be implemented in a serde serializer impl std::string::ToString for Pet { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.id.as_ref().map(|id| { vec![ @@ -4803,9 +4803,9 @@ impl std::string::ToString for Pet { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -4841,7 +4841,7 @@ impl std::str::FromStr for Pet { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "category" => intermediate_rep.category.push(<models::Category as std::str::FromStr>::from_str(val)?), "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "photoUrls" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), @@ -4915,7 +4915,7 @@ impl Pet { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ReadOnlyFirst { #[serde(rename = "bar")] @@ -4943,7 +4943,7 @@ impl ReadOnlyFirst { /// Should be implemented in a serde serializer impl std::string::ToString for ReadOnlyFirst { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.bar.as_ref().map(|bar| { vec![ @@ -4960,9 +4960,9 @@ impl std::string::ToString for ReadOnlyFirst { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -5061,7 +5061,7 @@ impl ReadOnlyFirst { } /// Model for testing reserved words -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Return")] pub struct Return { @@ -5085,7 +5085,7 @@ impl Return { /// Should be implemented in a serde serializer impl std::string::ToString for Return { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.r#return.as_ref().map(|r#return| { vec![ @@ -5094,9 +5094,9 @@ impl std::string::ToString for Return { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -5127,7 +5127,7 @@ impl std::str::FromStr for Return { if let Some(key) = key_result { match key { - "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val)?), + "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Return".to_string()) } } @@ -5191,7 +5191,7 @@ impl Return { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "Tag")] pub struct Tag { @@ -5220,7 +5220,7 @@ impl Tag { /// Should be implemented in a serde serializer impl std::string::ToString for Tag { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.id.as_ref().map(|id| { vec![ @@ -5237,9 +5237,9 @@ impl std::string::ToString for Tag { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -5271,7 +5271,7 @@ impl std::str::FromStr for Tag { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Tag".to_string()) } @@ -5337,7 +5337,7 @@ impl Tag { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "User")] pub struct User { @@ -5397,7 +5397,7 @@ impl User { /// Should be implemented in a serde serializer impl std::string::ToString for User { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.id.as_ref().map(|id| { vec![ @@ -5462,9 +5462,9 @@ impl std::string::ToString for User { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -5502,14 +5502,14 @@ impl std::str::FromStr for User { if let Some(key) = key_result { match key { - "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val)?), + "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "username" => intermediate_rep.username.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "firstName" => intermediate_rep.first_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "lastName" => intermediate_rep.last_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "email" => intermediate_rep.email.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "phone" => intermediate_rep.phone.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "userStatus" => intermediate_rep.user_status.push(<i32 as std::str::FromStr>::from_str(val)?), + "userStatus" => intermediate_rep.user_status.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing User".to_string()) } } diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs index 553cc3be995..4726f174638 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,7 +14,7 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum PingGetResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs index a2951a5a6ca..c38b2c2b77b 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs @@ -1,5 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports)] +#![allow(clippy::derive_partial_eq_without_eq)] use async_trait::async_trait; use futures::Stream; @@ -13,60 +14,60 @@ type ServiceError = Box<dyn Error + Send + Sync + 'static>; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "2.3.4"; -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum AllOfGetResponse { /// OK OK (models::AllOfObject) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum DummyGetResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum DummyPutResponse { /// Success Success } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum FileResponseGetResponse { /// Success Success (swagger::ByteArray) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum GetStructuredYamlResponse { /// OK OK (String) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum HtmlPostResponse { /// Success Success (String) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum PostYamlResponse { /// OK OK } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum RawJsonGetResponse { /// Success Success (serde_json::Value) } -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize)] pub enum SoloObjectPostResponse { /// OK OK diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs index ebea234c19d..5c29ce926cd 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs @@ -4,7 +4,7 @@ use crate::models; #[cfg(any(feature = "client", feature = "server"))] use crate::header; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ANullableContainer { #[serde(rename = "NullableThing")] @@ -33,7 +33,7 @@ impl ANullableContainer { /// Should be implemented in a serde serializer impl std::string::ToString for ANullableContainer { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.nullable_thing.as_ref().map(|nullable_thing| { vec![ @@ -46,9 +46,9 @@ impl std::string::ToString for ANullableContainer { Some("RequiredNullableThing".to_string()), Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -138,7 +138,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// An additionalPropertiesObject -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesObject(std::collections::HashMap<String, String>); @@ -188,7 +188,7 @@ impl ::std::str::FromStr for AdditionalPropertiesObject { } } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AllOfObject { #[serde(rename = "sampleProperty")] @@ -216,7 +216,7 @@ impl AllOfObject { /// Should be implemented in a serde serializer impl std::string::ToString for AllOfObject { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.sample_property.as_ref().map(|sample_property| { vec![ @@ -233,9 +233,9 @@ impl std::string::ToString for AllOfObject { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -324,7 +324,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct BaseAllOf { #[serde(rename = "sampleBasePropery")] @@ -347,7 +347,7 @@ impl BaseAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for BaseAllOf { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.sample_base_propery.as_ref().map(|sample_base_propery| { vec![ @@ -356,9 +356,9 @@ impl std::string::ToString for BaseAllOf { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -444,7 +444,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DummyPutRequest { #[serde(rename = "id")] @@ -471,7 +471,7 @@ impl DummyPutRequest { /// Should be implemented in a serde serializer impl std::string::ToString for DummyPutRequest { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("id".to_string()), Some(self.id.to_string()), @@ -484,9 +484,9 @@ impl std::string::ToString for DummyPutRequest { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -576,7 +576,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// structured response -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct GetYamlResponse { /// Inner string @@ -600,7 +600,7 @@ impl GetYamlResponse { /// Should be implemented in a serde serializer impl std::string::ToString for GetYamlResponse { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ self.value.as_ref().map(|value| { vec![ @@ -609,9 +609,9 @@ impl std::string::ToString for GetYamlResponse { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -698,7 +698,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal /// An object of objects -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjects { #[serde(rename = "inner")] @@ -721,12 +721,12 @@ impl ObjectOfObjects { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectOfObjects { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ // Skipping inner in query parameter serialization - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -812,7 +812,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal } -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjectsInner { #[serde(rename = "required_thing")] @@ -839,7 +839,7 @@ impl ObjectOfObjectsInner { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectOfObjectsInner { fn to_string(&self) -> String { - let params: Vec<String> = vec![ + let params: Vec<Option<String>> = vec![ Some("required_thing".to_string()), Some(self.required_thing.to_string()), @@ -852,9 +852,9 @@ impl std::string::ToString for ObjectOfObjectsInner { ].join(",") }), - ].into_iter().flatten().collect(); + ]; - params.join(",") + params.into_iter().flatten().collect::<Vec<_>>().join(",") } } @@ -887,7 +887,7 @@ impl std::str::FromStr for ObjectOfObjectsInner { if let Some(key) = key_result { match key { "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val)?), + "optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string()) } } -- GitLab From 91f368bec61e8fae492c9a69eb1c355a3b778f4a Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 13:29:55 +0900 Subject: [PATCH 14/18] fix(rust-server): Allow clippy::redundant_clone instead of removing redundant map_err --- .../resources/rust-server/models.mustache | 3 +- .../output/multipart-v3/src/models.rs | 4 +- .../output/no-example-v3/src/models.rs | 1 + .../output/openapi-v3/src/models.rs | 19 ++++- .../src/models.rs | 82 ++++++++++++++++++- .../output/rust-server-test/src/models.rs | 11 ++- 6 files changed, 114 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 5a25de0d286..d7ad169865d 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -399,7 +399,8 @@ impl std::str::FromStr for {{{classname}}} { "{{{baseName}}}" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in {{{classname}}}".to_string()), {{/isNullable}} {{^isNullable}} - "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val){{^isModel}}.map_err(|x| x.to_string()){{/isModel}}?), + #[allow(clippy::redundant_clone)] + "{{{baseName}}}" => intermediate_rep.{{{name}}}.push(<{{{dataType}}} as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), {{/isNullable}} {{/isContainer}} {{/isByteArray}} diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs index e0c8cbea9d7..5cade05779a 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs @@ -80,7 +80,8 @@ impl std::str::FromStr for MultipartRelatedRequest { if let Some(key) = key_result { match key { - "object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val)?), + #[allow(clippy::redundant_clone)] + "object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "optional_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()), "required_binary_field" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipartRelatedRequest".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MultipartRelatedRequest".to_string()) @@ -213,6 +214,7 @@ impl std::str::FromStr for MultipartRequestObjectField { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "field_b" => return std::result::Result::Err("Parsing a container in this style is not supported in MultipartRequestObjectField".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MultipartRequestObjectField".to_string()) diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs index a74bfb18249..2c4d68f18d9 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs @@ -69,6 +69,7 @@ impl std::str::FromStr for OpGetRequest { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing OpGetRequest".to_string()) } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs index 63fe98547a5..b5e69a14d94 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs @@ -331,6 +331,7 @@ impl std::str::FromStr for AnotherXmlObject { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing AnotherXmlObject".to_string()) } @@ -742,8 +743,10 @@ impl std::str::FromStr for AnyOfProperty { if let Some(key) = key_result { match key { - "requiredAnyOf" => intermediate_rep.required_any_of.push(<models::AnyOfObject as std::str::FromStr>::from_str(val)?), - "optionalAnyOf" => intermediate_rep.optional_any_of.push(<models::Model12345AnyOfObject as std::str::FromStr>::from_str(val)?), + #[allow(clippy::redundant_clone)] + "requiredAnyOf" => intermediate_rep.required_any_of.push(<models::AnyOfObject as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] + "optionalAnyOf" => intermediate_rep.optional_any_of.push(<models::Model12345AnyOfObject as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing AnyOfProperty".to_string()) } } @@ -883,7 +886,9 @@ impl std::str::FromStr for DuplicateXmlObject { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "inner_array" => intermediate_rep.inner_array.push(<models::XmlArray as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DuplicateXmlObject".to_string()) } @@ -1338,6 +1343,7 @@ impl std::str::FromStr for MultigetGet201Response { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing MultigetGet201Response".to_string()) } @@ -1849,7 +1855,9 @@ impl std::str::FromStr for ObjectHeader { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "optionalObjectHeader" => intermediate_rep.optional_object_header.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectHeader".to_string()) } @@ -1989,7 +1997,9 @@ impl std::str::FromStr for ObjectParam { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "optionalParam" => intermediate_rep.optional_param.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectParam".to_string()) } @@ -2136,9 +2146,12 @@ impl std::str::FromStr for ObjectUntypedProps { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "required_untyped_nullable" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ObjectUntypedProps".to_string()), + #[allow(clippy::redundant_clone)] "not_required_untyped" => intermediate_rep.not_required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "not_required_untyped_nullable" => intermediate_rep.not_required_untyped_nullable.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectUntypedProps".to_string()) } @@ -3048,7 +3061,9 @@ impl std::str::FromStr for XmlObject { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "innerString" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "other_inner_rename" => intermediate_rep.other_inner_rename.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing XmlObject".to_string()) } diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 80fe54cab64..1bd3c22d2b3 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -212,7 +212,9 @@ impl std::str::FromStr for Animal { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Animal".to_string()) } @@ -509,8 +511,11 @@ impl std::str::FromStr for ApiResponse { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "type" => intermediate_rep.r#type.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "message" => intermediate_rep.message.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ApiResponse".to_string()) } @@ -1131,11 +1136,17 @@ impl std::str::FromStr for Capitalization { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "smallCamel" => intermediate_rep.small_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "CapitalCamel" => intermediate_rep.capital_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "small_Snake" => intermediate_rep.small_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "Capital_Snake" => intermediate_rep.capital_snake.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "SCA_ETH_Flow_Points" => intermediate_rep.sca_eth_flow_points.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "ATT_NAME" => intermediate_rep.att_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Capitalization".to_string()) } @@ -1293,8 +1304,11 @@ impl std::str::FromStr for Cat { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Cat".to_string()) } @@ -1426,6 +1440,7 @@ impl std::str::FromStr for CatAllOf { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing CatAllOf".to_string()) } @@ -1570,7 +1585,9 @@ impl std::str::FromStr for Category { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Category".to_string()) } @@ -1702,6 +1719,7 @@ impl std::str::FromStr for ClassModel { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "_class" => intermediate_rep._class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ClassModel".to_string()) } @@ -1831,6 +1849,7 @@ impl std::str::FromStr for Client { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "client" => intermediate_rep.client.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Client".to_string()) } @@ -1983,8 +2002,11 @@ impl std::str::FromStr for Dog { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "color" => intermediate_rep.color.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Dog".to_string()) } @@ -2116,6 +2138,7 @@ impl std::str::FromStr for DogAllOf { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DogAllOf".to_string()) } @@ -2246,6 +2269,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket".to_string()) } @@ -2400,6 +2424,7 @@ impl std::str::FromStr for EnumArrays { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "just_symbol" => intermediate_rep.just_symbol.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), "array_array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), @@ -2630,10 +2655,15 @@ impl std::str::FromStr for EnumTest { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "enum_string" => intermediate_rep.enum_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "enum_string_required" => intermediate_rep.enum_string_required.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "enum_integer" => intermediate_rep.enum_integer.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "enum_number" => intermediate_rep.enum_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "outerEnum" => intermediate_rep.outer_enum.push(<models::OuterEnum as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing EnumTest".to_string()) } @@ -2895,18 +2925,29 @@ impl std::str::FromStr for FormatTest { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "int32" => intermediate_rep.int32.push(<u32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "int64" => intermediate_rep.int64.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "number" => intermediate_rep.number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "float" => intermediate_rep.float.push(<f32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "double" => intermediate_rep.double.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "string" => intermediate_rep.string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "byte" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), "binary" => return std::result::Result::Err("Parsing binary data in this style is not supported in FormatTest".to_string()), + #[allow(clippy::redundant_clone)] "date" => intermediate_rep.date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing FormatTest".to_string()) } @@ -3062,7 +3103,9 @@ impl std::str::FromStr for HasOnlyReadOnly { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing HasOnlyReadOnly".to_string()) } @@ -3193,6 +3236,7 @@ impl std::str::FromStr for List { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "123-list" => intermediate_rep.param_123_list.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing List".to_string()) } @@ -3480,7 +3524,9 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "dateTime" => intermediate_rep.date_time.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "map" => return std::result::Result::Err("Parsing a container in this style is not supported in MixedPropertiesAndAdditionalPropertiesClass".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing MixedPropertiesAndAdditionalPropertiesClass".to_string()) @@ -3629,7 +3675,9 @@ impl std::str::FromStr for Model200Response { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "class" => intermediate_rep.class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Model200Response".to_string()) } @@ -3799,9 +3847,13 @@ impl std::str::FromStr for Name { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "snake_case" => intermediate_rep.snake_case.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "property" => intermediate_rep.property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "123Number" => intermediate_rep.param_123_number.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Name".to_string()) } @@ -3934,6 +3986,7 @@ impl std::str::FromStr for NumberOnly { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing NumberOnly".to_string()) } @@ -4057,6 +4110,7 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectContainingObjectWithOnlyAdditionalProperties".to_string()) } @@ -4312,11 +4366,17 @@ impl std::str::FromStr for Order { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "petId" => intermediate_rep.pet_id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "quantity" => intermediate_rep.quantity.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "shipDate" => intermediate_rep.ship_date.push(<chrono::DateTime::<chrono::Utc> as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "complete" => intermediate_rep.complete.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) } @@ -4518,8 +4578,11 @@ impl std::str::FromStr for OuterComposite { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "my_string" => intermediate_rep.my_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "my_boolean" => intermediate_rep.my_boolean.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing OuterComposite".to_string()) } @@ -4841,11 +4904,15 @@ impl std::str::FromStr for Pet { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), - "category" => intermediate_rep.category.push(<models::Category as std::str::FromStr>::from_str(val)?), + #[allow(clippy::redundant_clone)] + "category" => intermediate_rep.category.push(<models::Category as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), "photoUrls" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), "tags" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), + #[allow(clippy::redundant_clone)] "status" => intermediate_rep.status.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Pet".to_string()) } @@ -4994,7 +5061,9 @@ impl std::str::FromStr for ReadOnlyFirst { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "baz" => intermediate_rep.baz.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ReadOnlyFirst".to_string()) } @@ -5127,6 +5196,7 @@ impl std::str::FromStr for Return { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Return".to_string()) } @@ -5271,7 +5341,9 @@ impl std::str::FromStr for Tag { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Tag".to_string()) } @@ -5502,13 +5574,21 @@ impl std::str::FromStr for User { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "username" => intermediate_rep.username.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "firstName" => intermediate_rep.first_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "lastName" => intermediate_rep.last_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "email" => intermediate_rep.email.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "phone" => intermediate_rep.phone.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "userStatus" => intermediate_rep.user_status.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing User".to_string()) } diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs index 5c29ce926cd..130d0e292aa 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs @@ -267,7 +267,9 @@ impl std::str::FromStr for AllOfObject { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string()) } @@ -389,6 +391,7 @@ impl std::str::FromStr for BaseAllOf { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string()) } @@ -518,7 +521,9 @@ impl std::str::FromStr for DummyPutRequest { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string()) } @@ -642,6 +647,7 @@ impl std::str::FromStr for GetYamlResponse { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string()) } @@ -757,7 +763,8 @@ impl std::str::FromStr for ObjectOfObjects { if let Some(key) = key_result { match key { - "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val)?), + #[allow(clippy::redundant_clone)] + "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string()) } } @@ -886,7 +893,9 @@ impl std::str::FromStr for ObjectOfObjectsInner { if let Some(key) = key_result { match key { + #[allow(clippy::redundant_clone)] "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), + #[allow(clippy::redundant_clone)] "optional_thing" => intermediate_rep.optional_thing.push(<isize as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string()) } -- GitLab From 61083a64d5acf5daf6d0cb87b59670138095c1cf Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Tue, 20 Sep 2022 14:16:27 +0900 Subject: [PATCH 15/18] fix(rust-server): Resolve and dismiss lots of warnings to satisfy clippy on samples --- .../codegen/languages/RustServerCodegen.java | 1 + .../rust-server/client-callbacks.mustache | 4 +- .../rust-server/client-operation.mustache | 26 +- .../resources/rust-server/context.mustache | 10 +- .../main/resources/rust-server/lib.mustache | 8 +- .../resources/rust-server/models.mustache | 10 +- .../resources/rust-server/server-mod.mustache | 4 +- .../rust-server/server-operation.mustache | 30 +- .../rust-server/server-paths.mustache | 1 + .../server-service-header.mustache | 2 +- .../output/multipart-v3/src/client/mod.rs | 8 +- .../output/multipart-v3/src/lib.rs | 6 +- .../output/multipart-v3/src/models.rs | 12 +- .../output/multipart-v3/src/server/mod.rs | 38 +-- .../output/no-example-v3/src/lib.rs | 6 +- .../output/no-example-v3/src/models.rs | 4 +- .../output/no-example-v3/src/server/mod.rs | 8 +- .../output/openapi-v3/src/client/callbacks.rs | 22 +- .../output/openapi-v3/src/client/mod.rs | 36 +-- .../output/openapi-v3/src/context.rs | 2 +- .../rust-server/output/openapi-v3/src/lib.rs | 8 +- .../output/openapi-v3/src/models.rs | 134 +++++---- .../output/openapi-v3/src/server/callbacks.rs | 1 + .../output/openapi-v3/src/server/mod.rs | 142 ++++----- .../rust-server/output/ops-v3/src/lib.rs | 6 +- .../output/ops-v3/src/server/mod.rs | 152 +++++----- .../src/client/mod.rs | 51 +++- .../src/context.rs | 8 +- .../src/lib.rs | 6 +- .../src/models.rs | 216 +++++++++----- .../src/server/mod.rs | 271 +++++++++--------- .../output/ping-bearer-auth/src/client/mod.rs | 2 + .../output/ping-bearer-auth/src/context.rs | 2 +- .../output/ping-bearer-auth/src/lib.rs | 6 +- .../output/ping-bearer-auth/src/server/mod.rs | 14 +- .../output/rust-server-test/src/lib.rs | 6 +- .../output/rust-server-test/src/models.rs | 28 +- .../output/rust-server-test/src/server/mod.rs | 40 +-- 38 files changed, 750 insertions(+), 581 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index a05432b9003..f54e4936fe3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -568,6 +568,7 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon // basePath on the front. for (CodegenParameter param : op.pathParams) { // Replace {baseName} with (?P<baseName>[^/?#]*) for regex + // TODO: Sanitize baseName to avoid using '-' (see clippy::invalid_regex) String paramSearch = "{" + param.baseName + "}"; String paramReplace = "(?P<" + param.baseName + ">[^/?#]*)"; diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache index bafd04b1b77..44e16903d94 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache @@ -49,7 +49,7 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { {{#apiInfo}} {{#apis}} {{#operations}} @@ -58,7 +58,7 @@ impl<T> RequestParser<T> for ApiRequestParser { {{#urls}} {{#requests}} // {{{operationId}}} - {{{httpMethod}}} {{{path}}} - &hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"), + hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"), {{/requests}} {{/urls}} {{/callbacks}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache index ca566860288..a93adb61e0d 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache @@ -49,7 +49,7 @@ ¶m_{{{paramName}}}.iter().map(ToString::to_string).collect::<Vec<String>>().join(",")); {{/isArray}} {{^isArray}} - ¶m_{{{paramName}}}.to_string()); + ¶m_{{{paramName}}}{{^isString}}.to_string(){{/isString}}); {{/isArray}} {{/x-consumes-json}} {{/vendorExtensions}} @@ -60,10 +60,8 @@ {{#authMethods}} {{#isApiKey}} {{#isKeyInQuery}} - if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() { - if let AuthData::ApiKey(ref api_key) = *auth_data { - query_string.append_pair("{{keyParamName}}", api_key); - } + if let Some(AuthData::ApiKey(ref api_key)) = (context as &dyn Has<Option<AuthData>>).get().as_ref() { + query_string.append_pair("{{keyParamName}}", api_key); } {{/isKeyInQuery}} {{/isApiKey}} @@ -187,8 +185,8 @@ // no such boundary is used. let mut boundary = generate_boundary(); for b in boundary.iter_mut() { - if b == &('/' as u8) { - *b = '=' as u8; + if b == &(b'/') { + *b = b'='; } } @@ -257,7 +255,7 @@ {{/x-consumes-plain-text}} {{#required}} {{#x-consumes-xml}} - let body = param_{{{paramName}}}.to_xml(); + let body = param_{{{paramName}}}.as_xml(); {{/x-consumes-xml}} {{#x-consumes-json}} let body = serde_json::to_string(¶m_{{{paramName}}}).expect("impossible to fail to serialize"); @@ -266,7 +264,7 @@ {{^required}} let body = param_{{{paramName}}}.map(|ref body| { {{#x-consumes-xml}} - body.to_xml() + body.as_xml() {{/x-consumes-xml}} {{#x-consumes-json}} serde_json::to_string(body).expect("impossible to fail to serialize") @@ -305,8 +303,10 @@ }); {{#hasAuthMethods}} + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { {{#authMethods}} {{#isBasicBasic}} @@ -364,6 +364,7 @@ {{/required}} request.headers_mut().append( HeaderName::from_static("{{{nameInLowerCase}}}"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_{{{paramName}}}.clone()).try_into() { Ok(header) => header, Err(e) => { @@ -398,12 +399,11 @@ return Err(ApiError(format!("Invalid response header {{baseName}} for response {{code}} - {}", e))); }, }; - let response_{{{name}}} = response_{{{name}}}.0; {{#required}} - response_{{{name}}} + response_{{{name}}}.0 {{/required}} {{^required}} - Some(response_{{{name}}}) + Some(response_{{{name}}}.0) {{/required}} }, {{#required}} @@ -450,7 +450,7 @@ {{#headers}} {{#-first}} { - body: body, + body, {{/-first}} {{{name}}}: response_{{name}}, {{#-last}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/context.mustache b/modules/openapi-generator/src/main/resources/rust-server/context.mustache index f3e1c5e130a..4ec03e0d2e4 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/context.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/context.mustache @@ -110,7 +110,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Basic; use std::ops::Deref; - if let Some(basic) = swagger::auth::from_headers::<Basic>(&headers) { + if let Some(basic) = swagger::auth::from_headers::<Basic>(headers) { let auth_data = AuthData::Basic(basic); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -123,7 +123,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Bearer; use std::ops::Deref; - if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) { + if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) { let auth_data = AuthData::Bearer(bearer); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -137,7 +137,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Bearer; use std::ops::Deref; - if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) { + if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) { let auth_data = AuthData::Bearer(bearer); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -151,7 +151,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::api_key_from_header; - if let Some(header) = api_key_from_header(&headers, "{{{keyParamName}}}") { + if let Some(header) = api_key_from_header(headers, "{{{keyParamName}}}") { let auth_data = AuthData::ApiKey(header); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -165,7 +165,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C let key = form_urlencoded::parse(request.uri().query().unwrap_or_default().as_bytes()) .filter(|e| e.0 == "{{{keyParamName}}}") .map(|e| e.1.clone().into_owned()) - .nth(0); + .next(); if let Some(key) = key { let auth_data = AuthData::ApiKey(key); let context = context.push(Some(auth_data)); diff --git a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache index 586210bf0e0..c642b08a65f 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -27,6 +27,7 @@ pub const API_VERSION: &str = "{{{.}}}"; {{/apiInfo}} /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -54,6 +55,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; @@ -224,7 +226,7 @@ pub trait CallbackApiNoContext<C: Send + Sync> { pub trait CallbackContextWrapperExt<C: Send + Sync> where Self: Sized { /// Binds this API to a context. - fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>; + fn with_context(self, context: C) -> ContextWrapper<Self, C>; } impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackContextWrapperExt<C> for T { diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index d7ad169865d..30be5a54f35 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -189,7 +189,7 @@ impl<'a> std::iter::IntoIterator for &'a {{{classname}}} { type IntoIter = std::slice::Iter<'a, {{{arrayModelType}}}>; fn into_iter(self) -> Self::IntoIter { - (&self.0).into_iter() + (&self.0).iter() } } @@ -198,7 +198,7 @@ impl<'a> std::iter::IntoIterator for &'a mut {{{classname}}} { type IntoIter = std::slice::IterMut<'a, {{{arrayModelType}}}>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).into_iter() + (&mut self.0).iter_mut() } } @@ -360,8 +360,9 @@ impl std::str::FromStr for {{{classname}}} { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { {{#vars}} pub {{{name}}}: Vec<{{{dataType}}}>, @@ -381,6 +382,7 @@ impl std::str::FromStr for {{{classname}}} { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { {{#vars}} {{#isBinary}} @@ -485,7 +487,7 @@ impl {{{classname}}} { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { {{#xmlNamespace}} let mut namespaces = std::collections::BTreeMap::new(); // An empty string is used to indicate a global namespace in xmltree. diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache index d38f3b5b3da..08e63ca087e 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-mod.mustache @@ -28,13 +28,13 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { {{#apiInfo}} {{#apis}} {{#operations}} {{#operation}} // {{{operationId}}} - {{{httpMethod}}} {{{path}}} - &hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"), + hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Some("{{{operationId}}}"), {{/operation}} {{/operations}} {{/apis}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache index b5e1bed5c7d..a8ac8bbc802 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache @@ -1,10 +1,10 @@ // {{{operationId}}} - {{{httpMethod}}} {{{path}}} - &hyper::Method::{{vendorExtensions.x-http-method}} if path.matched(paths::ID_{{vendorExtensions.x-path-id}}) => { + hyper::Method::{{vendorExtensions.x-http-method}} if path.matched(paths::ID_{{vendorExtensions.x-path-id}}) => { {{#hasAuthMethods}} { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -50,10 +50,10 @@ {{/x-consumes-multipart}} {{#x-has-path-params}} // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_{{{x-path-id}}} - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE {{{x-path-id}}} in set but failed match against \"{}\"", path, paths::REGEX_{{{x-path-id}}}.as_str()) ); @@ -139,7 +139,7 @@ {{/required}} {{/vendorExtensions.x-consumes-json}} {{#vendorExtensions.x-consumes-json}} - .nth(0); + .next(); let param_{{{paramName}}} = match param_{{{paramName}}} { Some(param_{{{paramName}}}) => { let param_{{{paramName}}} = @@ -167,7 +167,7 @@ {{/vendorExtensions.x-consumes-json}} {{/isArray}} {{^isArray}} - .nth(0); + .next(); let param_{{{paramName}}} = match param_{{{paramName}}} { Some(param_{{{paramName}}}) => { let param_{{{paramName}}} = @@ -292,7 +292,7 @@ _ => { return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Unable to process all message parts"))) + .body(Body::from("Unable to process all message parts".to_string())) .expect("Unable to create Bad Request response due to failure to process all message")) }, }; @@ -335,7 +335,7 @@ return Ok( Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Missing required form parameter {{{paramName}}}"))) + .body(Body::from("Missing required form parameter {{{paramName}}}".to_string())) .expect("Unable to create Bad Request due to missing required form parameter {{{paramName}}}")) {{/required}} {{^required}} @@ -378,9 +378,9 @@ // Extract the top-level content type header. let content_type_mime = headers .get(CONTENT_TYPE) - .ok_or("Missing content-type header".to_string()) + .ok_or_else(|| "Missing content-type header".to_string()) .and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for {{operationId}}: {}", e))) - .and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for {{operationId}}"))); + .and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for {{operationId}}".to_string())); // Insert top-level content type header into a Headers object. let mut multi_part_headers = Headers::new(); @@ -415,7 +415,7 @@ for node in nodes { if let Node::Part(part) = node { let content_type = part.content_type().map(|x| format!("{}",x)); - match content_type.as_ref().map(|x| x.as_str()) { + match content_type.as_deref() { {{#formParams}} {{^isBinary}} Some("{{{contentType}}}") if param_{{{paramName}}}.is_none() => { @@ -464,7 +464,7 @@ Some(x) => x, None => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Missing required multipart/related parameter {{{paramName}}}"))) + .body(Body::from("Missing required multipart/related parameter {{{paramName}}}".to_string())) .expect("Unable to create Bad Request response for missing multipart/related parameter {{{paramName}}} due to schema")) }; {{/required}} @@ -641,7 +641,7 @@ }, Err(e) => Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't read multipart body"))) + .body(Body::from("Couldn't read multipart body".to_string())) .expect("Unable to create Bad Request response due to unable read multipart body")), } {{/vendorExtensions}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-paths.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-paths.mustache index 2930a49e163..c5297d058d2 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-paths.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-paths.mustache @@ -14,6 +14,7 @@ mod paths { {{#hasPathParams}} lazy_static! { pub static ref REGEX_{{{PATH_ID}}}: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^{{{basePathWithoutHost}}}{{{pathRegEx}}}") .expect("Unable to create regex for {{{PATH_ID}}}"); } diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache index 3da968d23bc..01fde31fa1e 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-service-header.mustache @@ -63,4 +63,4 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where This match statement is duplicated below in `parse_operation_id()`. Please update both places if changing how this code is autogenerated. }} - match &method { + match method { diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs index bd02a236767..eaea306af10 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/client/mod.rs @@ -429,8 +429,8 @@ impl<S, C> Api<C> for Client<S, C> where // no such boundary is used. let mut boundary = generate_boundary(); for b in boundary.iter_mut() { - if b == &('/' as u8) { - *b = '=' as u8; + if b == &(b'/') { + *b = b'='; } } @@ -722,8 +722,8 @@ impl<S, C> Api<C> for Client<S, C> where // no such boundary is used. let mut boundary = generate_boundary(); for b in boundary.iter_mut() { - if b == &('/' as u8) { - *b = '=' as u8; + if b == &(b'/') { + *b = b'='; } } diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs index 3bf0b01757b..b1c50ab40a6 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -34,6 +34,7 @@ pub enum MultipleIdenticalMimeTypesPostResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -64,6 +65,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs index 5cade05779a..f94163d9106 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs @@ -58,8 +58,9 @@ impl std::str::FromStr for MultipartRelatedRequest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub object_field: Vec<models::MultipartRequestObjectField>, pub optional_binary_field: Vec<swagger::ByteArray>, @@ -79,6 +80,7 @@ impl std::str::FromStr for MultipartRelatedRequest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "object_field" => intermediate_rep.object_field.push(<models::MultipartRequestObjectField as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -193,8 +195,9 @@ impl std::str::FromStr for MultipartRequestObjectField { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub field_a: Vec<String>, pub field_b: Vec<Vec<String>>, @@ -213,6 +216,7 @@ impl std::str::FromStr for MultipartRequestObjectField { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "field_a" => intermediate_rep.field_a.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -320,8 +324,9 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub binary1: Vec<swagger::ByteArray>, pub binary2: Vec<swagger::ByteArray>, @@ -340,6 +345,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "binary1" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()), "binary2" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()), diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs index 5082f49ae1f..c3ab4bd0e64 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs @@ -148,10 +148,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // MultipartRelatedRequestPost - POST /multipart_related_request - &hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => { + hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -165,9 +165,9 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where // Extract the top-level content type header. let content_type_mime = headers .get(CONTENT_TYPE) - .ok_or("Missing content-type header".to_string()) + .ok_or_else(|| "Missing content-type header".to_string()) .and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for MultipartRelatedRequestPost: {}", e))) - .and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for MultipartRelatedRequestPost"))); + .and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for MultipartRelatedRequestPost".to_string())); // Insert top-level content type header into a Headers object. let mut multi_part_headers = Headers::new(); @@ -202,7 +202,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where for node in nodes { if let Node::Part(part) = node { let content_type = part.content_type().map(|x| format!("{}",x)); - match content_type.as_ref().map(|x| x.as_str()) { + match content_type.as_deref() { Some("application/json") if param_object_field.is_none() => { // Extract JSON part. let deserializer = &mut serde_json::Deserializer::from_slice(part.body.as_slice()); @@ -244,7 +244,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where Some(x) => x, None => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Missing required multipart/related parameter required_binary_field"))) + .body(Body::from("Missing required multipart/related parameter required_binary_field".to_string())) .expect("Unable to create Bad Request response for missing multipart/related parameter required_binary_field due to schema")) }; @@ -285,7 +285,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // MultipartRequestPost - POST /multipart_request - &hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => { + hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => { let boundary = match swagger::multipart::form::boundary(&headers) { Some(boundary) => boundary.to_string(), None => return Ok(Response::builder() @@ -310,7 +310,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where _ => { return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Unable to process all message parts"))) + .body(Body::from("Unable to process all message parts".to_string())) .expect("Unable to create Bad Request response due to failure to process all message")) }, }; @@ -336,7 +336,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where return Ok( Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Missing required form parameter string_field"))) + .body(Body::from("Missing required form parameter string_field".to_string())) .expect("Unable to create Bad Request due to missing required form parameter string_field")) } }; @@ -400,7 +400,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where return Ok( Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Missing required form parameter binary_field"))) + .body(Body::from("Missing required form parameter binary_field".to_string())) .expect("Unable to create Bad Request due to missing required form parameter binary_field")) } }; @@ -436,13 +436,13 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, Err(e) => Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't read multipart body"))) + .body(Body::from("Couldn't read multipart body".to_string())) .expect("Unable to create Bad Request response due to unable read multipart body")), } }, // MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types - &hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => { + hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -456,9 +456,9 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where // Extract the top-level content type header. let content_type_mime = headers .get(CONTENT_TYPE) - .ok_or("Missing content-type header".to_string()) + .ok_or_else(|| "Missing content-type header".to_string()) .and_then(|v| v.to_str().map_err(|e| format!("Couldn't read content-type header value for MultipleIdenticalMimeTypesPost: {}", e))) - .and_then(|v| v.parse::<Mime2>().map_err(|_e| format!("Couldn't parse content-type header value for MultipleIdenticalMimeTypesPost"))); + .and_then(|v| v.parse::<Mime2>().map_err(|_e| "Couldn't parse content-type header value for MultipleIdenticalMimeTypesPost".to_string())); // Insert top-level content type header into a Headers object. let mut multi_part_headers = Headers::new(); @@ -492,7 +492,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where for node in nodes { if let Node::Part(part) = node { let content_type = part.content_type().map(|x| format!("{}",x)); - match content_type.as_ref().map(|x| x.as_str()) { + match content_type.as_deref() { Some("application/octet-stream") if param_binary1.is_none() => { param_binary1.get_or_insert(swagger::ByteArray(part.body)); }, @@ -565,13 +565,13 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // MultipartRelatedRequestPost - POST /multipart_related_request - &hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => Some("MultipartRelatedRequestPost"), + hyper::Method::POST if path.matched(paths::ID_MULTIPART_RELATED_REQUEST) => Some("MultipartRelatedRequestPost"), // MultipartRequestPost - POST /multipart_request - &hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => Some("MultipartRequestPost"), + hyper::Method::POST if path.matched(paths::ID_MULTIPART_REQUEST) => Some("MultipartRequestPost"), // MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types - &hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => Some("MultipleIdenticalMimeTypesPost"), + hyper::Method::POST if path.matched(paths::ID_MULTIPLE_IDENTICAL_MIME_TYPES) => Some("MultipleIdenticalMimeTypesPost"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs index 1f85575086f..05aca2b05b4 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -22,6 +22,7 @@ pub enum OpGetResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -36,6 +37,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs index 2c4d68f18d9..cc90dcda97e 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs @@ -49,8 +49,9 @@ impl std::str::FromStr for OpGetRequest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub propery: Vec<String>, } @@ -68,6 +69,7 @@ impl std::str::FromStr for OpGetRequest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs index 5a4f69112c7..6bd3627a916 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs @@ -137,10 +137,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // OpGet - GET /op - &hyper::Method::GET if path.matched(paths::ID_OP) => { + hyper::Method::GET if path.matched(paths::ID_OP) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -225,9 +225,9 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // OpGet - GET /op - &hyper::Method::GET if path.matched(paths::ID_OP) => Some("OpGet"), + hyper::Method::GET if path.matched(paths::ID_OP) => Some("OpGet"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index ec3970b2bcb..3f3d2b0cf82 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -38,12 +38,14 @@ mod paths { pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK: usize = 0; lazy_static! { pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/(?P<request_query_url>.*)/callback$") .expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK"); } pub(crate) static ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: usize = 1; lazy_static! { pub static ref REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/(?P<request_query_url>.*)/callback-with-header$") .expect("Unable to create regex for REQUEST_QUERY_URL_CALLBACK_WITH_HEADER"); } @@ -151,15 +153,15 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header - &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => { + hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK_WITH_HEADER in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER.as_str()) ); @@ -215,12 +217,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CallbackCallbackPost - POST /{$request.query.url}/callback - &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => { + hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_REQUEST_QUERY_URL_CALLBACK - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK.as_str()) ); @@ -268,11 +270,11 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header - &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => Some("CallbackCallbackWithHeaderPost"), + hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => Some("CallbackCallbackWithHeaderPost"), // CallbackCallbackPost - POST /{$request.query.url}/callback - &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => Some("CallbackCallbackPost"), + hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => Some("CallbackCallbackPost"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 76a64ab229b..71a4af71339 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -532,7 +532,7 @@ impl<S, C> Api<C> for Client<S, C> where let query_string = { let mut query_string = form_urlencoded::Serializer::new("".to_owned()); query_string.append_pair("url", - ¶m_url.to_string()); + ¶m_url); query_string.finish() }; if !query_string.is_empty() { @@ -850,6 +850,7 @@ impl<S, C> Api<C> for Client<S, C> where // Header parameters request.headers_mut().append( HeaderName::from_static("x-header"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_x_header.clone()).try_into() { Ok(header) => header, Err(e) => { @@ -1159,8 +1160,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -1481,8 +1484,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -1542,7 +1547,7 @@ impl<S, C> Api<C> for Client<S, C> where let query_string = { let mut query_string = form_urlencoded::Serializer::new("".to_owned()); query_string.append_pair("url", - ¶m_url.to_string()); + ¶m_url); query_string.finish() }; if !query_string.is_empty() { @@ -1728,8 +1733,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header Success-Info for response 200 - {}", e))); }, }; - let response_success_info = response_success_info.0; - response_success_info + response_success_info.0 }, None => return Err(ApiError(String::from("Required response header Success-Info for response 200 was not found."))), }; @@ -1743,8 +1747,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header Bool-Header for response 200 - {}", e))); }, }; - let response_bool_header = response_bool_header.0; - Some(response_bool_header) + Some(response_bool_header.0) }, None => None, }; @@ -1758,8 +1761,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header Object-Header for response 200 - {}", e))); }, }; - let response_object_header = response_object_header.0; - Some(response_object_header) + Some(response_object_header.0) }, None => None, }; @@ -1775,7 +1777,7 @@ impl<S, C> Api<C> for Client<S, C> where })?; Ok(ResponsesWithHeadersGetResponse::Success { - body: body, + body, success_info: response_success_info, bool_header: response_bool_header, object_header: response_object_header, @@ -1792,8 +1794,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header Further-Info for response 412 - {}", e))); }, }; - let response_further_info = response_further_info.0; - Some(response_further_info) + Some(response_further_info.0) }, None => None, }; @@ -1807,8 +1808,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header Failure-Info for response 412 - {}", e))); }, }; - let response_failure_info = response_failure_info.0; - Some(response_failure_info) + Some(response_failure_info.0) }, None => None, }; @@ -2140,7 +2140,7 @@ impl<S, C> Api<C> for Client<S, C> where }; let body = param_duplicate_xml_object.map(|ref body| { - body.to_xml() + body.as_xml() }); if let Some(body) = body { *request.body_mut() = Body::from(body); @@ -2226,7 +2226,7 @@ impl<S, C> Api<C> for Client<S, C> where }; let body = param_another_xml_object.map(|ref body| { - body.to_xml() + body.as_xml() }); if let Some(body) = body { *request.body_mut() = Body::from(body); @@ -2322,7 +2322,7 @@ impl<S, C> Api<C> for Client<S, C> where }; let body = param_another_xml_array.map(|ref body| { - body.to_xml() + body.as_xml() }); if let Some(body) = body { *request.body_mut() = Body::from(body); @@ -2408,7 +2408,7 @@ impl<S, C> Api<C> for Client<S, C> where }; let body = param_xml_array.map(|ref body| { - body.to_xml() + body.as_xml() }); if let Some(body) = body { *request.body_mut() = Body::from(body); @@ -2494,7 +2494,7 @@ impl<S, C> Api<C> for Client<S, C> where }; let body = param_xml_object.map(|ref body| { - body.to_xml() + body.as_xml() }); if let Some(body) = body { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/context.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/context.rs index 6f030053252..ac1c07864b8 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/context.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/context.rs @@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Bearer; use std::ops::Deref; - if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) { + if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) { let auth_data = AuthData::Bearer(bearer); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 86abc5eb0ab..1f5793d8bf1 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -274,6 +274,7 @@ pub enum GetRepoInfoResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -409,6 +410,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; @@ -855,7 +857,7 @@ pub trait CallbackApiNoContext<C: Send + Sync> { pub trait CallbackContextWrapperExt<C: Send + Sync> where Self: Sized { /// Binds this API to a context. - fn with_context(self: Self, context: C) -> ContextWrapper<Self, C>; + fn with_context(self, context: C) -> ContextWrapper<Self, C>; } impl<T: CallbackApi<C> + Send + Sync, C: Clone + Send + Sync> CallbackContextWrapperExt<C> for T { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs index b5e69a14d94..f422536428c 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs @@ -58,7 +58,7 @@ impl AdditionalPropertiesWithList { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -111,7 +111,7 @@ impl<'a> std::iter::IntoIterator for &'a AnotherXmlArray { type IntoIter = std::slice::Iter<'a, String>; fn into_iter(self) -> Self::IntoIter { - (&self.0).into_iter() + (&self.0).iter() } } @@ -120,7 +120,7 @@ impl<'a> std::iter::IntoIterator for &'a mut AnotherXmlArray { type IntoIter = std::slice::IterMut<'a, String>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).into_iter() + (&mut self.0).iter_mut() } } @@ -206,7 +206,7 @@ impl AnotherXmlArray { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -259,7 +259,7 @@ impl AnotherXmlInner { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -311,8 +311,9 @@ impl std::str::FromStr for AnotherXmlObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub inner_string: Vec<String>, } @@ -330,6 +331,7 @@ impl std::str::FromStr for AnotherXmlObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -397,7 +399,7 @@ impl AnotherXmlObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { let mut namespaces = std::collections::BTreeMap::new(); // An empty string is used to indicate a global namespace in xmltree. namespaces.insert("".to_string(), Self::NAMESPACE.to_string()); @@ -437,8 +439,9 @@ impl std::str::FromStr for AnyOfGet202Response { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { } @@ -455,6 +458,7 @@ impl std::str::FromStr for AnyOfGet202Response { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { _ => return std::result::Result::Err("Unexpected key while parsing AnyOfGet202Response".to_string()) } @@ -513,7 +517,7 @@ impl AnyOfGet202Response { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -551,8 +555,9 @@ impl std::str::FromStr for AnyOfObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { } @@ -569,6 +574,7 @@ impl std::str::FromStr for AnyOfObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { _ => return std::result::Result::Err("Unexpected key while parsing AnyOfObject".to_string()) } @@ -627,7 +633,7 @@ impl AnyOfObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -671,7 +677,7 @@ impl AnyOfObjectAnyOf { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -722,8 +728,9 @@ impl std::str::FromStr for AnyOfProperty { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub required_any_of: Vec<models::AnyOfObject>, pub optional_any_of: Vec<models::Model12345AnyOfObject>, @@ -742,6 +749,7 @@ impl std::str::FromStr for AnyOfProperty { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "requiredAnyOf" => intermediate_rep.required_any_of.push(<models::AnyOfObject as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -806,7 +814,7 @@ impl AnyOfProperty { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -865,8 +873,9 @@ impl std::str::FromStr for DuplicateXmlObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub inner_string: Vec<String>, pub inner_array: Vec<models::XmlArray>, @@ -885,6 +894,7 @@ impl std::str::FromStr for DuplicateXmlObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "inner_string" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -955,7 +965,7 @@ impl DuplicateXmlObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { let mut namespaces = std::collections::BTreeMap::new(); // An empty string is used to indicate a global namespace in xmltree. namespaces.insert("".to_string(), Self::NAMESPACE.to_string()); @@ -1007,7 +1017,7 @@ impl EnumWithStarObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1059,7 +1069,7 @@ impl Err { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1111,7 +1121,7 @@ impl Error { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1149,8 +1159,9 @@ impl std::str::FromStr for Model12345AnyOfObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { } @@ -1167,6 +1178,7 @@ impl std::str::FromStr for Model12345AnyOfObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { _ => return std::result::Result::Err("Unexpected key while parsing Model12345AnyOfObject".to_string()) } @@ -1225,7 +1237,7 @@ impl Model12345AnyOfObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1273,7 +1285,7 @@ impl Model12345AnyOfObjectAnyOf { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1323,8 +1335,9 @@ impl std::str::FromStr for MultigetGet201Response { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub foo: Vec<String>, } @@ -1342,6 +1355,7 @@ impl std::str::FromStr for MultigetGet201Response { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1403,7 +1417,7 @@ impl MultigetGet201Response { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1442,7 +1456,7 @@ impl MyId { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1485,7 +1499,7 @@ impl<'a> std::iter::IntoIterator for &'a MyIdList { type IntoIter = std::slice::Iter<'a, i32>; fn into_iter(self) -> Self::IntoIter { - (&self.0).into_iter() + (&self.0).iter() } } @@ -1494,7 +1508,7 @@ impl<'a> std::iter::IntoIterator for &'a mut MyIdList { type IntoIter = std::slice::IterMut<'a, i32>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).into_iter() + (&mut self.0).iter_mut() } } @@ -1580,7 +1594,7 @@ impl MyIdList { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1685,8 +1699,9 @@ impl std::str::FromStr for NullableTest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub nullable: Vec<String>, pub nullable_with_null_default: Vec<String>, @@ -1708,6 +1723,7 @@ impl std::str::FromStr for NullableTest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "nullable" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in NullableTest".to_string()), "nullableWithNullDefault" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in NullableTest".to_string()), @@ -1776,7 +1792,7 @@ impl NullableTest { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1834,8 +1850,9 @@ impl std::str::FromStr for ObjectHeader { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub required_object_header: Vec<bool>, pub optional_object_header: Vec<isize>, @@ -1854,6 +1871,7 @@ impl std::str::FromStr for ObjectHeader { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "requiredObjectHeader" => intermediate_rep.required_object_header.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1918,7 +1936,7 @@ impl ObjectHeader { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1976,8 +1994,9 @@ impl std::str::FromStr for ObjectParam { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub required_param: Vec<bool>, pub optional_param: Vec<isize>, @@ -1996,6 +2015,7 @@ impl std::str::FromStr for ObjectParam { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "requiredParam" => intermediate_rep.required_param.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2060,7 +2080,7 @@ impl ObjectParam { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2123,8 +2143,9 @@ impl std::str::FromStr for ObjectUntypedProps { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub required_untyped: Vec<serde_json::Value>, pub required_untyped_nullable: Vec<serde_json::Value>, @@ -2145,6 +2166,7 @@ impl std::str::FromStr for ObjectUntypedProps { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "required_untyped" => intermediate_rep.required_untyped.push(<serde_json::Value as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2214,7 +2236,7 @@ impl ObjectUntypedProps { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2264,8 +2286,9 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub object_array: Vec<Vec<models::StringObject>>, } @@ -2283,6 +2306,7 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "objectArray" => return std::result::Result::Err("Parsing a container in this style is not supported in ObjectWithArrayOfObjects".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing ObjectWithArrayOfObjects".to_string()) @@ -2343,7 +2367,7 @@ impl ObjectWithArrayOfObjects { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2395,7 +2419,7 @@ impl Ok { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2432,8 +2456,9 @@ impl std::str::FromStr for OneOfGet200Response { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { } @@ -2450,6 +2475,7 @@ impl std::str::FromStr for OneOfGet200Response { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { _ => return std::result::Result::Err("Unexpected key while parsing OneOfGet200Response".to_string()) } @@ -2508,7 +2534,7 @@ impl OneOfGet200Response { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2547,7 +2573,7 @@ impl OptionalObjectHeader { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2586,7 +2612,7 @@ impl RequiredObjectHeader { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2638,7 +2664,7 @@ impl Result { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2682,7 +2708,7 @@ impl StringEnum { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2734,7 +2760,7 @@ impl StringObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2774,7 +2800,7 @@ impl UuidObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2827,7 +2853,7 @@ impl<'a> std::iter::IntoIterator for &'a XmlArray { type IntoIter = std::slice::Iter<'a, String>; fn into_iter(self) -> Self::IntoIter { - (&self.0).into_iter() + (&self.0).iter() } } @@ -2836,7 +2862,7 @@ impl<'a> std::iter::IntoIterator for &'a mut XmlArray { type IntoIter = std::slice::IterMut<'a, String>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).into_iter() + (&mut self.0).iter_mut() } } @@ -2922,7 +2948,7 @@ impl XmlArray { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2975,7 +3001,7 @@ impl XmlInner { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3040,8 +3066,9 @@ impl std::str::FromStr for XmlObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub inner_string: Vec<String>, pub other_inner_rename: Vec<isize>, @@ -3060,6 +3087,7 @@ impl std::str::FromStr for XmlObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "innerString" => intermediate_rep.inner_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3130,7 +3158,7 @@ impl XmlObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { let mut namespaces = std::collections::BTreeMap::new(); // An empty string is used to indicate a global namespace in xmltree. namespaces.insert("".to_string(), Self::NAMESPACE.to_string()); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs index 38dd27fa7ae..0486992669b 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/callbacks.rs @@ -275,6 +275,7 @@ impl<S, C> CallbackApi<C> for Client<S, C> where Some(param_information) => { request.headers_mut().append( HeaderName::from_static("information"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_information.clone()).try_into() { Ok(header) => header, Err(e) => { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index 94dd4f34988..66216f5a2f0 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -90,6 +90,7 @@ mod paths { pub(crate) static ID_ENUM_IN_PATH_PATH_PARAM: usize = 3; lazy_static! { pub static ref REGEX_ENUM_IN_PATH_PATH_PARAM: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/enum_in_path/(?P<path_param>[^/?#]*)$") .expect("Unable to create regex for ENUM_IN_PATH_PATH_PARAM"); } @@ -107,6 +108,7 @@ mod paths { pub(crate) static ID_REPOS_REPOID: usize = 15; lazy_static! { pub static ref REGEX_REPOS_REPOID: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/repos/(?P<repoId>[^/?#]*)$") .expect("Unable to create regex for REPOS_REPOID"); } @@ -220,10 +222,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // AnyOfGet - GET /any-of - &hyper::Method::GET if path.matched(paths::ID_ANY_OF) => { + hyper::Method::GET if path.matched(paths::ID_ANY_OF) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_any_of = query_params.iter().filter(|e| e.0 == "any-of").map(|e| e.1.to_owned()) @@ -293,11 +295,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CallbackWithHeaderPost - POST /callback-with-header - &hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => { + hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_url = match param_url { Some(param_url) => { let param_url = @@ -350,7 +352,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // ComplexQueryParamGet - GET /complex-query-param - &hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => { + hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.to_owned()) @@ -391,12 +393,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // EnumInPathPathParamGet - GET /enum_in_path/{path_param} - &hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => { + hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_ENUM_IN_PATH_PATH_PARAM - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE ENUM_IN_PATH_PATH_PARAM in set but failed match against \"{}\"", path, paths::REGEX_ENUM_IN_PATH_PATH_PARAM.as_str()) ); @@ -444,11 +446,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // JsonComplexQueryParamGet - GET /json-complex-query-param - &hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => { + hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_list_of_strings = query_params.iter().filter(|e| e.0 == "list-of-strings").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_list_of_strings = match param_list_of_strings { Some(param_list_of_strings) => { let param_list_of_strings = @@ -494,7 +496,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // MandatoryRequestHeaderGet - GET /mandatory-request-header - &hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => { + hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => { // Header parameters let param_x_header = headers.get(HeaderName::from_static("x-header")); @@ -547,7 +549,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // MergePatchJsonGet - GET /merge-patch-json - &hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => { + hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => { let result = api_impl.merge_patch_json_get( &context ).await; @@ -583,7 +585,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // MultigetGet - GET /multiget - &hyper::Method::GET if path.matched(paths::ID_MULTIGET) => { + hyper::Method::GET if path.matched(paths::ID_MULTIGET) => { let result = api_impl.multiget_get( &context ).await; @@ -685,11 +687,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // MultipleAuthSchemeGet - GET /multiple_auth_scheme - &hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => { + hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -744,7 +746,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // OneOfGet - GET /one-of - &hyper::Method::GET if path.matched(paths::ID_ONE_OF) => { + hyper::Method::GET if path.matched(paths::ID_ONE_OF) => { let result = api_impl.one_of_get( &context ).await; @@ -780,7 +782,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // OverrideServerGet - GET /override-server - &hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => { + hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => { let result = api_impl.override_server_get( &context ).await; @@ -809,11 +811,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // ParamgetGet - GET /paramget - &hyper::Method::GET if path.matched(paths::ID_PARAMGET) => { + hyper::Method::GET if path.matched(paths::ID_PARAMGET) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_uuid = query_params.iter().filter(|e| e.0 == "uuid").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_uuid = match param_uuid { Some(param_uuid) => { let param_uuid = @@ -830,7 +832,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where None => None, }; let param_some_object = query_params.iter().filter(|e| e.0 == "someObject").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_some_object = match param_some_object { Some(param_some_object) => { let param_some_object = @@ -847,7 +849,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where None => None, }; let param_some_list = query_params.iter().filter(|e| e.0 == "someList").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_some_list = match param_some_list { Some(param_some_list) => { let param_some_list = @@ -902,11 +904,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // ReadonlyAuthSchemeGet - GET /readonly_auth_scheme - &hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => { + hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -960,11 +962,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // RegisterCallbackPost - POST /register-callback - &hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => { + hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_url = query_params.iter().filter(|e| e.0 == "url").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_url = match param_url { Some(param_url) => { let param_url = @@ -1017,7 +1019,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // RequiredOctetStreamPut - PUT /required_octet_stream - &hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => { + hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1072,7 +1074,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // ResponsesWithHeadersGet - GET /responses_with_headers - &hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => { + hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => { let result = api_impl.responses_with_headers_get( &context ).await; @@ -1199,7 +1201,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Rfc7807Get - GET /rfc7807 - &hyper::Method::GET if path.matched(paths::ID_RFC7807) => { + hyper::Method::GET if path.matched(paths::ID_RFC7807) => { let result = api_impl.rfc7807_get( &context ).await; @@ -1257,7 +1259,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UntypedPropertyGet - GET /untyped_property - &hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => { + hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1320,7 +1322,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UuidGet - GET /uuid - &hyper::Method::GET if path.matched(paths::ID_UUID) => { + hyper::Method::GET if path.matched(paths::ID_UUID) => { let result = api_impl.uuid_get( &context ).await; @@ -1356,7 +1358,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // XmlExtraPost - POST /xml_extra - &hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => { + hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1423,7 +1425,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // XmlOtherPost - POST /xml_other - &hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => { + hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1501,7 +1503,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // XmlOtherPut - PUT /xml_other - &hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => { + hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1568,7 +1570,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // XmlPost - POST /xml - &hyper::Method::POST if path.matched(paths::ID_XML) => { + hyper::Method::POST if path.matched(paths::ID_XML) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1635,7 +1637,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // XmlPut - PUT /xml - &hyper::Method::PUT if path.matched(paths::ID_XML) => { + hyper::Method::PUT if path.matched(paths::ID_XML) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1702,7 +1704,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CreateRepo - POST /repos - &hyper::Method::POST if path.matched(paths::ID_REPOS) => { + hyper::Method::POST if path.matched(paths::ID_REPOS) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1775,12 +1777,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetRepoInfo - GET /repos/{repoId} - &hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => { + hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_REPOS_REPOID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE REPOS_REPOID in set but failed match against \"{}\"", path, paths::REGEX_REPOS_REPOID.as_str()) ); @@ -1870,59 +1872,59 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // AnyOfGet - GET /any-of - &hyper::Method::GET if path.matched(paths::ID_ANY_OF) => Some("AnyOfGet"), + hyper::Method::GET if path.matched(paths::ID_ANY_OF) => Some("AnyOfGet"), // CallbackWithHeaderPost - POST /callback-with-header - &hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => Some("CallbackWithHeaderPost"), + hyper::Method::POST if path.matched(paths::ID_CALLBACK_WITH_HEADER) => Some("CallbackWithHeaderPost"), // ComplexQueryParamGet - GET /complex-query-param - &hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => Some("ComplexQueryParamGet"), + hyper::Method::GET if path.matched(paths::ID_COMPLEX_QUERY_PARAM) => Some("ComplexQueryParamGet"), // EnumInPathPathParamGet - GET /enum_in_path/{path_param} - &hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"), + hyper::Method::GET if path.matched(paths::ID_ENUM_IN_PATH_PATH_PARAM) => Some("EnumInPathPathParamGet"), // JsonComplexQueryParamGet - GET /json-complex-query-param - &hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => Some("JsonComplexQueryParamGet"), + hyper::Method::GET if path.matched(paths::ID_JSON_COMPLEX_QUERY_PARAM) => Some("JsonComplexQueryParamGet"), // MandatoryRequestHeaderGet - GET /mandatory-request-header - &hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => Some("MandatoryRequestHeaderGet"), + hyper::Method::GET if path.matched(paths::ID_MANDATORY_REQUEST_HEADER) => Some("MandatoryRequestHeaderGet"), // MergePatchJsonGet - GET /merge-patch-json - &hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => Some("MergePatchJsonGet"), + hyper::Method::GET if path.matched(paths::ID_MERGE_PATCH_JSON) => Some("MergePatchJsonGet"), // MultigetGet - GET /multiget - &hyper::Method::GET if path.matched(paths::ID_MULTIGET) => Some("MultigetGet"), + hyper::Method::GET if path.matched(paths::ID_MULTIGET) => Some("MultigetGet"), // MultipleAuthSchemeGet - GET /multiple_auth_scheme - &hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Some("MultipleAuthSchemeGet"), + hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Some("MultipleAuthSchemeGet"), // OneOfGet - GET /one-of - &hyper::Method::GET if path.matched(paths::ID_ONE_OF) => Some("OneOfGet"), + hyper::Method::GET if path.matched(paths::ID_ONE_OF) => Some("OneOfGet"), // OverrideServerGet - GET /override-server - &hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => Some("OverrideServerGet"), + hyper::Method::GET if path.matched(paths::ID_OVERRIDE_SERVER) => Some("OverrideServerGet"), // ParamgetGet - GET /paramget - &hyper::Method::GET if path.matched(paths::ID_PARAMGET) => Some("ParamgetGet"), + hyper::Method::GET if path.matched(paths::ID_PARAMGET) => Some("ParamgetGet"), // ReadonlyAuthSchemeGet - GET /readonly_auth_scheme - &hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Some("ReadonlyAuthSchemeGet"), + hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Some("ReadonlyAuthSchemeGet"), // RegisterCallbackPost - POST /register-callback - &hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => Some("RegisterCallbackPost"), + hyper::Method::POST if path.matched(paths::ID_REGISTER_CALLBACK) => Some("RegisterCallbackPost"), // RequiredOctetStreamPut - PUT /required_octet_stream - &hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Some("RequiredOctetStreamPut"), + hyper::Method::PUT if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Some("RequiredOctetStreamPut"), // ResponsesWithHeadersGet - GET /responses_with_headers - &hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => Some("ResponsesWithHeadersGet"), + hyper::Method::GET if path.matched(paths::ID_RESPONSES_WITH_HEADERS) => Some("ResponsesWithHeadersGet"), // Rfc7807Get - GET /rfc7807 - &hyper::Method::GET if path.matched(paths::ID_RFC7807) => Some("Rfc7807Get"), + hyper::Method::GET if path.matched(paths::ID_RFC7807) => Some("Rfc7807Get"), // UntypedPropertyGet - GET /untyped_property - &hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => Some("UntypedPropertyGet"), + hyper::Method::GET if path.matched(paths::ID_UNTYPED_PROPERTY) => Some("UntypedPropertyGet"), // UuidGet - GET /uuid - &hyper::Method::GET if path.matched(paths::ID_UUID) => Some("UuidGet"), + hyper::Method::GET if path.matched(paths::ID_UUID) => Some("UuidGet"), // XmlExtraPost - POST /xml_extra - &hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => Some("XmlExtraPost"), + hyper::Method::POST if path.matched(paths::ID_XML_EXTRA) => Some("XmlExtraPost"), // XmlOtherPost - POST /xml_other - &hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPost"), + hyper::Method::POST if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPost"), // XmlOtherPut - PUT /xml_other - &hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPut"), + hyper::Method::PUT if path.matched(paths::ID_XML_OTHER) => Some("XmlOtherPut"), // XmlPost - POST /xml - &hyper::Method::POST if path.matched(paths::ID_XML) => Some("XmlPost"), + hyper::Method::POST if path.matched(paths::ID_XML) => Some("XmlPost"), // XmlPut - PUT /xml - &hyper::Method::PUT if path.matched(paths::ID_XML) => Some("XmlPut"), + hyper::Method::PUT if path.matched(paths::ID_XML) => Some("XmlPut"), // CreateRepo - POST /repos - &hyper::Method::POST if path.matched(paths::ID_REPOS) => Some("CreateRepo"), + hyper::Method::POST if path.matched(paths::ID_REPOS) => Some("CreateRepo"), // GetRepoInfo - GET /repos/{repoId} - &hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => Some("GetRepoInfo"), + hyper::Method::GET if path.matched(paths::ID_REPOS_REPOID) => Some("GetRepoInfo"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs index 676ef8a5a75..4cc7e28f739 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -238,6 +238,7 @@ pub enum Op9GetResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -395,6 +396,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index 1e020af6477..e27cc1ed58c 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -245,10 +245,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // Op10Get - GET /op10 - &hyper::Method::GET if path.matched(paths::ID_OP10) => { + hyper::Method::GET if path.matched(paths::ID_OP10) => { let result = api_impl.op10_get( &context ).await; @@ -277,7 +277,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op11Get - GET /op11 - &hyper::Method::GET if path.matched(paths::ID_OP11) => { + hyper::Method::GET if path.matched(paths::ID_OP11) => { let result = api_impl.op11_get( &context ).await; @@ -306,7 +306,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op12Get - GET /op12 - &hyper::Method::GET if path.matched(paths::ID_OP12) => { + hyper::Method::GET if path.matched(paths::ID_OP12) => { let result = api_impl.op12_get( &context ).await; @@ -335,7 +335,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op13Get - GET /op13 - &hyper::Method::GET if path.matched(paths::ID_OP13) => { + hyper::Method::GET if path.matched(paths::ID_OP13) => { let result = api_impl.op13_get( &context ).await; @@ -364,7 +364,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op14Get - GET /op14 - &hyper::Method::GET if path.matched(paths::ID_OP14) => { + hyper::Method::GET if path.matched(paths::ID_OP14) => { let result = api_impl.op14_get( &context ).await; @@ -393,7 +393,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op15Get - GET /op15 - &hyper::Method::GET if path.matched(paths::ID_OP15) => { + hyper::Method::GET if path.matched(paths::ID_OP15) => { let result = api_impl.op15_get( &context ).await; @@ -422,7 +422,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op16Get - GET /op16 - &hyper::Method::GET if path.matched(paths::ID_OP16) => { + hyper::Method::GET if path.matched(paths::ID_OP16) => { let result = api_impl.op16_get( &context ).await; @@ -451,7 +451,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op17Get - GET /op17 - &hyper::Method::GET if path.matched(paths::ID_OP17) => { + hyper::Method::GET if path.matched(paths::ID_OP17) => { let result = api_impl.op17_get( &context ).await; @@ -480,7 +480,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op18Get - GET /op18 - &hyper::Method::GET if path.matched(paths::ID_OP18) => { + hyper::Method::GET if path.matched(paths::ID_OP18) => { let result = api_impl.op18_get( &context ).await; @@ -509,7 +509,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op19Get - GET /op19 - &hyper::Method::GET if path.matched(paths::ID_OP19) => { + hyper::Method::GET if path.matched(paths::ID_OP19) => { let result = api_impl.op19_get( &context ).await; @@ -538,7 +538,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op1Get - GET /op1 - &hyper::Method::GET if path.matched(paths::ID_OP1) => { + hyper::Method::GET if path.matched(paths::ID_OP1) => { let result = api_impl.op1_get( &context ).await; @@ -567,7 +567,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op20Get - GET /op20 - &hyper::Method::GET if path.matched(paths::ID_OP20) => { + hyper::Method::GET if path.matched(paths::ID_OP20) => { let result = api_impl.op20_get( &context ).await; @@ -596,7 +596,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op21Get - GET /op21 - &hyper::Method::GET if path.matched(paths::ID_OP21) => { + hyper::Method::GET if path.matched(paths::ID_OP21) => { let result = api_impl.op21_get( &context ).await; @@ -625,7 +625,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op22Get - GET /op22 - &hyper::Method::GET if path.matched(paths::ID_OP22) => { + hyper::Method::GET if path.matched(paths::ID_OP22) => { let result = api_impl.op22_get( &context ).await; @@ -654,7 +654,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op23Get - GET /op23 - &hyper::Method::GET if path.matched(paths::ID_OP23) => { + hyper::Method::GET if path.matched(paths::ID_OP23) => { let result = api_impl.op23_get( &context ).await; @@ -683,7 +683,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op24Get - GET /op24 - &hyper::Method::GET if path.matched(paths::ID_OP24) => { + hyper::Method::GET if path.matched(paths::ID_OP24) => { let result = api_impl.op24_get( &context ).await; @@ -712,7 +712,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op25Get - GET /op25 - &hyper::Method::GET if path.matched(paths::ID_OP25) => { + hyper::Method::GET if path.matched(paths::ID_OP25) => { let result = api_impl.op25_get( &context ).await; @@ -741,7 +741,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op26Get - GET /op26 - &hyper::Method::GET if path.matched(paths::ID_OP26) => { + hyper::Method::GET if path.matched(paths::ID_OP26) => { let result = api_impl.op26_get( &context ).await; @@ -770,7 +770,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op27Get - GET /op27 - &hyper::Method::GET if path.matched(paths::ID_OP27) => { + hyper::Method::GET if path.matched(paths::ID_OP27) => { let result = api_impl.op27_get( &context ).await; @@ -799,7 +799,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op28Get - GET /op28 - &hyper::Method::GET if path.matched(paths::ID_OP28) => { + hyper::Method::GET if path.matched(paths::ID_OP28) => { let result = api_impl.op28_get( &context ).await; @@ -828,7 +828,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op29Get - GET /op29 - &hyper::Method::GET if path.matched(paths::ID_OP29) => { + hyper::Method::GET if path.matched(paths::ID_OP29) => { let result = api_impl.op29_get( &context ).await; @@ -857,7 +857,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op2Get - GET /op2 - &hyper::Method::GET if path.matched(paths::ID_OP2) => { + hyper::Method::GET if path.matched(paths::ID_OP2) => { let result = api_impl.op2_get( &context ).await; @@ -886,7 +886,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op30Get - GET /op30 - &hyper::Method::GET if path.matched(paths::ID_OP30) => { + hyper::Method::GET if path.matched(paths::ID_OP30) => { let result = api_impl.op30_get( &context ).await; @@ -915,7 +915,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op31Get - GET /op31 - &hyper::Method::GET if path.matched(paths::ID_OP31) => { + hyper::Method::GET if path.matched(paths::ID_OP31) => { let result = api_impl.op31_get( &context ).await; @@ -944,7 +944,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op32Get - GET /op32 - &hyper::Method::GET if path.matched(paths::ID_OP32) => { + hyper::Method::GET if path.matched(paths::ID_OP32) => { let result = api_impl.op32_get( &context ).await; @@ -973,7 +973,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op33Get - GET /op33 - &hyper::Method::GET if path.matched(paths::ID_OP33) => { + hyper::Method::GET if path.matched(paths::ID_OP33) => { let result = api_impl.op33_get( &context ).await; @@ -1002,7 +1002,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op34Get - GET /op34 - &hyper::Method::GET if path.matched(paths::ID_OP34) => { + hyper::Method::GET if path.matched(paths::ID_OP34) => { let result = api_impl.op34_get( &context ).await; @@ -1031,7 +1031,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op35Get - GET /op35 - &hyper::Method::GET if path.matched(paths::ID_OP35) => { + hyper::Method::GET if path.matched(paths::ID_OP35) => { let result = api_impl.op35_get( &context ).await; @@ -1060,7 +1060,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op36Get - GET /op36 - &hyper::Method::GET if path.matched(paths::ID_OP36) => { + hyper::Method::GET if path.matched(paths::ID_OP36) => { let result = api_impl.op36_get( &context ).await; @@ -1089,7 +1089,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op37Get - GET /op37 - &hyper::Method::GET if path.matched(paths::ID_OP37) => { + hyper::Method::GET if path.matched(paths::ID_OP37) => { let result = api_impl.op37_get( &context ).await; @@ -1118,7 +1118,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op3Get - GET /op3 - &hyper::Method::GET if path.matched(paths::ID_OP3) => { + hyper::Method::GET if path.matched(paths::ID_OP3) => { let result = api_impl.op3_get( &context ).await; @@ -1147,7 +1147,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op4Get - GET /op4 - &hyper::Method::GET if path.matched(paths::ID_OP4) => { + hyper::Method::GET if path.matched(paths::ID_OP4) => { let result = api_impl.op4_get( &context ).await; @@ -1176,7 +1176,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op5Get - GET /op5 - &hyper::Method::GET if path.matched(paths::ID_OP5) => { + hyper::Method::GET if path.matched(paths::ID_OP5) => { let result = api_impl.op5_get( &context ).await; @@ -1205,7 +1205,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op6Get - GET /op6 - &hyper::Method::GET if path.matched(paths::ID_OP6) => { + hyper::Method::GET if path.matched(paths::ID_OP6) => { let result = api_impl.op6_get( &context ).await; @@ -1234,7 +1234,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op7Get - GET /op7 - &hyper::Method::GET if path.matched(paths::ID_OP7) => { + hyper::Method::GET if path.matched(paths::ID_OP7) => { let result = api_impl.op7_get( &context ).await; @@ -1263,7 +1263,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op8Get - GET /op8 - &hyper::Method::GET if path.matched(paths::ID_OP8) => { + hyper::Method::GET if path.matched(paths::ID_OP8) => { let result = api_impl.op8_get( &context ).await; @@ -1292,7 +1292,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Op9Get - GET /op9 - &hyper::Method::GET if path.matched(paths::ID_OP9) => { + hyper::Method::GET if path.matched(paths::ID_OP9) => { let result = api_impl.op9_get( &context ).await; @@ -1369,81 +1369,81 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // Op10Get - GET /op10 - &hyper::Method::GET if path.matched(paths::ID_OP10) => Some("Op10Get"), + hyper::Method::GET if path.matched(paths::ID_OP10) => Some("Op10Get"), // Op11Get - GET /op11 - &hyper::Method::GET if path.matched(paths::ID_OP11) => Some("Op11Get"), + hyper::Method::GET if path.matched(paths::ID_OP11) => Some("Op11Get"), // Op12Get - GET /op12 - &hyper::Method::GET if path.matched(paths::ID_OP12) => Some("Op12Get"), + hyper::Method::GET if path.matched(paths::ID_OP12) => Some("Op12Get"), // Op13Get - GET /op13 - &hyper::Method::GET if path.matched(paths::ID_OP13) => Some("Op13Get"), + hyper::Method::GET if path.matched(paths::ID_OP13) => Some("Op13Get"), // Op14Get - GET /op14 - &hyper::Method::GET if path.matched(paths::ID_OP14) => Some("Op14Get"), + hyper::Method::GET if path.matched(paths::ID_OP14) => Some("Op14Get"), // Op15Get - GET /op15 - &hyper::Method::GET if path.matched(paths::ID_OP15) => Some("Op15Get"), + hyper::Method::GET if path.matched(paths::ID_OP15) => Some("Op15Get"), // Op16Get - GET /op16 - &hyper::Method::GET if path.matched(paths::ID_OP16) => Some("Op16Get"), + hyper::Method::GET if path.matched(paths::ID_OP16) => Some("Op16Get"), // Op17Get - GET /op17 - &hyper::Method::GET if path.matched(paths::ID_OP17) => Some("Op17Get"), + hyper::Method::GET if path.matched(paths::ID_OP17) => Some("Op17Get"), // Op18Get - GET /op18 - &hyper::Method::GET if path.matched(paths::ID_OP18) => Some("Op18Get"), + hyper::Method::GET if path.matched(paths::ID_OP18) => Some("Op18Get"), // Op19Get - GET /op19 - &hyper::Method::GET if path.matched(paths::ID_OP19) => Some("Op19Get"), + hyper::Method::GET if path.matched(paths::ID_OP19) => Some("Op19Get"), // Op1Get - GET /op1 - &hyper::Method::GET if path.matched(paths::ID_OP1) => Some("Op1Get"), + hyper::Method::GET if path.matched(paths::ID_OP1) => Some("Op1Get"), // Op20Get - GET /op20 - &hyper::Method::GET if path.matched(paths::ID_OP20) => Some("Op20Get"), + hyper::Method::GET if path.matched(paths::ID_OP20) => Some("Op20Get"), // Op21Get - GET /op21 - &hyper::Method::GET if path.matched(paths::ID_OP21) => Some("Op21Get"), + hyper::Method::GET if path.matched(paths::ID_OP21) => Some("Op21Get"), // Op22Get - GET /op22 - &hyper::Method::GET if path.matched(paths::ID_OP22) => Some("Op22Get"), + hyper::Method::GET if path.matched(paths::ID_OP22) => Some("Op22Get"), // Op23Get - GET /op23 - &hyper::Method::GET if path.matched(paths::ID_OP23) => Some("Op23Get"), + hyper::Method::GET if path.matched(paths::ID_OP23) => Some("Op23Get"), // Op24Get - GET /op24 - &hyper::Method::GET if path.matched(paths::ID_OP24) => Some("Op24Get"), + hyper::Method::GET if path.matched(paths::ID_OP24) => Some("Op24Get"), // Op25Get - GET /op25 - &hyper::Method::GET if path.matched(paths::ID_OP25) => Some("Op25Get"), + hyper::Method::GET if path.matched(paths::ID_OP25) => Some("Op25Get"), // Op26Get - GET /op26 - &hyper::Method::GET if path.matched(paths::ID_OP26) => Some("Op26Get"), + hyper::Method::GET if path.matched(paths::ID_OP26) => Some("Op26Get"), // Op27Get - GET /op27 - &hyper::Method::GET if path.matched(paths::ID_OP27) => Some("Op27Get"), + hyper::Method::GET if path.matched(paths::ID_OP27) => Some("Op27Get"), // Op28Get - GET /op28 - &hyper::Method::GET if path.matched(paths::ID_OP28) => Some("Op28Get"), + hyper::Method::GET if path.matched(paths::ID_OP28) => Some("Op28Get"), // Op29Get - GET /op29 - &hyper::Method::GET if path.matched(paths::ID_OP29) => Some("Op29Get"), + hyper::Method::GET if path.matched(paths::ID_OP29) => Some("Op29Get"), // Op2Get - GET /op2 - &hyper::Method::GET if path.matched(paths::ID_OP2) => Some("Op2Get"), + hyper::Method::GET if path.matched(paths::ID_OP2) => Some("Op2Get"), // Op30Get - GET /op30 - &hyper::Method::GET if path.matched(paths::ID_OP30) => Some("Op30Get"), + hyper::Method::GET if path.matched(paths::ID_OP30) => Some("Op30Get"), // Op31Get - GET /op31 - &hyper::Method::GET if path.matched(paths::ID_OP31) => Some("Op31Get"), + hyper::Method::GET if path.matched(paths::ID_OP31) => Some("Op31Get"), // Op32Get - GET /op32 - &hyper::Method::GET if path.matched(paths::ID_OP32) => Some("Op32Get"), + hyper::Method::GET if path.matched(paths::ID_OP32) => Some("Op32Get"), // Op33Get - GET /op33 - &hyper::Method::GET if path.matched(paths::ID_OP33) => Some("Op33Get"), + hyper::Method::GET if path.matched(paths::ID_OP33) => Some("Op33Get"), // Op34Get - GET /op34 - &hyper::Method::GET if path.matched(paths::ID_OP34) => Some("Op34Get"), + hyper::Method::GET if path.matched(paths::ID_OP34) => Some("Op34Get"), // Op35Get - GET /op35 - &hyper::Method::GET if path.matched(paths::ID_OP35) => Some("Op35Get"), + hyper::Method::GET if path.matched(paths::ID_OP35) => Some("Op35Get"), // Op36Get - GET /op36 - &hyper::Method::GET if path.matched(paths::ID_OP36) => Some("Op36Get"), + hyper::Method::GET if path.matched(paths::ID_OP36) => Some("Op36Get"), // Op37Get - GET /op37 - &hyper::Method::GET if path.matched(paths::ID_OP37) => Some("Op37Get"), + hyper::Method::GET if path.matched(paths::ID_OP37) => Some("Op37Get"), // Op3Get - GET /op3 - &hyper::Method::GET if path.matched(paths::ID_OP3) => Some("Op3Get"), + hyper::Method::GET if path.matched(paths::ID_OP3) => Some("Op3Get"), // Op4Get - GET /op4 - &hyper::Method::GET if path.matched(paths::ID_OP4) => Some("Op4Get"), + hyper::Method::GET if path.matched(paths::ID_OP4) => Some("Op4Get"), // Op5Get - GET /op5 - &hyper::Method::GET if path.matched(paths::ID_OP5) => Some("Op5Get"), + hyper::Method::GET if path.matched(paths::ID_OP5) => Some("Op5Get"), // Op6Get - GET /op6 - &hyper::Method::GET if path.matched(paths::ID_OP6) => Some("Op6Get"), + hyper::Method::GET if path.matched(paths::ID_OP6) => Some("Op6Get"), // Op7Get - GET /op7 - &hyper::Method::GET if path.matched(paths::ID_OP7) => Some("Op7Get"), + hyper::Method::GET if path.matched(paths::ID_OP7) => Some("Op7Get"), // Op8Get - GET /op8 - &hyper::Method::GET if path.matched(paths::ID_OP8) => Some("Op8Get"), + hyper::Method::GET if path.matched(paths::ID_OP8) => Some("Op8Get"), // Op9Get - GET /op9 - &hyper::Method::GET if path.matched(paths::ID_OP9) => Some("Op9Get"), + hyper::Method::GET if path.matched(paths::ID_OP9) => Some("Op9Get"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs index a4b4158b4ff..0ea239e35c8 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs @@ -1088,7 +1088,7 @@ impl<S, C> Api<C> for Client<S, C> where let query_string = { let mut query_string = form_urlencoded::Serializer::new("".to_owned()); query_string.append_pair("query", - ¶m_query.to_string()); + ¶m_query); query_string.finish() }; if !query_string.is_empty() { @@ -1315,8 +1315,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Basic(ref basic_header) => { let auth = swagger::auth::Header(basic_header.clone()); @@ -1392,7 +1394,7 @@ impl<S, C> Api<C> for Client<S, C> where } if let Some(param_enum_query_string) = param_enum_query_string { query_string.append_pair("enum_query_string", - ¶m_enum_query_string.to_string()); + ¶m_enum_query_string); } if let Some(param_enum_query_integer) = param_enum_query_integer { query_string.append_pair("enum_query_integer", @@ -1444,6 +1446,7 @@ impl<S, C> Api<C> for Client<S, C> where Some(param_enum_header_string_array) => { request.headers_mut().append( HeaderName::from_static("enum_header_string_array"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_enum_header_string_array.clone()).try_into() { Ok(header) => header, Err(e) => { @@ -1459,6 +1462,7 @@ impl<S, C> Api<C> for Client<S, C> where Some(param_enum_header_string) => { request.headers_mut().append( HeaderName::from_static("enum_header_string"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_enum_header_string.clone()).try_into() { Ok(header) => header, Err(e) => { @@ -1677,10 +1681,8 @@ impl<S, C> Api<C> for Client<S, C> where // Query parameters let query_string = { let mut query_string = form_urlencoded::Serializer::new("".to_owned()); - if let Some(auth_data) = (context as &dyn Has<Option<AuthData>>).get().as_ref() { - if let AuthData::ApiKey(ref api_key) = *auth_data { - query_string.append_pair("api_key_query", api_key); - } + if let Some(AuthData::ApiKey(ref api_key)) = (context as &dyn Has<Option<AuthData>>).get().as_ref() { + query_string.append_pair("api_key_query", api_key); } query_string.finish() }; @@ -1719,8 +1721,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { _ => {} } @@ -1799,7 +1803,7 @@ impl<S, C> Api<C> for Client<S, C> where }; // Body parameter - let body = param_body.to_xml(); + let body = param_body.as_xml(); *request.body_mut() = Body::from(body); let header = "application/json"; @@ -1813,8 +1817,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -1901,8 +1907,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -1923,6 +1931,7 @@ impl<S, C> Api<C> for Client<S, C> where Some(param_api_key) => { request.headers_mut().append( HeaderName::from_static("api_key"), + #[allow(clippy::redundant_clone)] match header::IntoHeaderValue(param_api_key.clone()).try_into() { Ok(header) => header, Err(e) => { @@ -2005,8 +2014,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -2108,8 +2119,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -2210,8 +2223,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { _ => {} } @@ -2300,7 +2315,7 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create request: {}", e))) }; - let body = param_body.to_xml(); + let body = param_body.as_xml(); *request.body_mut() = Body::from(body); let header = "application/json"; @@ -2314,8 +2329,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -2425,8 +2442,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -2569,8 +2588,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); @@ -2738,8 +2759,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { _ => {} } @@ -3380,9 +3403,9 @@ impl<S, C> Api<C> for Client<S, C> where let query_string = { let mut query_string = form_urlencoded::Serializer::new("".to_owned()); query_string.append_pair("username", - ¶m_username.to_string()); + ¶m_username); query_string.append_pair("password", - ¶m_password.to_string()); + ¶m_password); query_string.finish() }; if !query_string.is_empty() { @@ -3423,8 +3446,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header X-Rate-Limit for response 200 - {}", e))); }, }; - let response_x_rate_limit = response_x_rate_limit.0; - Some(response_x_rate_limit) + Some(response_x_rate_limit.0) }, None => None, }; @@ -3438,8 +3460,7 @@ impl<S, C> Api<C> for Client<S, C> where return Err(ApiError(format!("Invalid response header X-Expires-After for response 200 - {}", e))); }, }; - let response_x_expires_after = response_x_expires_after.0; - Some(response_x_expires_after) + Some(response_x_expires_after.0) }, None => None, }; @@ -3456,7 +3477,7 @@ impl<S, C> Api<C> for Client<S, C> where .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?; Ok(LoginUserResponse::SuccessfulOperation { - body: body, + body, x_rate_limit: response_x_rate_limit, x_expires_after: response_x_expires_after, } diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/context.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/context.rs index d9b71134176..dc28f08c1cf 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/context.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/context.rs @@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::api_key_from_header; - if let Some(header) = api_key_from_header(&headers, "api_key") { + if let Some(header) = api_key_from_header(headers, "api_key") { let auth_data = AuthData::ApiKey(header); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -119,7 +119,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C let key = form_urlencoded::parse(request.uri().query().unwrap_or_default().as_bytes()) .filter(|e| e.0 == "api_key_query") .map(|e| e.1.clone().into_owned()) - .nth(0); + .next(); if let Some(key) = key { let auth_data = AuthData::ApiKey(key); let context = context.push(Some(auth_data)); @@ -131,7 +131,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Basic; use std::ops::Deref; - if let Some(basic) = swagger::auth::from_headers::<Basic>(&headers) { + if let Some(basic) = swagger::auth::from_headers::<Basic>(headers) { let auth_data = AuthData::Basic(basic); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); @@ -142,7 +142,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Bearer; use std::ops::Deref; - if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) { + if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) { let auth_data = AuthData::Bearer(bearer); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index e0776dbcea5..18a5ecab024 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -317,6 +317,7 @@ pub enum UpdateUserResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -552,6 +553,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 1bd3c22d2b3..cab73c967ba 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -51,8 +51,9 @@ impl std::str::FromStr for AdditionalPropertiesClass { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub map_property: Vec<std::collections::HashMap<String, String>>, pub map_of_map_property: Vec<std::collections::HashMap<String, std::collections::HashMap<String, String>>>, @@ -71,6 +72,7 @@ impl std::str::FromStr for AdditionalPropertiesClass { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "map_property" => return std::result::Result::Err("Parsing a container in this style is not supported in AdditionalPropertiesClass".to_string()), "map_of_map_property" => return std::result::Result::Err("Parsing a container in this style is not supported in AdditionalPropertiesClass".to_string()), @@ -133,7 +135,7 @@ impl AdditionalPropertiesClass { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -191,8 +193,9 @@ impl std::str::FromStr for Animal { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub class_name: Vec<String>, pub color: Vec<String>, @@ -211,6 +214,7 @@ impl std::str::FromStr for Animal { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -275,7 +279,7 @@ impl Animal { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -318,7 +322,7 @@ impl<'a> std::iter::IntoIterator for &'a AnimalFarm { type IntoIter = std::slice::Iter<'a, Animal>; fn into_iter(self) -> Self::IntoIter { - (&self.0).into_iter() + (&self.0).iter() } } @@ -327,7 +331,7 @@ impl<'a> std::iter::IntoIterator for &'a mut AnimalFarm { type IntoIter = std::slice::IterMut<'a, Animal>; fn into_iter(self) -> Self::IntoIter { - (&mut self.0).into_iter() + (&mut self.0).iter_mut() } } @@ -413,7 +417,7 @@ impl AnimalFarm { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -489,8 +493,9 @@ impl std::str::FromStr for ApiResponse { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub code: Vec<i32>, pub r#type: Vec<String>, @@ -510,6 +515,7 @@ impl std::str::FromStr for ApiResponse { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "code" => intermediate_rep.code.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -577,7 +583,7 @@ impl ApiResponse { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -621,8 +627,9 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub array_array_number: Vec<Vec<Vec<f64>>>, } @@ -640,6 +647,7 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "ArrayArrayNumber" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayOfArrayOfNumberOnly".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing ArrayOfArrayOfNumberOnly".to_string()) @@ -700,7 +708,7 @@ impl ArrayOfArrayOfNumberOnly { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -750,8 +758,9 @@ impl std::str::FromStr for ArrayOfNumberOnly { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub array_number: Vec<Vec<f64>>, } @@ -769,6 +778,7 @@ impl std::str::FromStr for ArrayOfNumberOnly { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "ArrayNumber" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayOfNumberOnly".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing ArrayOfNumberOnly".to_string()) @@ -829,7 +839,7 @@ impl ArrayOfNumberOnly { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -907,8 +917,9 @@ impl std::str::FromStr for ArrayTest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub array_of_string: Vec<Vec<String>>, pub array_array_of_integer: Vec<Vec<Vec<i64>>>, @@ -929,6 +940,7 @@ impl std::str::FromStr for ArrayTest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "array_of_string" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayTest".to_string()), "array_array_of_integer" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayTest".to_string()), @@ -995,7 +1007,7 @@ impl ArrayTest { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1111,8 +1123,9 @@ impl std::str::FromStr for Capitalization { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub small_camel: Vec<String>, pub capital_camel: Vec<String>, @@ -1135,6 +1148,7 @@ impl std::str::FromStr for Capitalization { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "smallCamel" => intermediate_rep.small_camel.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1211,7 +1225,7 @@ impl Capitalization { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1282,8 +1296,9 @@ impl std::str::FromStr for Cat { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub class_name: Vec<String>, pub color: Vec<String>, @@ -1303,6 +1318,7 @@ impl std::str::FromStr for Cat { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1370,7 +1386,7 @@ impl Cat { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1420,8 +1436,9 @@ impl std::str::FromStr for CatAllOf { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub declawed: Vec<bool>, } @@ -1439,6 +1456,7 @@ impl std::str::FromStr for CatAllOf { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "declawed" => intermediate_rep.declawed.push(<bool as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1500,7 +1518,7 @@ impl CatAllOf { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1564,8 +1582,9 @@ impl std::str::FromStr for Category { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<i64>, pub name: Vec<String>, @@ -1584,6 +1603,7 @@ impl std::str::FromStr for Category { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1648,7 +1668,7 @@ impl Category { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1699,8 +1719,9 @@ impl std::str::FromStr for ClassModel { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub _class: Vec<String>, } @@ -1718,6 +1739,7 @@ impl std::str::FromStr for ClassModel { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "_class" => intermediate_rep._class.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1779,7 +1801,7 @@ impl ClassModel { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1829,8 +1851,9 @@ impl std::str::FromStr for Client { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub client: Vec<String>, } @@ -1848,6 +1871,7 @@ impl std::str::FromStr for Client { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "client" => intermediate_rep.client.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -1909,7 +1933,7 @@ impl Client { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -1980,8 +2004,9 @@ impl std::str::FromStr for Dog { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub class_name: Vec<String>, pub color: Vec<String>, @@ -2001,6 +2026,7 @@ impl std::str::FromStr for Dog { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "className" => intermediate_rep.class_name.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2068,7 +2094,7 @@ impl Dog { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2118,8 +2144,9 @@ impl std::str::FromStr for DogAllOf { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub breed: Vec<String>, } @@ -2137,6 +2164,7 @@ impl std::str::FromStr for DogAllOf { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "breed" => intermediate_rep.breed.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2198,7 +2226,7 @@ impl DogAllOf { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2249,8 +2277,9 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub dollar_special_left_square_bracket_property_period_name_right_square_bracket: Vec<i64>, } @@ -2268,6 +2297,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "$special[property.name]" => intermediate_rep.dollar_special_left_square_bracket_property_period_name_right_square_bracket.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2329,7 +2359,7 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2402,8 +2432,9 @@ impl std::str::FromStr for EnumArrays { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub just_symbol: Vec<String>, pub array_enum: Vec<Vec<String>>, @@ -2423,6 +2454,7 @@ impl std::str::FromStr for EnumArrays { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "just_symbol" => intermediate_rep.just_symbol.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2488,7 +2520,7 @@ impl EnumArrays { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2536,7 +2568,7 @@ impl EnumClass { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2631,8 +2663,9 @@ impl std::str::FromStr for EnumTest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub enum_string: Vec<String>, pub enum_string_required: Vec<String>, @@ -2654,6 +2687,7 @@ impl std::str::FromStr for EnumTest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "enum_string" => intermediate_rep.enum_string.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -2727,7 +2761,7 @@ impl EnumTest { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -2893,8 +2927,9 @@ impl std::str::FromStr for FormatTest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub integer: Vec<u8>, pub int32: Vec<u32>, @@ -2924,6 +2959,7 @@ impl std::str::FromStr for FormatTest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "integer" => intermediate_rep.integer.push(<u8 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3019,7 +3055,7 @@ impl FormatTest { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3082,8 +3118,9 @@ impl std::str::FromStr for HasOnlyReadOnly { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub bar: Vec<String>, pub foo: Vec<String>, @@ -3102,6 +3139,7 @@ impl std::str::FromStr for HasOnlyReadOnly { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3166,7 +3204,7 @@ impl HasOnlyReadOnly { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3216,8 +3254,9 @@ impl std::str::FromStr for List { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub param_123_list: Vec<String>, } @@ -3235,6 +3274,7 @@ impl std::str::FromStr for List { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "123-list" => intermediate_rep.param_123_list.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3296,7 +3336,7 @@ impl List { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3358,8 +3398,9 @@ impl std::str::FromStr for MapTest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub map_map_of_string: Vec<std::collections::HashMap<String, std::collections::HashMap<String, String>>>, pub map_map_of_enum: Vec<std::collections::HashMap<String, std::collections::HashMap<String, String>>>, @@ -3379,6 +3420,7 @@ impl std::str::FromStr for MapTest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "map_map_of_string" => return std::result::Result::Err("Parsing a container in this style is not supported in MapTest".to_string()), "map_map_of_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in MapTest".to_string()), @@ -3443,7 +3485,7 @@ impl MapTest { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3502,8 +3544,9 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub uuid: Vec<uuid::Uuid>, pub date_time: Vec<chrono::DateTime::<chrono::Utc>>, @@ -3523,6 +3566,7 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "uuid" => intermediate_rep.uuid.push(<uuid::Uuid as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3589,7 +3633,7 @@ impl MixedPropertiesAndAdditionalPropertiesClass { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3654,8 +3698,9 @@ impl std::str::FromStr for Model200Response { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub name: Vec<i32>, pub class: Vec<String>, @@ -3674,6 +3719,7 @@ impl std::str::FromStr for Model200Response { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3738,7 +3784,7 @@ impl Model200Response { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3824,8 +3870,9 @@ impl std::str::FromStr for Name { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub name: Vec<i32>, pub snake_case: Vec<i32>, @@ -3846,6 +3893,7 @@ impl std::str::FromStr for Name { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "name" => intermediate_rep.name.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -3916,7 +3964,7 @@ impl Name { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -3966,8 +4014,9 @@ impl std::str::FromStr for NumberOnly { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub just_number: Vec<f64>, } @@ -3985,6 +4034,7 @@ impl std::str::FromStr for NumberOnly { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "JustNumber" => intermediate_rep.just_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -4046,7 +4096,7 @@ impl NumberOnly { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4090,8 +4140,9 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub inner: Vec<models::ObjectWithOnlyAdditionalProperties>, } @@ -4109,6 +4160,7 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "inner" => intermediate_rep.inner.push(<models::ObjectWithOnlyAdditionalProperties as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -4170,7 +4222,7 @@ impl ObjectContainingObjectWithOnlyAdditionalProperties { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4229,7 +4281,7 @@ impl ObjectWithOnlyAdditionalProperties { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4341,8 +4393,9 @@ impl std::str::FromStr for Order { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<i64>, pub pet_id: Vec<i64>, @@ -4365,6 +4418,7 @@ impl std::str::FromStr for Order { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -4441,7 +4495,7 @@ impl Order { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4480,7 +4534,7 @@ impl OuterBoolean { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4556,8 +4610,9 @@ impl std::str::FromStr for OuterComposite { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub my_number: Vec<f64>, pub my_string: Vec<String>, @@ -4577,6 +4632,7 @@ impl std::str::FromStr for OuterComposite { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "my_number" => intermediate_rep.my_number.push(<f64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -4644,7 +4700,7 @@ impl OuterComposite { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4692,7 +4748,7 @@ impl OuterEnum { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4731,7 +4787,7 @@ impl OuterNumber { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4783,7 +4839,7 @@ impl OuterString { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -4879,8 +4935,9 @@ impl std::str::FromStr for Pet { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<i64>, pub category: Vec<models::Category>, @@ -4903,6 +4960,7 @@ impl std::str::FromStr for Pet { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -4977,7 +5035,7 @@ impl Pet { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -5040,8 +5098,9 @@ impl std::str::FromStr for ReadOnlyFirst { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub bar: Vec<String>, pub baz: Vec<String>, @@ -5060,6 +5119,7 @@ impl std::str::FromStr for ReadOnlyFirst { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "bar" => intermediate_rep.bar.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -5124,7 +5184,7 @@ impl ReadOnlyFirst { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -5176,8 +5236,9 @@ impl std::str::FromStr for Return { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub r#return: Vec<i32>, } @@ -5195,6 +5256,7 @@ impl std::str::FromStr for Return { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "return" => intermediate_rep.r#return.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -5256,7 +5318,7 @@ impl Return { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -5320,8 +5382,9 @@ impl std::str::FromStr for Tag { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<i64>, pub name: Vec<String>, @@ -5340,6 +5403,7 @@ impl std::str::FromStr for Tag { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -5404,7 +5468,7 @@ impl Tag { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } @@ -5547,8 +5611,9 @@ impl std::str::FromStr for User { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<i64>, pub username: Vec<String>, @@ -5573,6 +5638,7 @@ impl std::str::FromStr for User { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<i64 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -5655,7 +5721,7 @@ impl User { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. #[allow(dead_code)] - pub(crate) fn to_xml(&self) -> String { + pub(crate) fn as_xml(&self) -> String { serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") } } diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 104af6e332c..e2366ba364d 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -102,6 +102,7 @@ mod paths { pub(crate) static ID_FAKE_HYPHENPARAM_HYPHEN_PARAM: usize = 3; lazy_static! { pub static ref REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/v2/fake/hyphenParam/(?P<hyphen-param>[^/?#]*)$") .expect("Unable to create regex for FAKE_HYPHENPARAM_HYPHEN_PARAM"); } @@ -120,12 +121,14 @@ mod paths { pub(crate) static ID_PET_PETID: usize = 16; lazy_static! { pub static ref REGEX_PET_PETID: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)$") .expect("Unable to create regex for PET_PETID"); } pub(crate) static ID_PET_PETID_UPLOADIMAGE: usize = 17; lazy_static! { pub static ref REGEX_PET_PETID_UPLOADIMAGE: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/v2/pet/(?P<petId>[^/?#]*)/uploadImage$") .expect("Unable to create regex for PET_PETID_UPLOADIMAGE"); } @@ -134,6 +137,7 @@ mod paths { pub(crate) static ID_STORE_ORDER_ORDER_ID: usize = 20; lazy_static! { pub static ref REGEX_STORE_ORDER_ORDER_ID: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/v2/store/order/(?P<order_id>[^/?#]*)$") .expect("Unable to create regex for STORE_ORDER_ORDER_ID"); } @@ -145,6 +149,7 @@ mod paths { pub(crate) static ID_USER_USERNAME: usize = 26; lazy_static! { pub static ref REGEX_USER_USERNAME: regex::Regex = + #[allow(clippy::invalid_regex)] regex::Regex::new(r"^/v2/user/(?P<username>[^/?#]*)$") .expect("Unable to create regex for USER_USERNAME"); } @@ -250,10 +255,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // TestSpecialTags - PATCH /another-fake/dummy - &hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => { + hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -333,7 +338,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // Call123example - GET /fake/operation-with-numeric-id - &hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => { + hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => { let result = api_impl.call123example( &context ).await; @@ -362,7 +367,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FakeOuterBooleanSerialize - POST /fake/outer/boolean - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => { + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -432,7 +437,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FakeOuterCompositeSerialize - POST /fake/outer/composite - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => { + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -502,7 +507,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FakeOuterNumberSerialize - POST /fake/outer/number - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => { + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -572,7 +577,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FakeOuterStringSerialize - POST /fake/outer/string - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => { + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -642,7 +647,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description - &hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => { + hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => { let result = api_impl.fake_response_with_numerical_description( &context ).await; @@ -671,12 +676,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // HyphenParam - GET /fake/hyphenParam/{hyphen-param} - &hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => { + hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE FAKE_HYPHENPARAM_HYPHEN_PARAM in set but failed match against \"{}\"", path, paths::REGEX_FAKE_HYPHENPARAM_HYPHEN_PARAM.as_str()) ); @@ -724,11 +729,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestBodyWithQueryParams - PUT /fake/body-with-query-params - &hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => { + hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_query = query_params.iter().filter(|e| e.0 == "query").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_query = match param_query { Some(param_query) => { let param_query = @@ -825,7 +830,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestClientModel - PATCH /fake - &hyper::Method::PATCH if path.matched(paths::ID_FAKE) => { + hyper::Method::PATCH if path.matched(paths::ID_FAKE) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -905,11 +910,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestEndpointParameters - POST /fake - &hyper::Method::POST if path.matched(paths::ID_FAKE) => { + hyper::Method::POST if path.matched(paths::ID_FAKE) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -978,7 +983,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestEnumParameters - GET /fake - &hyper::Method::GET if path.matched(paths::ID_FAKE) => { + hyper::Method::GET if path.matched(paths::ID_FAKE) => { // Header parameters let param_enum_header_string_array = headers.get(HeaderName::from_static("enum_header_string_array")); @@ -1028,7 +1033,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where None }; let param_enum_query_string = query_params.iter().filter(|e| e.0 == "enum_query_string").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_enum_query_string = match param_enum_query_string { Some(param_enum_query_string) => { let param_enum_query_string = @@ -1045,7 +1050,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where None => None, }; let param_enum_query_integer = query_params.iter().filter(|e| e.0 == "enum_query_integer").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_enum_query_integer = match param_enum_query_integer { Some(param_enum_query_integer) => { let param_enum_query_integer = @@ -1062,7 +1067,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where None => None, }; let param_enum_query_double = query_params.iter().filter(|e| e.0 == "enum_query_double").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_enum_query_double = match param_enum_query_double { Some(param_enum_query_double) => { let param_enum_query_double = @@ -1121,7 +1126,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestInlineAdditionalProperties - POST /fake/inline-additionalProperties - &hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => { + hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -1194,7 +1199,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestJsonFormData - GET /fake/jsonFormData - &hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => { + hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => { // Form parameters let param_param = "param_example".to_string(); let param_param2 = "param2_example".to_string(); @@ -1229,11 +1234,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // TestClassname - PATCH /fake_classname_test - &hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => { + hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1319,11 +1324,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // AddPet - POST /pet - &hyper::Method::POST if path.matched(paths::ID_PET) => { + hyper::Method::POST if path.matched(paths::ID_PET) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1422,11 +1427,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // DeletePet - DELETE /pet/{petId} - &hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => { + hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1454,10 +1459,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where } // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_PET_PETID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) ); @@ -1526,11 +1531,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FindPetsByStatus - GET /pet/findByStatus - &hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => { + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1603,11 +1608,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FindPetsByTags - GET /pet/findByTags - &hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => { + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1680,11 +1685,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetPetById - GET /pet/{petId} - &hyper::Method::GET if path.matched(paths::ID_PET_PETID) => { + hyper::Method::GET if path.matched(paths::ID_PET_PETID) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1692,10 +1697,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where } // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_PET_PETID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) ); @@ -1758,11 +1763,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UpdatePet - PUT /pet - &hyper::Method::PUT if path.matched(paths::ID_PET) => { + hyper::Method::PUT if path.matched(paths::ID_PET) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1869,11 +1874,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UpdatePetWithForm - POST /pet/{petId} - &hyper::Method::POST if path.matched(paths::ID_PET_PETID) => { + hyper::Method::POST if path.matched(paths::ID_PET_PETID) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1901,10 +1906,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where } // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_PET_PETID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE PET_PETID in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID.as_str()) ); @@ -1958,11 +1963,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UploadFile - POST /pet/{petId}/uploadImage - &hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => { + hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -1998,10 +2003,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }; // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_PET_PETID_UPLOADIMAGE - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE PET_PETID_UPLOADIMAGE in set but failed match against \"{}\"", path, paths::REGEX_PET_PETID_UPLOADIMAGE.as_str()) ); @@ -2036,7 +2041,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where _ => { return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Unable to process all message parts"))) + .body(Body::from("Unable to process all message parts".to_string())) .expect("Unable to create Bad Request response due to failure to process all message")) }, }; @@ -2126,18 +2131,18 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, Err(e) => Ok(Response::builder() .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Couldn't read multipart body"))) + .body(Body::from("Couldn't read multipart body".to_string())) .expect("Unable to create Bad Request response due to unable read multipart body")), } }, // DeleteOrder - DELETE /store/order/{order_id} - &hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_STORE_ORDER_ORDER_ID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) ); @@ -2189,11 +2194,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetInventory - GET /store/inventory - &hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => { + hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -2235,12 +2240,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetOrderById - GET /store/order/{order_id} - &hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { + hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_STORE_ORDER_ORDER_ID - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE STORE_ORDER_ORDER_ID in set but failed match against \"{}\"", path, paths::REGEX_STORE_ORDER_ORDER_ID.as_str()) ); @@ -2303,7 +2308,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // PlaceOrder - POST /store/order - &hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => { + hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2387,7 +2392,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CreateUser - POST /user - &hyper::Method::POST if path.matched(paths::ID_USER) => { + hyper::Method::POST if path.matched(paths::ID_USER) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2460,7 +2465,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CreateUsersWithArrayInput - POST /user/createWithArray - &hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => { + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2533,7 +2538,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // CreateUsersWithListInput - POST /user/createWithList - &hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => { + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -2606,12 +2611,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // DeleteUser - DELETE /user/{username} - &hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => { + hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_USER_USERNAME - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) ); @@ -2663,12 +2668,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetUserByName - GET /user/{username} - &hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => { + hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_USER_USERNAME - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) ); @@ -2731,11 +2736,11 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // LoginUser - GET /user/login - &hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => { + hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => { // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response) let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>(); let param_username = query_params.iter().filter(|e| e.0 == "username").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_username = match param_username { Some(param_username) => { let param_username = @@ -2759,7 +2764,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where .expect("Unable to create Bad Request response for missing query parameter username")), }; let param_password = query_params.iter().filter(|e| e.0 == "password").map(|e| e.1.to_owned()) - .nth(0); + .next(); let param_password = match param_password { Some(param_password) => { let param_password = @@ -2860,7 +2865,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // LogoutUser - GET /user/logout - &hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => { + hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => { let result = api_impl.logout_user( &context ).await; @@ -2889,12 +2894,12 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // UpdateUser - PUT /user/{username} - &hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => { + hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => { // Path parameters - let path: &str = &uri.path().to_string(); + let path: &str = uri.path(); let path_params = paths::REGEX_USER_USERNAME - .captures(&path) + .captures(path) .unwrap_or_else(|| panic!("Path {} matched RE USER_USERNAME in set but failed match against \"{}\"", path, paths::REGEX_USER_USERNAME.as_str()) ); @@ -3028,77 +3033,77 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // TestSpecialTags - PATCH /another-fake/dummy - &hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => Some("TestSpecialTags"), + hyper::Method::PATCH if path.matched(paths::ID_ANOTHER_FAKE_DUMMY) => Some("TestSpecialTags"), // Call123example - GET /fake/operation-with-numeric-id - &hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => Some("Call123example"), + hyper::Method::GET if path.matched(paths::ID_FAKE_OPERATION_WITH_NUMERIC_ID) => Some("Call123example"), // FakeOuterBooleanSerialize - POST /fake/outer/boolean - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => Some("FakeOuterBooleanSerialize"), + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_BOOLEAN) => Some("FakeOuterBooleanSerialize"), // FakeOuterCompositeSerialize - POST /fake/outer/composite - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => Some("FakeOuterCompositeSerialize"), + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_COMPOSITE) => Some("FakeOuterCompositeSerialize"), // FakeOuterNumberSerialize - POST /fake/outer/number - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => Some("FakeOuterNumberSerialize"), + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_NUMBER) => Some("FakeOuterNumberSerialize"), // FakeOuterStringSerialize - POST /fake/outer/string - &hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => Some("FakeOuterStringSerialize"), + hyper::Method::POST if path.matched(paths::ID_FAKE_OUTER_STRING) => Some("FakeOuterStringSerialize"), // FakeResponseWithNumericalDescription - GET /fake/response-with-numerical-description - &hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => Some("FakeResponseWithNumericalDescription"), + hyper::Method::GET if path.matched(paths::ID_FAKE_RESPONSE_WITH_NUMERICAL_DESCRIPTION) => Some("FakeResponseWithNumericalDescription"), // HyphenParam - GET /fake/hyphenParam/{hyphen-param} - &hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"), + hyper::Method::GET if path.matched(paths::ID_FAKE_HYPHENPARAM_HYPHEN_PARAM) => Some("HyphenParam"), // TestBodyWithQueryParams - PUT /fake/body-with-query-params - &hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Some("TestBodyWithQueryParams"), + hyper::Method::PUT if path.matched(paths::ID_FAKE_BODY_WITH_QUERY_PARAMS) => Some("TestBodyWithQueryParams"), // TestClientModel - PATCH /fake - &hyper::Method::PATCH if path.matched(paths::ID_FAKE) => Some("TestClientModel"), + hyper::Method::PATCH if path.matched(paths::ID_FAKE) => Some("TestClientModel"), // TestEndpointParameters - POST /fake - &hyper::Method::POST if path.matched(paths::ID_FAKE) => Some("TestEndpointParameters"), + hyper::Method::POST if path.matched(paths::ID_FAKE) => Some("TestEndpointParameters"), // TestEnumParameters - GET /fake - &hyper::Method::GET if path.matched(paths::ID_FAKE) => Some("TestEnumParameters"), + hyper::Method::GET if path.matched(paths::ID_FAKE) => Some("TestEnumParameters"), // TestInlineAdditionalProperties - POST /fake/inline-additionalProperties - &hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Some("TestInlineAdditionalProperties"), + hyper::Method::POST if path.matched(paths::ID_FAKE_INLINE_ADDITIONALPROPERTIES) => Some("TestInlineAdditionalProperties"), // TestJsonFormData - GET /fake/jsonFormData - &hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => Some("TestJsonFormData"), + hyper::Method::GET if path.matched(paths::ID_FAKE_JSONFORMDATA) => Some("TestJsonFormData"), // TestClassname - PATCH /fake_classname_test - &hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Some("TestClassname"), + hyper::Method::PATCH if path.matched(paths::ID_FAKE_CLASSNAME_TEST) => Some("TestClassname"), // AddPet - POST /pet - &hyper::Method::POST if path.matched(paths::ID_PET) => Some("AddPet"), + hyper::Method::POST if path.matched(paths::ID_PET) => Some("AddPet"), // DeletePet - DELETE /pet/{petId} - &hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"), + hyper::Method::DELETE if path.matched(paths::ID_PET_PETID) => Some("DeletePet"), // FindPetsByStatus - GET /pet/findByStatus - &hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => Some("FindPetsByStatus"), + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYSTATUS) => Some("FindPetsByStatus"), // FindPetsByTags - GET /pet/findByTags - &hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => Some("FindPetsByTags"), + hyper::Method::GET if path.matched(paths::ID_PET_FINDBYTAGS) => Some("FindPetsByTags"), // GetPetById - GET /pet/{petId} - &hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"), + hyper::Method::GET if path.matched(paths::ID_PET_PETID) => Some("GetPetById"), // UpdatePet - PUT /pet - &hyper::Method::PUT if path.matched(paths::ID_PET) => Some("UpdatePet"), + hyper::Method::PUT if path.matched(paths::ID_PET) => Some("UpdatePet"), // UpdatePetWithForm - POST /pet/{petId} - &hyper::Method::POST if path.matched(paths::ID_PET_PETID) => Some("UpdatePetWithForm"), + hyper::Method::POST if path.matched(paths::ID_PET_PETID) => Some("UpdatePetWithForm"), // UploadFile - POST /pet/{petId}/uploadImage - &hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Some("UploadFile"), + hyper::Method::POST if path.matched(paths::ID_PET_PETID_UPLOADIMAGE) => Some("UploadFile"), // DeleteOrder - DELETE /store/order/{order_id} - &hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"), + hyper::Method::DELETE if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("DeleteOrder"), // GetInventory - GET /store/inventory - &hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => Some("GetInventory"), + hyper::Method::GET if path.matched(paths::ID_STORE_INVENTORY) => Some("GetInventory"), // GetOrderById - GET /store/order/{order_id} - &hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"), + hyper::Method::GET if path.matched(paths::ID_STORE_ORDER_ORDER_ID) => Some("GetOrderById"), // PlaceOrder - POST /store/order - &hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => Some("PlaceOrder"), + hyper::Method::POST if path.matched(paths::ID_STORE_ORDER) => Some("PlaceOrder"), // CreateUser - POST /user - &hyper::Method::POST if path.matched(paths::ID_USER) => Some("CreateUser"), + hyper::Method::POST if path.matched(paths::ID_USER) => Some("CreateUser"), // CreateUsersWithArrayInput - POST /user/createWithArray - &hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => Some("CreateUsersWithArrayInput"), + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHARRAY) => Some("CreateUsersWithArrayInput"), // CreateUsersWithListInput - POST /user/createWithList - &hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => Some("CreateUsersWithListInput"), + hyper::Method::POST if path.matched(paths::ID_USER_CREATEWITHLIST) => Some("CreateUsersWithListInput"), // DeleteUser - DELETE /user/{username} - &hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"), + hyper::Method::DELETE if path.matched(paths::ID_USER_USERNAME) => Some("DeleteUser"), // GetUserByName - GET /user/{username} - &hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"), + hyper::Method::GET if path.matched(paths::ID_USER_USERNAME) => Some("GetUserByName"), // LoginUser - GET /user/login - &hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => Some("LoginUser"), + hyper::Method::GET if path.matched(paths::ID_USER_LOGIN) => Some("LoginUser"), // LogoutUser - GET /user/logout - &hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => Some("LogoutUser"), + hyper::Method::GET if path.matched(paths::ID_USER_LOGOUT) => Some("LogoutUser"), // UpdateUser - PUT /user/{username} - &hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => Some("UpdateUser"), + hyper::Method::PUT if path.matched(paths::ID_USER_USERNAME) => Some("UpdateUser"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs index 854dd41f33f..9ce229a207f 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/client/mod.rs @@ -419,8 +419,10 @@ impl<S, C> Api<C> for Client<S, C> where Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) }); + #[allow(clippy::collapsible_match)] if let Some(auth_data) = Has::<Option<AuthData>>::get(context).as_ref() { // Currently only authentication with Basic and Bearer are supported + #[allow(clippy::single_match, clippy::match_single_binding)] match auth_data { &AuthData::Bearer(ref bearer_header) => { let auth = swagger::auth::Header(bearer_header.clone()); diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/context.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/context.rs index 6f030053252..ac1c07864b8 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/context.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/context.rs @@ -107,7 +107,7 @@ impl<T, A, B, C, D, ReqBody> Service<Request<ReqBody>> for AddContext<T, A, B, C { use swagger::auth::Bearer; use std::ops::Deref; - if let Some(bearer) = swagger::auth::from_headers::<Bearer>(&headers) { + if let Some(bearer) = swagger::auth::from_headers::<Bearer>(headers) { let auth_data = AuthData::Bearer(bearer); let context = context.push(Some(auth_data)); let context = context.push(None::<Authorization>); diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs index 4726f174638..5a5c46ba33c 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -22,6 +22,7 @@ pub enum PingGetResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -35,6 +36,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs index 6a19617d356..0657f06dd60 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs @@ -137,14 +137,14 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // PingGet - GET /ping - &hyper::Method::GET if path.matched(paths::ID_PING) => { + hyper::Method::GET if path.matched(paths::ID_PING) => { { - let authorization = match (&context as &dyn Has<Option<Authorization>>).get() { - &Some(ref authorization) => authorization, - &None => return Ok(Response::builder() + let authorization = match *(&context as &dyn Has<Option<Authorization>>).get() { + Some(ref authorization) => authorization, + None => return Ok(Response::builder() .status(StatusCode::FORBIDDEN) .body(Body::from("Unauthenticated")) .expect("Unable to create Authentication Forbidden response")), @@ -191,9 +191,9 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // PingGet - GET /ping - &hyper::Method::GET if path.matched(paths::ID_PING) => Some("PingGet"), + hyper::Method::GET if path.matched(paths::ID_PING) => Some("PingGet"), _ => None, } } diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs index c38b2c2b77b..9d9c1f711c3 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] -#![allow(unused_imports)] -#![allow(clippy::derive_partial_eq_without_eq)] +#![allow(unused_imports, unused_attributes)] +#![allow(clippy::derive_partial_eq_without_eq, clippy::blacklisted_name)] use async_trait::async_trait; use futures::Stream; @@ -75,6 +75,7 @@ pub enum SoloObjectPostResponse { /// API #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait Api<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>> { Poll::Ready(Ok(())) @@ -129,6 +130,7 @@ pub trait Api<C: Send + Sync> { /// API where `Context` isn't passed on every API call #[async_trait] +#[allow(clippy::too_many_arguments, clippy::ptr_arg)] pub trait ApiNoContext<C: Send + Sync> { fn poll_ready(&self, _cx: &mut Context) -> Poll<Result<(), Box<dyn Error + Send + Sync + 'static>>>; diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs index 130d0e292aa..98527d6d9ac 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs @@ -59,8 +59,9 @@ impl std::str::FromStr for ANullableContainer { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub nullable_thing: Vec<String>, pub required_nullable_thing: Vec<String>, @@ -79,6 +80,7 @@ impl std::str::FromStr for ANullableContainer { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { "NullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()), "RequiredNullableThing" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in ANullableContainer".to_string()), @@ -246,8 +248,9 @@ impl std::str::FromStr for AllOfObject { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub sample_property: Vec<String>, pub sample_base_propery: Vec<String>, @@ -266,6 +269,7 @@ impl std::str::FromStr for AllOfObject { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -371,8 +375,9 @@ impl std::str::FromStr for BaseAllOf { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub sample_base_propery: Vec<String>, } @@ -390,6 +395,7 @@ impl std::str::FromStr for BaseAllOf { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "sampleBasePropery" => intermediate_rep.sample_base_propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -500,8 +506,9 @@ impl std::str::FromStr for DummyPutRequest { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub id: Vec<String>, pub password: Vec<String>, @@ -520,6 +527,7 @@ impl std::str::FromStr for DummyPutRequest { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -627,8 +635,9 @@ impl std::str::FromStr for GetYamlResponse { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub value: Vec<String>, } @@ -646,6 +655,7 @@ impl std::str::FromStr for GetYamlResponse { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -743,8 +753,9 @@ impl std::str::FromStr for ObjectOfObjects { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub inner: Vec<models::ObjectOfObjectsInner>, } @@ -762,6 +773,7 @@ impl std::str::FromStr for ObjectOfObjects { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), @@ -872,8 +884,9 @@ impl std::str::FromStr for ObjectOfObjectsInner { type Err = String; fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + /// An intermediate representation of the struct to use for parsing. #[derive(Default)] - // An intermediate representation of the struct to use for parsing. + #[allow(dead_code)] struct IntermediateRep { pub required_thing: Vec<String>, pub optional_thing: Vec<isize>, @@ -892,6 +905,7 @@ impl std::str::FromStr for ObjectOfObjectsInner { }; if let Some(key) = key_result { + #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index dacae95911e..52df96f3ef6 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -159,10 +159,10 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where let (method, uri, headers) = (parts.method, parts.uri, parts.headers); let path = paths::GLOBAL_REGEX_SET.matches(uri.path()); - match &method { + match method { // AllOfGet - GET /allOf - &hyper::Method::GET if path.matched(paths::ID_ALLOF) => { + hyper::Method::GET if path.matched(paths::ID_ALLOF) => { let result = api_impl.all_of_get( &context ).await; @@ -198,7 +198,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // DummyGet - GET /dummy - &hyper::Method::GET if path.matched(paths::ID_DUMMY) => { + hyper::Method::GET if path.matched(paths::ID_DUMMY) => { let result = api_impl.dummy_get( &context ).await; @@ -227,7 +227,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // DummyPut - PUT /dummy - &hyper::Method::PUT if path.matched(paths::ID_DUMMY) => { + hyper::Method::PUT if path.matched(paths::ID_DUMMY) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -300,7 +300,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // FileResponseGet - GET /file_response - &hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => { + hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => { let result = api_impl.file_response_get( &context ).await; @@ -336,7 +336,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // GetStructuredYaml - GET /get-structured-yaml - &hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => { + hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => { let result = api_impl.get_structured_yaml( &context ).await; @@ -372,7 +372,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // HtmlPost - POST /html - &hyper::Method::POST if path.matched(paths::ID_HTML) => { + hyper::Method::POST if path.matched(paths::ID_HTML) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -440,7 +440,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // PostYaml - POST /post-yaml - &hyper::Method::POST if path.matched(paths::ID_POST_YAML) => { + hyper::Method::POST if path.matched(paths::ID_POST_YAML) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -501,7 +501,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // RawJsonGet - GET /raw_json - &hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => { + hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => { let result = api_impl.raw_json_get( &context ).await; @@ -537,7 +537,7 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where }, // SoloObjectPost - POST /solo-object - &hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => { + hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => { // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -629,25 +629,25 @@ pub struct ApiRequestParser; impl<T> RequestParser<T> for ApiRequestParser { fn parse_operation_id(request: &Request<T>) -> Option<&'static str> { let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path()); - match request.method() { + match *request.method() { // AllOfGet - GET /allOf - &hyper::Method::GET if path.matched(paths::ID_ALLOF) => Some("AllOfGet"), + hyper::Method::GET if path.matched(paths::ID_ALLOF) => Some("AllOfGet"), // DummyGet - GET /dummy - &hyper::Method::GET if path.matched(paths::ID_DUMMY) => Some("DummyGet"), + hyper::Method::GET if path.matched(paths::ID_DUMMY) => Some("DummyGet"), // DummyPut - PUT /dummy - &hyper::Method::PUT if path.matched(paths::ID_DUMMY) => Some("DummyPut"), + hyper::Method::PUT if path.matched(paths::ID_DUMMY) => Some("DummyPut"), // FileResponseGet - GET /file_response - &hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => Some("FileResponseGet"), + hyper::Method::GET if path.matched(paths::ID_FILE_RESPONSE) => Some("FileResponseGet"), // GetStructuredYaml - GET /get-structured-yaml - &hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => Some("GetStructuredYaml"), + hyper::Method::GET if path.matched(paths::ID_GET_STRUCTURED_YAML) => Some("GetStructuredYaml"), // HtmlPost - POST /html - &hyper::Method::POST if path.matched(paths::ID_HTML) => Some("HtmlPost"), + hyper::Method::POST if path.matched(paths::ID_HTML) => Some("HtmlPost"), // PostYaml - POST /post-yaml - &hyper::Method::POST if path.matched(paths::ID_POST_YAML) => Some("PostYaml"), + hyper::Method::POST if path.matched(paths::ID_POST_YAML) => Some("PostYaml"), // RawJsonGet - GET /raw_json - &hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => Some("RawJsonGet"), + hyper::Method::GET if path.matched(paths::ID_RAW_JSON) => Some("RawJsonGet"), // SoloObjectPost - POST /solo-object - &hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => Some("SoloObjectPost"), + hyper::Method::POST if path.matched(paths::ID_SOLO_OBJECT) => Some("SoloObjectPost"), _ => None, } } -- GitLab From 2aa2f082b392e4f158972aacaf3137c677c680de Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Wed, 21 Sep 2022 01:15:48 +0900 Subject: [PATCH 16/18] build(rust-server): Add clippy execution to sample integration test --- samples/server/petstore/rust-server/pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/samples/server/petstore/rust-server/pom.xml b/samples/server/petstore/rust-server/pom.xml index eeefcb808a5..7963d9dc633 100644 --- a/samples/server/petstore/rust-server/pom.xml +++ b/samples/server/petstore/rust-server/pom.xml @@ -53,6 +53,21 @@ </arguments> </configuration> </execution> + <execution> + <id>clippy</id> + <phase>integration-test</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>cargo</executable> + <arguments> + <argument>clippy</argument> + <argument>--</argument> + <argument>-Dwarnings</argument> + </arguments> + </configuration> + </execution> </executions> </plugin> </plugins> -- GitLab From 9f1257d9f5f1a8fedd170b43a606b3c955a255e3 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Wed, 21 Sep 2022 01:21:02 +0900 Subject: [PATCH 17/18] build(rust-server): Add .cargo/config to the test root to use -Dwarnings flag in tests --- .../server/petstore/rust-server/.cargo/config | 18 ++++++++++++++++++ samples/server/petstore/rust-server/pom.xml | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 samples/server/petstore/rust-server/.cargo/config diff --git a/samples/server/petstore/rust-server/.cargo/config b/samples/server/petstore/rust-server/.cargo/config new file mode 100644 index 00000000000..b8acc9c00c8 --- /dev/null +++ b/samples/server/petstore/rust-server/.cargo/config @@ -0,0 +1,18 @@ +[build] +rustflags = [ + "-W", "missing_docs", # detects missing documentation for public members + + "-W", "trivial_casts", # detects trivial casts which could be removed + + "-W", "trivial_numeric_casts", # detects trivial casts of numeric types which could be removed + + "-W", "unsafe_code", # usage of `unsafe` code + + "-W", "unused_qualifications", # detects unnecessarily qualified names + + "-W", "unused_extern_crates", # extern crates that are never used + + "-W", "unused_import_braces", # unnecessary braces around an imported item + + "-D", "warnings", # all warnings should be denied +] diff --git a/samples/server/petstore/rust-server/pom.xml b/samples/server/petstore/rust-server/pom.xml index 7963d9dc633..61e50dcc15a 100644 --- a/samples/server/petstore/rust-server/pom.xml +++ b/samples/server/petstore/rust-server/pom.xml @@ -63,8 +63,6 @@ <executable>cargo</executable> <arguments> <argument>clippy</argument> - <argument>--</argument> - <argument>-Dwarnings</argument> </arguments> </configuration> </execution> -- GitLab From aa23af8c20ace2a5debfeaa501f1036298a30246 Mon Sep 17 00:00:00 2001 From: "Naoki Ikeguchi (YUMEMI Inc.)" <n_ikeguchi@yumemi.co.jp> Date: Wed, 21 Sep 2022 01:21:39 +0900 Subject: [PATCH 18/18] fix(rust-server): Allow unused_mut to avoid compilation fails in some environments --- .../main/resources/rust-server/example-server-common.mustache | 1 + .../rust-server/output/multipart-v3/examples/server/server.rs | 1 + .../rust-server/output/no-example-v3/examples/server/server.rs | 1 + .../rust-server/output/openapi-v3/examples/client/server.rs | 1 + .../rust-server/output/openapi-v3/examples/server/server.rs | 1 + .../petstore/rust-server/output/ops-v3/examples/server/server.rs | 1 + .../examples/server/server.rs | 1 + .../output/ping-bearer-auth/examples/server/server.rs | 1 + .../output/rust-server-test/examples/server/server.rs | 1 + 9 files changed, 9 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/rust-server/example-server-common.mustache b/modules/openapi-generator/src/main/resources/rust-server/example-server-common.mustache index 960449f0437..924abea8549 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/example-server-common.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/example-server-common.mustache @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = {{{externCrateName}}}::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/multipart-v3/examples/server/server.rs b/samples/server/petstore/rust-server/output/multipart-v3/examples/server/server.rs index 892a189b8ef..a031eb139ca 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = multipart_v3::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/no-example-v3/examples/server/server.rs b/samples/server/petstore/rust-server/output/no-example-v3/examples/server/server.rs index 3bc8fa48fe2..55f8d608b52 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = no_example_v3::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/client/server.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/client/server.rs index fab67f0476b..a66747e42db 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/client/server.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/client/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = openapi_v3::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs index e2d19e2266c..1fde6bbdf1e 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = openapi_v3::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/ops-v3/examples/server/server.rs b/samples/server/petstore/rust-server/output/ops-v3/examples/server/server.rs index ffd7d59c804..0f5e145f345 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = ops_v3::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs index e86eaae25fb..304590c34f1 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = petstore_with_fake_endpoints_models_for_testing::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/examples/server/server.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/examples/server/server.rs index 19af14b7782..3383a22e1ad 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = ping_bearer_auth::server::context::MakeAddContext::<_, EmptyContext>::new( service diff --git a/samples/server/petstore/rust-server/output/rust-server-test/examples/server/server.rs b/samples/server/petstore/rust-server/output/rust-server-test/examples/server/server.rs index 143e17a051d..ab9e383866b 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/examples/server/server.rs @@ -32,6 +32,7 @@ pub async fn create(addr: &str, https: bool) { let service = MakeAllowAllAuthenticator::new(service, "cosmo"); + #[allow(unused_mut)] let mut service = rust_server_test::server::context::MakeAddContext::<_, EmptyContext>::new( service -- GitLab