diff --git a/samples/server/petstore/kotlin-springboot-request/.openapi-generator/FILES b/samples/server/petstore/kotlin-springboot-request/.openapi-generator/FILES index 843a3288acd4..6500c2b11cc5 100644 --- a/samples/server/petstore/kotlin-springboot-request/.openapi-generator/FILES +++ b/samples/server/petstore/kotlin-springboot-request/.openapi-generator/FILES @@ -1,4 +1,3 @@ -.openapi-generator-ignore README.md build.gradle.kts pom.xml diff --git a/samples/server/petstore/kotlin-springboot-request/.openapi-generator/VERSION b/samples/server/petstore/kotlin-springboot-request/.openapi-generator/VERSION index 0f78c31cdc77..fff4bdd7ab59 100644 --- a/samples/server/petstore/kotlin-springboot-request/.openapi-generator/VERSION +++ b/samples/server/petstore/kotlin-springboot-request/.openapi-generator/VERSION @@ -1 +1 @@ -7.2.0-SNAPSHOT \ No newline at end of file +7.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/PetApi.kt b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/PetApi.kt index f5372c859777..5992245a2126 100644 --- a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/PetApi.kt +++ b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/PetApi.kt @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT). + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT). * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/StoreApi.kt b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/StoreApi.kt index 7f84f6d301eb..a4f995f64d12 100644 --- a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/StoreApi.kt +++ b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/StoreApi.kt @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT). + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT). * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/UserApi.kt b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/UserApi.kt index d55ddaa8b954..61bb690132d3 100644 --- a/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/UserApi.kt +++ b/samples/server/petstore/kotlin-springboot-request/src/main/kotlin/org/openapitools/api/UserApi.kt @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT). + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT). * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/header.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/header.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs index ad0edc3812ee..f0c2fbe49bcb 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,60 +14,65 @@ use types::*; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MultipartRelatedRequestPostResponse { /// OK - Status201_OK, + Status201_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MultipartRequestPostResponse { /// OK - Status201_OK, + Status201_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MultipleIdenticalMimeTypesPostResponse { /// OK - Status200_OK, + Status200_OK } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// MultipartRelatedRequestPost - POST /multipart_related_request - async fn multipart_related_request_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: axum::body::Body, - ) -> Result; - /// MultipartRequestPost - POST /multipart_request - async fn multipart_request_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Multipart, - ) -> Result; + /// MultipartRelatedRequestPost - POST /multipart_related_request + async fn multipart_related_request_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: axum::body::Body, + ) -> Result; + + + /// MultipartRequestPost - POST /multipart_request + async fn multipart_request_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Multipart, + ) -> Result; + + + /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types + async fn multiple_identical_mime_types_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: axum::body::Body, + ) -> Result; - /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types - async fn multiple_identical_mime_types_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: axum::body::Body, - ) -> Result; } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs index 56ed14cbe8a6..6ccb7d3f84d1 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs @@ -7,24 +7,34 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRelatedRequest { #[serde(rename = "object_field")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub object_field: Option, #[serde(rename = "optional_binary_field")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub optional_binary_field: Option, #[serde(rename = "required_binary_field")] pub required_binary_field: ByteArray, + } + impl MultipartRelatedRequest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_binary_field: ByteArray) -> MultipartRelatedRequest { + pub fn new(required_binary_field: ByteArray, ) -> MultipartRelatedRequest { MultipartRelatedRequest { object_field: None, optional_binary_field: None, @@ -78,11 +88,7 @@ impl std::str::FromStr for MultipartRelatedRequest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing MultipartRelatedRequest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing MultipartRelatedRequest".to_string()) }; if let Some(key) = key_result { @@ -104,13 +110,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_else(|| { - "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())?, }) } } @@ -121,16 +121,13 @@ impl std::str::FromStr for MultipartRelatedRequest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for MultipartRelatedRequest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MultipartRelatedRequest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -141,25 +138,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultipartRelatedRequest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into MultipartRelatedRequest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipartRequestObjectField { @@ -167,13 +166,15 @@ pub struct MultipartRequestObjectField { pub field_a: String, #[serde(rename = "field_b")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub field_b: Option>, + } + impl MultipartRequestObjectField { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(field_a: String) -> MultipartRequestObjectField { + pub fn new(field_a: String, ) -> MultipartRequestObjectField { MultipartRequestObjectField { field_a, field_b: None, @@ -187,19 +188,18 @@ impl MultipartRequestObjectField { impl std::string::ToString for MultipartRequestObjectField { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("field_a".to_string()), Some(self.field_a.to_string()), + + self.field_b.as_ref().map(|field_b| { [ "field_b".to_string(), - field_b - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + field_b.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -230,11 +230,7 @@ impl std::str::FromStr for MultipartRequestObjectField { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing MultipartRequestObjectField".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing MultipartRequestObjectField".to_string()) }; if let Some(key) = key_result { @@ -253,11 +249,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_else(|| "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(), }) } @@ -269,16 +261,13 @@ impl std::str::FromStr for MultipartRequestObjectField { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for MultipartRequestObjectField - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MultipartRequestObjectField - value: {} is invalid {}", + hdr_value, e)) } } } @@ -289,37 +278,41 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultipartRequestObjectField - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into MultipartRequestObjectField - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultipleIdenticalMimeTypesPostRequest { #[serde(rename = "binary1")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub binary1: Option, #[serde(rename = "binary2")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub binary2: Option, + } + impl MultipleIdenticalMimeTypesPostRequest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> MultipleIdenticalMimeTypesPostRequest { @@ -372,12 +365,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing MultipleIdenticalMimeTypesPostRequest" - .to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing MultipleIdenticalMimeTypesPostRequest".to_string()) }; if let Some(key) = key_result { @@ -404,14 +392,10 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> - for HeaderValue -{ +impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { std::result::Result::Ok(value) => std::result::Result::Ok(value), @@ -423,9 +407,7 @@ impl std::convert::TryFrom - for header::IntoHeaderValue -{ +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { @@ -444,3 +426,6 @@ impl std::convert::TryFrom } } } + + + diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index b1dc6929757c..a13018a64851 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -12,9 +12,10 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{ - Api, MultipartRelatedRequestPostResponse, MultipartRequestPostResponse, - MultipleIdenticalMimeTypesPostResponse, +use crate::{Api, + MultipartRelatedRequestPostResponse, + MultipartRequestPostResponse, + MultipleIdenticalMimeTypesPostResponse }; /// Setup API Server. @@ -25,187 +26,216 @@ where { // build our application with a route Router::new() - .route( - "/multipart_related_request", - post(multipart_related_request_post::), + .route("/multipart_related_request", + post(multipart_related_request_post::) ) - .route("/multipart_request", post(multipart_request_post::)) - .route( - "/multiple-identical-mime-types", - post(multiple_identical_mime_types_post::), + .route("/multipart_request", + post(multipart_request_post::) + ) + .route("/multiple-identical-mime-types", + post(multiple_identical_mime_types_post::) ) .with_state(api_impl) } + #[tracing::instrument(skip_all)] -fn multipart_related_request_post_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn multipart_related_request_post_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MultipartRelatedRequestPost - POST /multipart_related_request #[tracing::instrument(skip_all)] async fn multipart_related_request_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: axum::body::Body, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: axum::body::Body, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || multipart_related_request_post_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + multipart_related_request_post_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .multipart_related_request_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().multipart_related_request_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MultipartRelatedRequestPostResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + MultipartRelatedRequestPostResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn multipart_request_post_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn multipart_request_post_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MultipartRequestPost - POST /multipart_request #[tracing::instrument(skip_all)] async fn multipart_request_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Multipart, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Multipart, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || multipart_request_post_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + multipart_request_post_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .multipart_request_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().multipart_request_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MultipartRequestPostResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + MultipartRequestPostResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn multiple_identical_mime_types_post_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn multiple_identical_mime_types_post_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types #[tracing::instrument(skip_all)] async fn multiple_identical_mime_types_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: axum::body::Body, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: axum::body::Body, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || multiple_identical_mime_types_post_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + multiple_identical_mime_types_post_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .multiple_identical_mime_types_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().multiple_identical_mime_types_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MultipleIdenticalMimeTypesPostResponse::Status200_OK => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + MultipleIdenticalMimeTypesPostResponse::Status200_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/header.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/header.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs index a86c406ffee4..b72ebe84cb8d 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,488 +14,569 @@ use types::*; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0.7"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum AnyOfGetResponse { /// Success - Status200_Success(models::AnyOfObject), + Status200_Success + (models::AnyOfObject) + , /// AlternateSuccess - Status201_AlternateSuccess(models::Model12345AnyOfObject), + Status201_AlternateSuccess + (models::Model12345AnyOfObject) + , /// AnyOfSuccess - Status202_AnyOfSuccess(models::AnyOfGet202Response), + Status202_AnyOfSuccess + (models::AnyOfGet202Response) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CallbackWithHeaderPostResponse { /// OK - Status204_OK, + Status204_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum ComplexQueryParamGetResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum EnumInPathPathParamGetResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum JsonComplexQueryParamGetResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MandatoryRequestHeaderGetResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MergePatchJsonGetResponse { /// merge-patch+json-encoded response - Status200_Merge(models::AnotherXmlObject), + Status200_Merge + (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MultigetGetResponse { /// JSON rsp - Status200_JSONRsp(models::AnotherXmlObject), + Status200_JSONRsp + (models::AnotherXmlObject) + , /// XML rsp - Status201_XMLRsp(String), + Status201_XMLRsp + (String) + , /// octet rsp - Status202_OctetRsp(ByteArray), + Status202_OctetRsp + (ByteArray) + , /// string rsp - Status203_StringRsp(String), + Status203_StringRsp + (String) + , /// Duplicate Response long text. One. - Status204_DuplicateResponseLongText(models::AnotherXmlObject), + Status204_DuplicateResponseLongText + (models::AnotherXmlObject) + , /// Duplicate Response long text. Two. - Status205_DuplicateResponseLongText(models::AnotherXmlObject), + Status205_DuplicateResponseLongText + (models::AnotherXmlObject) + , /// Duplicate Response long text. Three. - Status206_DuplicateResponseLongText(models::AnotherXmlObject), + Status206_DuplicateResponseLongText + (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum MultipleAuthSchemeGetResponse { /// Check that limiting to multiple required auth schemes works - Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks, + Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum OneOfGetResponse { /// Success - Status200_Success(models::OneOfGet200Response), + Status200_Success + (models::OneOfGet200Response) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum OverrideServerGetResponse { /// Success. - Status204_Success, + Status204_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum ParamgetGetResponse { /// JSON rsp - Status200_JSONRsp(models::AnotherXmlObject), + Status200_JSONRsp + (models::AnotherXmlObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum ReadonlyAuthSchemeGetResponse { /// Check that limiting to a single required auth scheme works - Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks, + Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum RegisterCallbackPostResponse { /// OK - Status204_OK, + Status204_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum RequiredOctetStreamPutResponse { /// OK - Status200_OK, + Status200_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum ResponsesWithHeadersGetResponse { /// Success - Status200_Success { + Status200_Success + { body: String, - success_info: String, - bool_header: Option, - object_header: Option, - }, + success_info: + String + , + bool_header: + Option< + bool + > + , + object_header: + Option< + models::ObjectHeader + > + } + , /// Precondition Failed - Status412_PreconditionFailed { - further_info: Option, - failure_info: Option, - }, + Status412_PreconditionFailed + { + further_info: + Option< + String + > + , + failure_info: + Option< + String + > + } } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum Rfc7807GetResponse { /// OK - Status204_OK(models::ObjectWithArrayOfObjects), + Status204_OK + (models::ObjectWithArrayOfObjects) + , /// NotFound - Status404_NotFound(models::ObjectWithArrayOfObjects), + Status404_NotFound + (models::ObjectWithArrayOfObjects) + , /// NotAcceptable - Status406_NotAcceptable(String), + Status406_NotAcceptable + (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UntypedPropertyGetResponse { /// Check that untyped properties works - Status200_CheckThatUntypedPropertiesWorks, + Status200_CheckThatUntypedPropertiesWorks } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UuidGetResponse { /// Duplicate Response long text. One. - Status200_DuplicateResponseLongText(uuid::Uuid), + Status200_DuplicateResponseLongText + (uuid::Uuid) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum XmlExtraPostResponse { /// OK - Status201_OK, + Status201_OK + , /// Bad Request - Status400_BadRequest, + Status400_BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum XmlOtherPostResponse { /// OK - Status201_OK(String), + Status201_OK + (String) + , /// Bad Request - Status400_BadRequest, + Status400_BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum XmlOtherPutResponse { /// OK - Status201_OK, + Status201_OK + , /// Bad Request - Status400_BadRequest, + Status400_BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum XmlPostResponse { /// OK - Status201_OK, + Status201_OK + , /// Bad Request - Status400_BadRequest, + Status400_BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum XmlPutResponse { /// OK - Status201_OK, + Status201_OK + , /// Bad Request - Status400_BadRequest, + Status400_BadRequest } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateRepoResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetRepoInfoResponse { /// OK - Status200_OK(String), + Status200_OK + (String) } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// AnyOfGet - GET /any-of - async fn any_of_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::AnyOfGetQueryParams, - ) -> Result; - /// CallbackWithHeaderPost - POST /callback-with-header - async fn callback_with_header_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::CallbackWithHeaderPostQueryParams, - ) -> Result; + /// AnyOfGet - GET /any-of + async fn any_of_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::AnyOfGetQueryParams, + ) -> Result; - /// ComplexQueryParamGet - GET /complex-query-param - async fn complex_query_param_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::ComplexQueryParamGetQueryParams, - ) -> Result; - /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} - async fn enum_in_path_path_param_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::EnumInPathPathParamGetPathParams, - ) -> Result; + /// CallbackWithHeaderPost - POST /callback-with-header + async fn callback_with_header_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::CallbackWithHeaderPostQueryParams, + ) -> Result; - /// JsonComplexQueryParamGet - GET /json-complex-query-param - async fn json_complex_query_param_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::JsonComplexQueryParamGetQueryParams, - ) -> Result; - /// MandatoryRequestHeaderGet - GET /mandatory-request-header - async fn mandatory_request_header_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::MandatoryRequestHeaderGetHeaderParams, - ) -> Result; + /// ComplexQueryParamGet - GET /complex-query-param + async fn complex_query_param_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::ComplexQueryParamGetQueryParams, + ) -> Result; - /// MergePatchJsonGet - GET /merge-patch-json - async fn merge_patch_json_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// Get some stuff.. - /// - /// MultigetGet - GET /multiget - async fn multiget_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} + async fn enum_in_path_path_param_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::EnumInPathPathParamGetPathParams, + ) -> Result; - /// MultipleAuthSchemeGet - GET /multiple_auth_scheme - async fn multiple_auth_scheme_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// OneOfGet - GET /one-of - async fn one_of_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// JsonComplexQueryParamGet - GET /json-complex-query-param + async fn json_complex_query_param_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::JsonComplexQueryParamGetQueryParams, + ) -> Result; - /// OverrideServerGet - GET /override-server - async fn override_server_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// Get some stuff with parameters.. - /// - /// ParamgetGet - GET /paramget - async fn paramget_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::ParamgetGetQueryParams, - ) -> Result; + /// MandatoryRequestHeaderGet - GET /mandatory-request-header + async fn mandatory_request_header_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + header_params: models::MandatoryRequestHeaderGetHeaderParams, + ) -> Result; - /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme - async fn readonly_auth_scheme_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// RegisterCallbackPost - POST /register-callback - async fn register_callback_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::RegisterCallbackPostQueryParams, - ) -> Result; + /// MergePatchJsonGet - GET /merge-patch-json + async fn merge_patch_json_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// RequiredOctetStreamPut - PUT /required_octet_stream - async fn required_octet_stream_put( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; - /// ResponsesWithHeadersGet - GET /responses_with_headers - async fn responses_with_headers_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// Get some stuff.. + /// + /// MultigetGet - GET /multiget + async fn multiget_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// Rfc7807Get - GET /rfc7807 - async fn rfc7807_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// UntypedPropertyGet - GET /untyped_property - async fn untyped_property_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, - ) -> Result; + /// MultipleAuthSchemeGet - GET /multiple_auth_scheme + async fn multiple_auth_scheme_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// UuidGet - GET /uuid - async fn uuid_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// XmlExtraPost - POST /xml_extra - async fn xml_extra_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; + /// OneOfGet - GET /one-of + async fn one_of_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// XmlOtherPost - POST /xml_other - async fn xml_other_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; - /// XmlOtherPut - PUT /xml_other - async fn xml_other_put( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; + /// OverrideServerGet - GET /override-server + async fn override_server_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// Post an array. - /// - /// XmlPost - POST /xml - async fn xml_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; - /// XmlPut - PUT /xml - async fn xml_put( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Bytes, - ) -> Result; + /// Get some stuff with parameters.. + /// + /// ParamgetGet - GET /paramget + async fn paramget_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::ParamgetGetQueryParams, + ) -> Result; - /// CreateRepo - POST /repos - async fn create_repo( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::ObjectParam, - ) -> Result; - /// GetRepoInfo - GET /repos/{repoId} - async fn get_repo_info( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetRepoInfoPathParams, - ) -> Result; + /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme + async fn readonly_auth_scheme_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// RegisterCallbackPost - POST /register-callback + async fn register_callback_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::RegisterCallbackPostQueryParams, + ) -> Result; + + + /// RequiredOctetStreamPut - PUT /required_octet_stream + async fn required_octet_stream_put( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// ResponsesWithHeadersGet - GET /responses_with_headers + async fn responses_with_headers_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Rfc7807Get - GET /rfc7807 + async fn rfc7807_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// UntypedPropertyGet - GET /untyped_property + async fn untyped_property_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Option, + ) -> Result; + + + /// UuidGet - GET /uuid + async fn uuid_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// XmlExtraPost - POST /xml_extra + async fn xml_extra_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// XmlOtherPost - POST /xml_other + async fn xml_other_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// XmlOtherPut - PUT /xml_other + async fn xml_other_put( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// Post an array. + /// + /// XmlPost - POST /xml + async fn xml_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// XmlPut - PUT /xml + async fn xml_put( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Bytes, + ) -> Result; + + + /// CreateRepo - POST /repos + async fn create_repo( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::ObjectParam, + ) -> Result; + + + /// GetRepoInfo - GET /repos/{repoId} + async fn get_repo_info( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetRepoInfoPathParams, + ) -> Result; + } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs index 9c95d11a9e3d..cfa2394362e3 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs @@ -7,80 +7,113 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct AnyOfGetQueryParams { - /// list of any of objects - #[serde(rename = "any-of")] - #[validate(length(min = 1))] - #[serde(skip_serializing_if = "Option::is_none")] - pub any_of: Option>, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct AnyOfGetQueryParams { + /// list of any of objects + #[serde(rename = "any-of")] + #[validate( + length(min = 1), + )] + #[serde(skip_serializing_if="Option::is_none")] + pub any_of: Option>, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct CallbackWithHeaderPostQueryParams { - #[serde(rename = "url")] - pub url: String, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct CallbackWithHeaderPostQueryParams { + #[serde(rename = "url")] + pub url: String, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct ComplexQueryParamGetQueryParams { - #[serde(rename = "list-of-strings")] - #[serde(skip_serializing_if = "Option::is_none")] - pub list_of_strings: Option>, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct ComplexQueryParamGetQueryParams { + #[serde(rename = "list-of-strings")] + #[serde(skip_serializing_if="Option::is_none")] + pub list_of_strings: Option>, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct EnumInPathPathParamGetPathParams { - pub path_param: models::StringEnum, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct EnumInPathPathParamGetPathParams { + pub path_param: models::StringEnum, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct JsonComplexQueryParamGetQueryParams { - #[serde(rename = "list-of-strings")] - #[serde(skip_serializing_if = "Option::is_none")] - pub list_of_strings: Option>, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct MandatoryRequestHeaderGetHeaderParams { - pub x_header: String, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct JsonComplexQueryParamGetQueryParams { + #[serde(rename = "list-of-strings")] + #[serde(skip_serializing_if="Option::is_none")] + pub list_of_strings: Option>, + } + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct MandatoryRequestHeaderGetHeaderParams { + pub x_header: String, + } + + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct ParamgetGetQueryParams { + /// The stuff to get + #[serde(rename = "uuid")] + #[serde(skip_serializing_if="Option::is_none")] + pub uuid: Option, + /// Some object to pass as query parameter + #[serde(rename = "someObject")] + #[serde(skip_serializing_if="Option::is_none")] + pub some_object: Option, + /// Some list to pass as query parameter + #[serde(rename = "someList")] + #[serde(skip_serializing_if="Option::is_none")] + pub some_list: Option>, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct RegisterCallbackPostQueryParams { + #[serde(rename = "url")] + pub url: String, + } + + + + + + + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetRepoInfoPathParams { + pub repo_id: String, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct ParamgetGetQueryParams { - /// The stuff to get - #[serde(rename = "uuid")] - #[serde(skip_serializing_if = "Option::is_none")] - pub uuid: Option, - /// Some object to pass as query parameter - #[serde(rename = "someObject")] - #[serde(skip_serializing_if = "Option::is_none")] - pub some_object: Option, - /// Some list to pass as query parameter - #[serde(rename = "someList")] - #[serde(skip_serializing_if = "Option::is_none")] - pub some_list: Option>, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct RegisterCallbackPostQueryParams { - #[serde(rename = "url")] - pub url: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetRepoInfoPathParams { - pub repo_id: String, -} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -92,17 +125,13 @@ impl validator::Validate for AdditionalPropertiesWithList { } } -impl std::convert::From>> - for AdditionalPropertiesWithList -{ +impl std::convert::From>> for AdditionalPropertiesWithList { fn from(x: std::collections::HashMap>) -> Self { AdditionalPropertiesWithList(x) } } -impl std::convert::From - for std::collections::HashMap> -{ +impl std::convert::From for std::collections::HashMap> { fn from(x: AdditionalPropertiesWithList) -> Self { x.0 } @@ -138,12 +167,11 @@ impl ::std::str::FromStr for AdditionalPropertiesWithList { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err( - "Parsing additionalProperties for AdditionalPropertiesWithList is not supported", - ) + std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesWithList is not supported") } } + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnotherXmlArray(Vec); @@ -167,7 +195,7 @@ impl std::convert::From for Vec { } impl std::iter::FromIterator for AnotherXmlArray { - fn from_iter>(u: U) -> Self { + fn from_iter>(u: U) -> Self { AnotherXmlArray(Vec::::from_iter(u)) } } @@ -217,10 +245,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::>() - .join(",") + self.iter().map(|x| x.to_string()).collect::>().join(",") } } @@ -232,29 +257,28 @@ impl std::str::FromStr for AnotherXmlArray { fn from_str(s: &str) -> std::result::Result { let mut items = vec![]; - for item in s.split(',') { + for item in s.split(',') + { items.push(item.parse()?); } std::result::Result::Ok(AnotherXmlArray(items)) } } + // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AnotherXmlArray - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnotherXmlArray - value: {} is invalid {}", + hdr_value, e)) } } } @@ -265,25 +289,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlArray - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AnotherXmlArray - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnotherXmlInner(String); @@ -302,7 +325,7 @@ impl std::convert::From for AnotherXmlInner { impl std::string::ToString for AnotherXmlInner { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -332,20 +355,28 @@ impl std::ops::DerefMut for AnotherXmlInner { } } + + /// An XML object + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnotherXmlObject { #[serde(rename = "inner_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub inner_string: Option, + } + impl AnotherXmlObject { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> AnotherXmlObject { - AnotherXmlObject { inner_string: None } + AnotherXmlObject { + inner_string: None, + } } } @@ -354,10 +385,16 @@ impl AnotherXmlObject { /// Should be implemented in a serde serializer impl std::string::ToString for AnotherXmlObject { fn to_string(&self) -> String { - let params: Vec> = vec![self - .inner_string - .as_ref() - .map(|inner_string| ["inner_string".to_string(), inner_string.to_string()].join(","))]; + let params: Vec> = vec![ + + self.inner_string.as_ref().map(|inner_string| { + [ + "inner_string".to_string(), + inner_string.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -386,25 +423,15 @@ impl std::str::FromStr for AnotherXmlObject { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing AnotherXmlObject".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing AnotherXmlObject".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "inner_string" => intermediate_rep.inner_string.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing AnotherXmlObject".to_string(), - ) - } + "inner_string" => intermediate_rep.inner_string.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing AnotherXmlObject".to_string()) } } @@ -425,16 +452,13 @@ impl std::str::FromStr for AnotherXmlObject { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AnotherXmlObject - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnotherXmlObject - value: {} is invalid {}", + hdr_value, e)) } } } @@ -445,32 +469,33 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlObject - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AnotherXmlObject - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + /// Any of: /// - String /// - uuid::Uuid #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct AnyOfGet202Response(Box); -impl validator::Validate for AnyOfGet202Response { +impl validator::Validate for AnyOfGet202Response +{ fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> { std::result::Result::Ok(()) } @@ -493,6 +518,11 @@ impl PartialEq for AnyOfGet202Response { } } + + + + + /// Test a model containing an anyOf /// Any of: @@ -500,7 +530,8 @@ impl PartialEq for AnyOfGet202Response { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct AnyOfObject(Box); -impl validator::Validate for AnyOfObject { +impl validator::Validate for AnyOfObject +{ fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> { std::result::Result::Ok(()) } @@ -523,8 +554,15 @@ impl PartialEq for AnyOfObject { } } + + + + + /// Test containing an anyOf object + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnyOfProperty { @@ -532,13 +570,15 @@ pub struct AnyOfProperty { pub required_any_of: models::AnyOfObject, #[serde(rename = "optionalAnyOf")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub optional_any_of: Option, + } + impl AnyOfProperty { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_any_of: models::AnyOfObject) -> AnyOfProperty { + pub fn new(required_any_of: models::AnyOfObject, ) -> AnyOfProperty { AnyOfProperty { required_any_of, optional_any_of: None, @@ -586,31 +626,17 @@ impl std::str::FromStr for AnyOfProperty { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing AnyOfProperty".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing AnyOfProperty".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "requiredAnyOf" => intermediate_rep.required_any_of.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), + "requiredAnyOf" => intermediate_rep.required_any_of.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "optionalAnyOf" => intermediate_rep.optional_any_of.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing AnyOfProperty".to_string(), - ) - } + "optionalAnyOf" => intermediate_rep.optional_any_of.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing AnyOfProperty".to_string()) } } @@ -620,11 +646,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_else(|| "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(), }) } @@ -636,16 +658,13 @@ impl std::str::FromStr for AnyOfProperty { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AnyOfProperty - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnyOfProperty - value: {} is invalid {}", + hdr_value, e)) } } } @@ -656,41 +675,44 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfProperty - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AnyOfProperty - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// An XML object + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DuplicateXmlObject { #[serde(rename = "inner_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub inner_string: Option, #[serde(rename = "inner_array")] pub inner_array: models::XmlArray, + } + impl DuplicateXmlObject { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(inner_array: models::XmlArray) -> DuplicateXmlObject { + pub fn new(inner_array: models::XmlArray, ) -> DuplicateXmlObject { DuplicateXmlObject { inner_string: None, inner_array, @@ -704,10 +726,16 @@ impl DuplicateXmlObject { impl std::string::ToString for DuplicateXmlObject { fn to_string(&self) -> String { let params: Vec> = vec![ + self.inner_string.as_ref().map(|inner_string| { - ["inner_string".to_string(), inner_string.to_string()].join(",") + [ + "inner_string".to_string(), + inner_string.to_string(), + ].join(",") }), + // Skipping inner_array in query parameter serialization + ]; params.into_iter().flatten().collect::>().join(",") @@ -738,30 +766,17 @@ impl std::str::FromStr for DuplicateXmlObject { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing DuplicateXmlObject".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing DuplicateXmlObject".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "inner_string" => intermediate_rep.inner_string.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "inner_string" => intermediate_rep.inner_string.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "inner_array" => intermediate_rep.inner_array.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing DuplicateXmlObject".to_string(), - ) - } + "inner_array" => intermediate_rep.inner_array.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing DuplicateXmlObject".to_string()) } } @@ -772,11 +787,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_else(|| "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())?, }) } } @@ -787,16 +798,13 @@ impl std::str::FromStr for DuplicateXmlObject { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for DuplicateXmlObject - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for DuplicateXmlObject - value: {} is invalid {}", + hdr_value, e)) } } } @@ -807,34 +815,31 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into DuplicateXmlObject - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into DuplicateXmlObject - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Test a model containing a special character in the enum /// Enumeration of values. /// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` /// which helps with FFI. #[allow(non_camel_case_types)] #[repr(C)] -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] pub enum EnumWithStarObject { #[serde(rename = "FOO")] @@ -868,6 +873,7 @@ impl std::str::FromStr for EnumWithStarObject { } } + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Err(String); @@ -886,7 +892,7 @@ impl std::convert::From for Err { impl std::string::ToString for Err { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -916,6 +922,8 @@ impl std::ops::DerefMut for Err { } } + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Error(String); @@ -934,7 +942,7 @@ impl std::convert::From for Error { impl std::string::ToString for Error { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -964,6 +972,8 @@ impl std::ops::DerefMut for Error { } } + + /// Test a model containing an anyOf that starts with a number /// Any of: @@ -971,7 +981,8 @@ impl std::ops::DerefMut for Error { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct Model12345AnyOfObject(Box); -impl validator::Validate for Model12345AnyOfObject { +impl validator::Validate for Model12345AnyOfObject +{ fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> { std::result::Result::Ok(()) } @@ -994,18 +1005,30 @@ impl PartialEq for Model12345AnyOfObject { } } + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultigetGet201Response { #[serde(rename = "foo")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub foo: Option, + } + impl MultigetGet201Response { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> MultigetGet201Response { - MultigetGet201Response { foo: None } + MultigetGet201Response { + foo: None, + } } } @@ -1014,10 +1037,16 @@ impl MultigetGet201Response { /// Should be implemented in a serde serializer impl std::string::ToString for MultigetGet201Response { fn to_string(&self) -> String { - let params: Vec> = vec![self - .foo - .as_ref() - .map(|foo| ["foo".to_string(), foo.to_string()].join(","))]; + let params: Vec> = vec![ + + self.foo.as_ref().map(|foo| { + [ + "foo".to_string(), + foo.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -1046,25 +1075,15 @@ impl std::str::FromStr for MultigetGet201Response { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing MultigetGet201Response".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing MultigetGet201Response".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "foo" => intermediate_rep.foo.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing MultigetGet201Response".to_string(), - ) - } + "foo" => intermediate_rep.foo.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing MultigetGet201Response".to_string()) } } @@ -1085,16 +1104,13 @@ impl std::str::FromStr for MultigetGet201Response { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for MultigetGet201Response - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MultigetGet201Response - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1105,25 +1121,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultigetGet201Response - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into MultigetGet201Response - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyId(i32); @@ -1159,6 +1174,8 @@ impl std::ops::DerefMut for MyId { } } + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MyIdList(Vec); @@ -1182,7 +1199,7 @@ impl std::convert::From for Vec { } impl std::iter::FromIterator for MyIdList { - fn from_iter>(u: U) -> Self { + fn from_iter>(u: U) -> Self { MyIdList(Vec::::from_iter(u)) } } @@ -1232,10 +1249,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::>() - .join(",") + self.iter().map(|x| x.to_string()).collect::>().join(",") } } @@ -1247,29 +1261,28 @@ impl std::str::FromStr for MyIdList { fn from_str(s: &str) -> std::result::Result { let mut items = vec![]; - for item in s.split(',') { + for item in s.split(',') + { items.push(item.parse()?); } std::result::Result::Ok(MyIdList(items)) } } + // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for MyIdList - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MyIdList - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1280,25 +1293,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MyIdList - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into MyIdList - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NullableTest { @@ -1308,46 +1323,54 @@ pub struct NullableTest { #[serde(rename = "nullableWithNullDefault")] #[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(default = "default_optional_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub nullable_with_null_default: Option>, #[serde(rename = "nullableWithPresentDefault")] #[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(default = "default_optional_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub nullable_with_present_default: Option>, #[serde(rename = "nullableWithNoDefault")] #[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(default = "default_optional_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub nullable_with_no_default: Option>, #[serde(rename = "nullableArray")] #[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(default = "default_optional_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub nullable_array: Option>>, #[serde(rename = "min_item_test")] - #[validate(length(min = 1))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + length(min = 1), + )] + #[serde(skip_serializing_if="Option::is_none")] pub min_item_test: Option>, #[serde(rename = "max_item_test")] - #[validate(length(max = 2))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + length(max = 2), + )] + #[serde(skip_serializing_if="Option::is_none")] pub max_item_test: Option>, #[serde(rename = "min_max_item_test")] - #[validate(length(min = 1, max = 3))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + length(min = 1, max = 3), + )] + #[serde(skip_serializing_if="Option::is_none")] pub min_max_item_test: Option>, + } + impl NullableTest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(nullable: Nullable) -> NullableTest { + pub fn new(nullable: Nullable, ) -> NullableTest { NullableTest { nullable, nullable_with_null_default: None, @@ -1367,90 +1390,66 @@ impl NullableTest { impl std::string::ToString for NullableTest { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("nullable".to_string()), - Some( - self.nullable - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ), - self.nullable_with_null_default - .as_ref() - .map(|nullable_with_null_default| { - [ - "nullableWithNullDefault".to_string(), - nullable_with_null_default - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ] - .join(",") - }), - self.nullable_with_present_default - .as_ref() - .map(|nullable_with_present_default| { - [ - "nullableWithPresentDefault".to_string(), - nullable_with_present_default - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ] - .join(",") - }), - self.nullable_with_no_default - .as_ref() - .map(|nullable_with_no_default| { - [ - "nullableWithNoDefault".to_string(), - nullable_with_no_default - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ] - .join(",") - }), + Some(self.nullable.as_ref().map_or("null".to_string(), |x| x.to_string())), + + + self.nullable_with_null_default.as_ref().map(|nullable_with_null_default| { + [ + "nullableWithNullDefault".to_string(), + nullable_with_null_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), + + + self.nullable_with_present_default.as_ref().map(|nullable_with_present_default| { + [ + "nullableWithPresentDefault".to_string(), + nullable_with_present_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), + + + self.nullable_with_no_default.as_ref().map(|nullable_with_no_default| { + [ + "nullableWithNoDefault".to_string(), + nullable_with_no_default.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") + }), + + self.nullable_array.as_ref().map(|nullable_array| { [ "nullableArray".to_string(), - nullable_array.as_ref().map_or("null".to_string(), |x| { - x.iter() - .map(|x| x.to_string()) - .collect::>() - .join(",") - }), - ] - .join(",") + nullable_array.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::>().join(",")), + ].join(",") }), + + self.min_item_test.as_ref().map(|min_item_test| { [ "min_item_test".to_string(), - min_item_test - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + min_item_test.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + + self.max_item_test.as_ref().map(|max_item_test| { [ "max_item_test".to_string(), - max_item_test - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + max_item_test.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + + self.min_max_item_test.as_ref().map(|min_max_item_test| { [ "min_max_item_test".to_string(), - min_max_item_test - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + min_max_item_test.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1487,61 +1486,21 @@ impl std::str::FromStr for NullableTest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing NullableTest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing NullableTest".to_string()) }; 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(), - ), - "nullableWithPresentDefault" => return std::result::Result::Err( - "Parsing a nullable type in this style is not supported in NullableTest" - .to_string(), - ), - "nullableWithNoDefault" => return std::result::Result::Err( - "Parsing a nullable type in this style is not supported in NullableTest" - .to_string(), - ), - "nullableArray" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in NullableTest" - .to_string(), - ) - } - "min_item_test" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in NullableTest" - .to_string(), - ) - } - "max_item_test" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in NullableTest" - .to_string(), - ) - } - "min_max_item_test" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in NullableTest" - .to_string(), - ) - } - _ => { - return std::result::Result::Err( - "Unexpected key while parsing NullableTest".to_string(), - ) - } + "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()), + "nullableWithPresentDefault" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in NullableTest".to_string()), + "nullableWithNoDefault" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in NullableTest".to_string()), + "nullableArray" => return std::result::Result::Err("Parsing a container in this style is not supported in NullableTest".to_string()), + "min_item_test" => return std::result::Result::Err("Parsing a container in this style is not supported in NullableTest".to_string()), + "max_item_test" => return std::result::Result::Err("Parsing a container in this style is not supported in NullableTest".to_string()), + "min_max_item_test" => return std::result::Result::Err("Parsing a container in this style is not supported in NullableTest".to_string()), + _ => return std::result::Result::Err("Unexpected key while parsing NullableTest".to_string()) } } @@ -1551,21 +1510,11 @@ impl std::str::FromStr for NullableTest { // Use the intermediate representation to return the struct std::result::Result::Ok(NullableTest { - nullable: std::result::Result::Err( - "Nullable types not supported in NullableTest".to_string(), - )?, - nullable_with_null_default: std::result::Result::Err( - "Nullable types not supported in NullableTest".to_string(), - )?, - nullable_with_present_default: std::result::Result::Err( - "Nullable types not supported in NullableTest".to_string(), - )?, - nullable_with_no_default: std::result::Result::Err( - "Nullable types not supported in NullableTest".to_string(), - )?, - nullable_array: std::result::Result::Err( - "Nullable types not supported in NullableTest".to_string(), - )?, + nullable: std::result::Result::Err("Nullable types not supported in NullableTest".to_string())?, + nullable_with_null_default: std::result::Result::Err("Nullable types not supported in NullableTest".to_string())?, + nullable_with_present_default: std::result::Result::Err("Nullable types not supported in NullableTest".to_string())?, + nullable_with_no_default: std::result::Result::Err("Nullable types not supported in NullableTest".to_string())?, + nullable_array: std::result::Result::Err("Nullable types not supported in NullableTest".to_string())?, min_item_test: intermediate_rep.min_item_test.into_iter().next(), max_item_test: intermediate_rep.max_item_test.into_iter().next(), min_max_item_test: intermediate_rep.min_max_item_test.into_iter().next(), @@ -1579,16 +1528,13 @@ impl std::str::FromStr for NullableTest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for NullableTest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for NullableTest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1599,25 +1545,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into NullableTest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into NullableTest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectHeader { @@ -1625,13 +1573,15 @@ pub struct ObjectHeader { pub required_object_header: bool, #[serde(rename = "optionalObjectHeader")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub optional_object_header: Option, + } + impl ObjectHeader { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_object_header: bool) -> ObjectHeader { + pub fn new(required_object_header: bool, ) -> ObjectHeader { ObjectHeader { required_object_header, optional_object_header: None, @@ -1645,17 +1595,18 @@ impl ObjectHeader { impl std::string::ToString for ObjectHeader { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("requiredObjectHeader".to_string()), Some(self.required_object_header.to_string()), - self.optional_object_header - .as_ref() - .map(|optional_object_header| { - [ - "optionalObjectHeader".to_string(), - optional_object_header.to_string(), - ] - .join(",") - }), + + + self.optional_object_header.as_ref().map(|optional_object_header| { + [ + "optionalObjectHeader".to_string(), + optional_object_header.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1686,29 +1637,17 @@ impl std::str::FromStr for ObjectHeader { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectHeader".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectHeader".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "requiredObjectHeader" => intermediate_rep.required_object_header.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "requiredObjectHeader" => intermediate_rep.required_object_header.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "optionalObjectHeader" => intermediate_rep.optional_object_header.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ObjectHeader".to_string(), - ) - } + "optionalObjectHeader" => intermediate_rep.optional_object_header.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ObjectHeader".to_string()) } } @@ -1718,11 +1657,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_else(|| "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(), }) } @@ -1734,16 +1669,13 @@ impl std::str::FromStr for ObjectHeader { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectHeader - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectHeader - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1754,25 +1686,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectHeader - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectHeader - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectParam { @@ -1780,13 +1714,15 @@ pub struct ObjectParam { pub required_param: bool, #[serde(rename = "optionalParam")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub optional_param: Option, + } + impl ObjectParam { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_param: bool) -> ObjectParam { + pub fn new(required_param: bool, ) -> ObjectParam { ObjectParam { required_param, optional_param: None, @@ -1800,11 +1736,18 @@ impl ObjectParam { impl std::string::ToString for ObjectParam { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("requiredParam".to_string()), Some(self.required_param.to_string()), + + self.optional_param.as_ref().map(|optional_param| { - ["optionalParam".to_string(), optional_param.to_string()].join(",") + [ + "optionalParam".to_string(), + optional_param.to_string(), + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1835,29 +1778,17 @@ impl std::str::FromStr for ObjectParam { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectParam".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectParam".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "requiredParam" => intermediate_rep.required_param.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "requiredParam" => intermediate_rep.required_param.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "optionalParam" => intermediate_rep.optional_param.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ObjectParam".to_string(), - ) - } + "optionalParam" => intermediate_rep.optional_param.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ObjectParam".to_string()) } } @@ -1867,11 +1798,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_else(|| "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(), }) } @@ -1883,16 +1810,13 @@ impl std::str::FromStr for ObjectParam { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectParam - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectParam - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1903,25 +1827,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectParam - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectParam - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectUntypedProps { @@ -1932,20 +1858,19 @@ pub struct ObjectUntypedProps { pub required_untyped_nullable: Nullable, #[serde(rename = "not_required_untyped")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub not_required_untyped: Option, #[serde(rename = "not_required_untyped_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub not_required_untyped_nullable: Option, + } + impl ObjectUntypedProps { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new( - required_untyped: crate::types::Object, - required_untyped_nullable: Nullable, - ) -> ObjectUntypedProps { + pub fn new(required_untyped: crate::types::Object, required_untyped_nullable: Nullable, ) -> ObjectUntypedProps { ObjectUntypedProps { required_untyped, required_untyped_nullable, @@ -2001,11 +1926,7 @@ impl std::str::FromStr for ObjectUntypedProps { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectUntypedProps".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectUntypedProps".to_string()) }; if let Some(key) = key_result { @@ -2028,19 +1949,10 @@ 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_else(|| "required_untyped missing in ObjectUntypedProps".to_string())?, - required_untyped_nullable: std::result::Result::Err( - "Nullable types not supported 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(), + not_required_untyped_nullable: intermediate_rep.not_required_untyped_nullable.into_iter().next(), }) } } @@ -2051,16 +1963,13 @@ impl std::str::FromStr for ObjectUntypedProps { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectUntypedProps - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectUntypedProps - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2071,37 +1980,43 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectUntypedProps - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectUntypedProps - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithArrayOfObjects { #[serde(rename = "objectArray")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub object_array: Option>, + } + impl ObjectWithArrayOfObjects { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ObjectWithArrayOfObjects { - ObjectWithArrayOfObjects { object_array: None } + ObjectWithArrayOfObjects { + object_array: None, + } } } @@ -2110,17 +2025,16 @@ impl ObjectWithArrayOfObjects { /// Should be implemented in a serde serializer impl std::string::ToString for ObjectWithArrayOfObjects { fn to_string(&self) -> String { - let params: Vec> = vec![self.object_array.as_ref().map(|object_array| { - [ - "objectArray".to_string(), - object_array - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") - })]; + let params: Vec> = vec![ + + self.object_array.as_ref().map(|object_array| { + [ + "objectArray".to_string(), + object_array.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -2149,11 +2063,7 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectWithArrayOfObjects".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectWithArrayOfObjects".to_string()) }; if let Some(key) = key_result { @@ -2181,16 +2091,13 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectWithArrayOfObjects - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectWithArrayOfObjects - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2201,25 +2108,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectWithArrayOfObjects - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectWithArrayOfObjects - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Ok(String); @@ -2238,7 +2144,7 @@ impl std::convert::From for Ok { impl std::string::ToString for Ok { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -2268,13 +2174,18 @@ impl std::ops::DerefMut for Ok { } } + + + + /// One of: /// - Vec /// - i32 #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct OneOfGet200Response(Box); -impl validator::Validate for OneOfGet200Response { +impl validator::Validate for OneOfGet200Response +{ fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> { std::result::Result::Ok(()) } @@ -2297,6 +2208,10 @@ impl PartialEq for OneOfGet200Response { } } + + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OptionalObjectHeader(i32); @@ -2332,6 +2247,8 @@ impl std::ops::DerefMut for OptionalObjectHeader { } } + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct RequiredObjectHeader(bool); @@ -2367,6 +2284,8 @@ impl std::ops::DerefMut for RequiredObjectHeader { } } + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Result(String); @@ -2385,7 +2304,7 @@ impl std::convert::From for Result { impl std::string::ToString for Result { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -2415,14 +2334,14 @@ impl std::ops::DerefMut for Result { } } + + /// Enumeration of values. /// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` /// which helps with FFI. #[allow(non_camel_case_types)] #[repr(C)] -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] pub enum StringEnum { #[serde(rename = "FOO")] @@ -2452,6 +2371,7 @@ impl std::str::FromStr for StringEnum { } } + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct StringObject(String); @@ -2470,7 +2390,7 @@ impl std::convert::From for StringObject { impl std::string::ToString for StringObject { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -2500,6 +2420,8 @@ impl std::ops::DerefMut for StringObject { } } + + /// Test a model containing a UUID #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -2536,6 +2458,8 @@ impl std::ops::DerefMut for UuidObject { } } + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct XmlArray(Vec); @@ -2559,7 +2483,7 @@ impl std::convert::From for Vec { } impl std::iter::FromIterator for XmlArray { - fn from_iter>(u: U) -> Self { + fn from_iter>(u: U) -> Self { XmlArray(Vec::::from_iter(u)) } } @@ -2609,10 +2533,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::>() - .join(",") + self.iter().map(|x| x.to_string()).collect::>().join(",") } } @@ -2624,29 +2545,28 @@ impl std::str::FromStr for XmlArray { fn from_str(s: &str) -> std::result::Result { let mut items = vec![]; - for item in s.split(',') { + for item in s.split(',') + { items.push(item.parse()?); } std::result::Result::Ok(XmlArray(items)) } } + // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for XmlArray - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for XmlArray - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2657,25 +2577,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlArray - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into XmlArray - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct XmlInner(String); @@ -2694,7 +2613,7 @@ impl std::convert::From for XmlInner { impl std::string::ToString for XmlInner { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -2724,20 +2643,26 @@ impl std::ops::DerefMut for XmlInner { } } + + /// An XML object + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct XmlObject { #[serde(rename = "innerString")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub inner_string: Option, #[serde(rename = "other_inner_rename")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub other_inner_rename: Option, + } + impl XmlObject { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> XmlObject { @@ -2754,16 +2679,22 @@ impl XmlObject { impl std::string::ToString for XmlObject { fn to_string(&self) -> String { let params: Vec> = vec![ + self.inner_string.as_ref().map(|inner_string| { - ["innerString".to_string(), inner_string.to_string()].join(",") + [ + "innerString".to_string(), + inner_string.to_string(), + ].join(",") }), + + self.other_inner_rename.as_ref().map(|other_inner_rename| { [ "other_inner_rename".to_string(), other_inner_rename.to_string(), - ] - .join(",") + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -2794,29 +2725,17 @@ impl std::str::FromStr for XmlObject { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing XmlObject".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing XmlObject".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "innerString" => intermediate_rep.inner_string.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "innerString" => intermediate_rep.inner_string.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "other_inner_rename" => intermediate_rep.other_inner_rename.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing XmlObject".to_string(), - ) - } + "other_inner_rename" => intermediate_rep.other_inner_rename.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing XmlObject".to_string()) } } @@ -2838,16 +2757,13 @@ impl std::str::FromStr for XmlObject { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for XmlObject - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for XmlObject - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2858,21 +2774,20 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlObject - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into XmlObject - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index b471568f253c..eea66d5a3dd7 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -12,15 +12,33 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{ - AnyOfGetResponse, Api, CallbackWithHeaderPostResponse, ComplexQueryParamGetResponse, - CreateRepoResponse, EnumInPathPathParamGetResponse, GetRepoInfoResponse, - JsonComplexQueryParamGetResponse, MandatoryRequestHeaderGetResponse, MergePatchJsonGetResponse, - MultigetGetResponse, MultipleAuthSchemeGetResponse, OneOfGetResponse, - OverrideServerGetResponse, ParamgetGetResponse, ReadonlyAuthSchemeGetResponse, - RegisterCallbackPostResponse, RequiredOctetStreamPutResponse, ResponsesWithHeadersGetResponse, - Rfc7807GetResponse, UntypedPropertyGetResponse, UuidGetResponse, XmlExtraPostResponse, - XmlOtherPostResponse, XmlOtherPutResponse, XmlPostResponse, XmlPutResponse, +use crate::{Api, + AnyOfGetResponse, + CallbackWithHeaderPostResponse, + ComplexQueryParamGetResponse, + EnumInPathPathParamGetResponse, + JsonComplexQueryParamGetResponse, + MandatoryRequestHeaderGetResponse, + MergePatchJsonGetResponse, + MultigetGetResponse, + MultipleAuthSchemeGetResponse, + OneOfGetResponse, + OverrideServerGetResponse, + ParamgetGetResponse, + ReadonlyAuthSchemeGetResponse, + RegisterCallbackPostResponse, + RequiredOctetStreamPutResponse, + ResponsesWithHeadersGetResponse, + Rfc7807GetResponse, + UntypedPropertyGetResponse, + UuidGetResponse, + XmlExtraPostResponse, + XmlOtherPostResponse, + XmlOtherPutResponse, + XmlPostResponse, + XmlPutResponse, + CreateRepoResponse, + GetRepoInfoResponse }; /// Setup API Server. @@ -31,801 +49,893 @@ where { // build our application with a route Router::new() - .route("/any-of", get(any_of_get::)) - .route( - "/callback-with-header", - post(callback_with_header_post::), + .route("/any-of", + get(any_of_get::) ) - .route("/complex-query-param", get(complex_query_param_get::)) - .route( - "/enum_in_path/:path_param", - get(enum_in_path_path_param_get::), + .route("/callback-with-header", + post(callback_with_header_post::) ) - .route( - "/json-complex-query-param", - get(json_complex_query_param_get::), + .route("/complex-query-param", + get(complex_query_param_get::) ) - .route( - "/mandatory-request-header", - get(mandatory_request_header_get::), + .route("/enum_in_path/:path_param", + get(enum_in_path_path_param_get::) ) - .route("/merge-patch-json", get(merge_patch_json_get::)) - .route("/multiget", get(multiget_get::)) - .route( - "/multiple_auth_scheme", - get(multiple_auth_scheme_get::), + .route("/json-complex-query-param", + get(json_complex_query_param_get::) ) - .route("/one-of", get(one_of_get::)) - .route("/override-server", get(override_server_get::)) - .route("/paramget", get(paramget_get::)) - .route( - "/readonly_auth_scheme", - get(readonly_auth_scheme_get::), + .route("/mandatory-request-header", + get(mandatory_request_header_get::) ) - .route("/register-callback", post(register_callback_post::)) - .route("/repos", post(create_repo::)) - .route( - "/repos/:repo_id", - get(get_repo_info::).get(get_repo_info::), + .route("/merge-patch-json", + get(merge_patch_json_get::) ) - .route( - "/required_octet_stream", - put(required_octet_stream_put::), + .route("/multiget", + get(multiget_get::) ) - .route( - "/responses_with_headers", - get(responses_with_headers_get::), + .route("/multiple_auth_scheme", + get(multiple_auth_scheme_get::) ) - .route("/rfc7807", get(rfc7807_get::)) - .route("/untyped_property", get(untyped_property_get::)) - .route("/uuid", get(uuid_get::)) - .route("/xml", post(xml_post::).put(xml_put::)) - .route("/xml_extra", post(xml_extra_post::)) - .route( - "/xml_other", - post(xml_other_post::).put(xml_other_put::), + .route("/one-of", + get(one_of_get::) + ) + .route("/override-server", + get(override_server_get::) + ) + .route("/paramget", + get(paramget_get::) + ) + .route("/readonly_auth_scheme", + get(readonly_auth_scheme_get::) + ) + .route("/register-callback", + post(register_callback_post::) + ) + .route("/repos", + post(create_repo::) + ) + .route("/repos/:repo_id", + get(get_repo_info::).get(get_repo_info::) + ) + .route("/required_octet_stream", + put(required_octet_stream_put::) + ) + .route("/responses_with_headers", + get(responses_with_headers_get::) + ) + .route("/rfc7807", + get(rfc7807_get::) + ) + .route("/untyped_property", + get(untyped_property_get::) + ) + .route("/uuid", + get(uuid_get::) + ) + .route("/xml", + post(xml_post::).put(xml_put::) + ) + .route("/xml_extra", + post(xml_extra_post::) + ) + .route("/xml_other", + post(xml_other_post::).put(xml_other_put::) ) .with_state(api_impl) } + #[tracing::instrument(skip_all)] fn any_of_get_validation( - query_params: models::AnyOfGetQueryParams, -) -> std::result::Result<(models::AnyOfGetQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::AnyOfGetQueryParams, +) -> std::result::Result<( + models::AnyOfGetQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// AnyOfGet - GET /any-of #[tracing::instrument(skip_all)] async fn any_of_get( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = any_of_get_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + any_of_get_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .any_of_get(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().any_of_get( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - AnyOfGetResponse::Status200_Success(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + AnyOfGetResponse::Status200_Success + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - AnyOfGetResponse::Status201_AlternateSuccess(body) => { - let mut response = response.status(201); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - AnyOfGetResponse::Status202_AnyOfSuccess(body) => { - let mut response = response.status(202); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + AnyOfGetResponse::Status201_AlternateSuccess + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(201); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + AnyOfGetResponse::Status202_AnyOfSuccess + (body) + => { + + let mut response = response.status(202); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } + + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn callback_with_header_post_validation( - query_params: models::CallbackWithHeaderPostQueryParams, -) -> std::result::Result<(models::CallbackWithHeaderPostQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::CallbackWithHeaderPostQueryParams, +) -> std::result::Result<( + models::CallbackWithHeaderPostQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// CallbackWithHeaderPost - POST /callback-with-header #[tracing::instrument(skip_all)] async fn callback_with_header_post( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = callback_with_header_post_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + callback_with_header_post_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .callback_with_header_post(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().callback_with_header_post( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CallbackWithHeaderPostResponse::Status204_OK => { - let mut response = response.status(204); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CallbackWithHeaderPostResponse::Status204_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(204); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn complex_query_param_get_validation( - query_params: models::ComplexQueryParamGetQueryParams, -) -> std::result::Result<(models::ComplexQueryParamGetQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::ComplexQueryParamGetQueryParams, +) -> std::result::Result<( + models::ComplexQueryParamGetQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// ComplexQueryParamGet - GET /complex-query-param #[tracing::instrument(skip_all)] async fn complex_query_param_get( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = complex_query_param_get_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + complex_query_param_get_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .complex_query_param_get(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().complex_query_param_get( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - ComplexQueryParamGetResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + ComplexQueryParamGetResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn enum_in_path_path_param_get_validation( - path_params: models::EnumInPathPathParamGetPathParams, -) -> std::result::Result<(models::EnumInPathPathParamGetPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::EnumInPathPathParamGetPathParams, +) -> std::result::Result<( + models::EnumInPathPathParamGetPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// EnumInPathPathParamGet - GET /enum_in_path/{path_param} #[tracing::instrument(skip_all)] async fn enum_in_path_path_param_get( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = enum_in_path_path_param_get_validation(path_params); - let Ok((path_params,)) = validation else { - return Response::builder() + let validation = + enum_in_path_path_param_get_validation( + path_params, + ) + ; + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .enum_in_path_path_param_get(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().enum_in_path_path_param_get( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - EnumInPathPathParamGetResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + EnumInPathPathParamGetResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn json_complex_query_param_get_validation( - query_params: models::JsonComplexQueryParamGetQueryParams, -) -> std::result::Result<(models::JsonComplexQueryParamGetQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::JsonComplexQueryParamGetQueryParams, +) -> std::result::Result<( + models::JsonComplexQueryParamGetQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// JsonComplexQueryParamGet - GET /json-complex-query-param #[tracing::instrument(skip_all)] async fn json_complex_query_param_get( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = json_complex_query_param_get_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + json_complex_query_param_get_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .json_complex_query_param_get(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().json_complex_query_param_get( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - JsonComplexQueryParamGetResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + JsonComplexQueryParamGetResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn mandatory_request_header_get_validation( - header_params: models::MandatoryRequestHeaderGetHeaderParams, -) -> std::result::Result<(models::MandatoryRequestHeaderGetHeaderParams,), ValidationErrors> { - header_params.validate()?; + header_params: models::MandatoryRequestHeaderGetHeaderParams, +) -> std::result::Result<( + models::MandatoryRequestHeaderGetHeaderParams, +), ValidationErrors> +{ + header_params.validate()?; - Ok((header_params,)) +Ok(( + header_params, +)) } /// MandatoryRequestHeaderGet - GET /mandatory-request-header #[tracing::instrument(skip_all)] async fn mandatory_request_header_get( - method: Method, - host: Host, - cookies: CookieJar, - headers: HeaderMap, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + headers: HeaderMap, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { // Header parameters let header_params = { - let header_x_header = headers.get(HeaderName::from_static("x-header")); + let header_x_header = headers.get(HeaderName::from_static("x-header")); - let header_x_header = match header_x_header { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { - Ok(result) => result.0, - Err(err) => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Invalid header X-Header - {}", err))) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }, - None => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from("Missing required header X-Header")) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }; + let header_x_header = match header_x_header { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Ok(result) => + result.0, + Err(err) => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header X-Header - {}", err))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - models::MandatoryRequestHeaderGetHeaderParams { - x_header: header_x_header, - } - }; + }, + }, + None => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from("Missing required header X-Header")).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); + } + }; - let validation = mandatory_request_header_get_validation(header_params); + models::MandatoryRequestHeaderGetHeaderParams { + x_header: header_x_header, + } + }; - let Ok((header_params,)) = validation else { - return Response::builder() + + let validation = + mandatory_request_header_get_validation( + header_params, + ) + ; + + let Ok(( + header_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .mandatory_request_header_get(method, host, cookies, header_params) - .await; + let result = api_impl.as_ref().mandatory_request_header_get( + method, + host, + cookies, + header_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MandatoryRequestHeaderGetResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + MandatoryRequestHeaderGetResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn merge_patch_json_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn merge_patch_json_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MergePatchJsonGet - GET /merge-patch-json #[tracing::instrument(skip_all)] async fn merge_patch_json_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = merge_patch_json_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + merge_patch_json_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .merge_patch_json_get(method, host, cookies) - .await; + let result = api_impl.as_ref().merge_patch_json_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MergePatchJsonGetResponse::Status200_Merge(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/merge-patch+json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + MergePatchJsonGetResponse::Status200_Merge + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/merge-patch+json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn multiget_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn multiget_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MultigetGet - GET /multiget #[tracing::instrument(skip_all)] async fn multiget_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = multiget_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + multiget_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().multiget_get(method, host, cookies).await; + let result = api_impl.as_ref().multiget_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - MultigetGetResponse::Status200_JSONRsp(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + MultigetGetResponse::Status200_JSONRsp + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status201_XMLRsp(body) => { - let mut response = response.status(201); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = body; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status202_OctetRsp(body) => { - let mut response = response.status(202); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/octet-stream").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status201_XMLRsp + (body) + => { - let body_content = body.0; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status203_StringRsp(body) => { - let mut response = response.status(203); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(201); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = body; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status204_DuplicateResponseLongText(body) => { - let mut response = response.status(204); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let body_content = body; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status202_OctetRsp + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status205_DuplicateResponseLongText(body) => { - let mut response = response.status(205); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(202); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/octet-stream").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - MultigetGetResponse::Status206_DuplicateResponseLongText(body) => { - let mut response = response.status(206); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let body_content = body.0; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status203_StringRsp + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(203); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status204_DuplicateResponseLongText + (body) + => { + + let mut response = response.status(204); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } + + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status205_DuplicateResponseLongText + (body) + => { + + let mut response = response.status(205); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } + + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + MultigetGetResponse::Status206_DuplicateResponseLongText + (body) + => { + + let mut response = response.status(206); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } + + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn multiple_auth_scheme_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn multiple_auth_scheme_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// MultipleAuthSchemeGet - GET /multiple_auth_scheme #[tracing::instrument(skip_all)] async fn multiple_auth_scheme_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = multiple_auth_scheme_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + multiple_auth_scheme_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .multiple_auth_scheme_get(method, host, cookies) - .await; + let result = api_impl.as_ref().multiple_auth_scheme_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { + let resp = match result { Ok(rsp) => match rsp { MultipleAuthSchemeGetResponse::Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks => { @@ -841,245 +951,281 @@ where }, }; - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn one_of_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn one_of_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// OneOfGet - GET /one-of #[tracing::instrument(skip_all)] async fn one_of_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = one_of_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + one_of_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().one_of_get(method, host, cookies).await; + let result = api_impl.as_ref().one_of_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - OneOfGetResponse::Status200_Success(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + OneOfGetResponse::Status200_Success + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn override_server_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn override_server_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// OverrideServerGet - GET /override-server #[tracing::instrument(skip_all)] async fn override_server_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = override_server_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + override_server_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .override_server_get(method, host, cookies) - .await; + let result = api_impl.as_ref().override_server_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - OverrideServerGetResponse::Status204_Success => { - let mut response = response.status(204); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + OverrideServerGetResponse::Status204_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(204); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn paramget_get_validation( - query_params: models::ParamgetGetQueryParams, -) -> std::result::Result<(models::ParamgetGetQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::ParamgetGetQueryParams, +) -> std::result::Result<( + models::ParamgetGetQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// ParamgetGet - GET /paramget #[tracing::instrument(skip_all)] async fn paramget_get( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = paramget_get_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + paramget_get_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .paramget_get(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().paramget_get( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - ParamgetGetResponse::Status200_JSONRsp(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + ParamgetGetResponse::Status200_JSONRsp + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn readonly_auth_scheme_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn readonly_auth_scheme_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme #[tracing::instrument(skip_all)] async fn readonly_auth_scheme_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = readonly_auth_scheme_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + readonly_auth_scheme_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .readonly_auth_scheme_get(method, host, cookies) - .await; + let result = api_impl.as_ref().readonly_auth_scheme_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { + let resp = match result { Ok(rsp) => match rsp { ReadonlyAuthSchemeGetResponse::Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks => { @@ -1095,1008 +1241,1199 @@ where }, }; - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn register_callback_post_validation( - query_params: models::RegisterCallbackPostQueryParams, -) -> std::result::Result<(models::RegisterCallbackPostQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::RegisterCallbackPostQueryParams, +) -> std::result::Result<( + models::RegisterCallbackPostQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// RegisterCallbackPost - POST /register-callback #[tracing::instrument(skip_all)] async fn register_callback_post( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = register_callback_post_validation(query_params); - let Ok((query_params,)) = validation else { - return Response::builder() + let validation = + register_callback_post_validation( + query_params, + ) + ; + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .register_callback_post(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().register_callback_post( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - RegisterCallbackPostResponse::Status204_OK => { - let mut response = response.status(204); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + RegisterCallbackPostResponse::Status204_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(204); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct RequiredOctetStreamPutBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct RequiredOctetStreamPutBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] fn required_octet_stream_put_validation( - body: Bytes, -) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// RequiredOctetStreamPut - PUT /required_octet_stream #[tracing::instrument(skip_all)] async fn required_octet_stream_put( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = required_octet_stream_put_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + required_octet_stream_put_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .required_octet_stream_put(method, host, cookies, body) - .await; + let result = api_impl.as_ref().required_octet_stream_put( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - RequiredOctetStreamPutResponse::Status200_OK => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + RequiredOctetStreamPutResponse::Status200_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn responses_with_headers_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn responses_with_headers_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// ResponsesWithHeadersGet - GET /responses_with_headers #[tracing::instrument(skip_all)] async fn responses_with_headers_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = responses_with_headers_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + responses_with_headers_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .responses_with_headers_get(method, host, cookies) - .await; + let result = api_impl.as_ref().responses_with_headers_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - ResponsesWithHeadersGetResponse::Status200_Success { - body, - success_info, - bool_header, - object_header, - } => { - let success_info = match header::IntoHeaderValue(success_info).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + let resp = match result { + Ok(rsp) => match rsp { + ResponsesWithHeadersGetResponse::Status200_Success + { + body, + success_info, + bool_header, + object_header + } + => { + let success_info = match header::IntoHeaderValue(success_info).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling success_info header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert(HeaderName::from_static("success-info"), success_info); - } - if let Some(bool_header) = bool_header { - let bool_header = match header::IntoHeaderValue(bool_header).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("success-info"), + success_info + ); + } + if let Some(bool_header) = bool_header { + let bool_header = match header::IntoHeaderValue(bool_header).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling bool_header header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("bool-header"), bool_header); - } - } - if let Some(object_header) = object_header { - let object_header = match header::IntoHeaderValue(object_header).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("bool-header"), + bool_header + ); + } + } + if let Some(object_header) = object_header { + let object_header = match header::IntoHeaderValue(object_header).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling object_header header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("object-header"), object_header); - } - } + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("object-header"), + object_header + ); + } + } - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - ResponsesWithHeadersGetResponse::Status412_PreconditionFailed { - further_info, - failure_info, - } => { - if let Some(further_info) = further_info { - let further_info = match header::IntoHeaderValue(further_info).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + ResponsesWithHeadersGetResponse::Status412_PreconditionFailed + { + further_info, + failure_info + } + => { + if let Some(further_info) = further_info { + let further_info = match header::IntoHeaderValue(further_info).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling further_info header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("further-info"), further_info); - } - } - if let Some(failure_info) = failure_info { - let failure_info = match header::IntoHeaderValue(failure_info).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("further-info"), + further_info + ); + } + } + if let Some(failure_info) = failure_info { + let failure_info = match header::IntoHeaderValue(failure_info).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling failure_info header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("failure-info"), failure_info); - } - } + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("failure-info"), + failure_info + ); + } + } - let mut response = response.status(412); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(412); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn rfc7807_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn rfc7807_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// Rfc7807Get - GET /rfc7807 #[tracing::instrument(skip_all)] async fn rfc7807_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = rfc7807_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + rfc7807_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().rfc7807_get(method, host, cookies).await; + let result = api_impl.as_ref().rfc7807_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - Rfc7807GetResponse::Status204_OK(body) => { - let mut response = response.status(204); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + Rfc7807GetResponse::Status204_OK + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - Rfc7807GetResponse::Status404_NotFound(body) => { - let mut response = response.status(404); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/problem+json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(204); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - Rfc7807GetResponse::Status406_NotAcceptable(body) => { - let mut response = response.status(406); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + Rfc7807GetResponse::Status404_NotFound + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(404); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/problem+json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + Rfc7807GetResponse::Status406_NotAcceptable + (body) + => { + + let mut response = response.status(406); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } + + let body_content = body; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct UntypedPropertyGetBodyValidator<'a> { - #[validate] - body: &'a models::ObjectUntypedProps, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct UntypedPropertyGetBodyValidator<'a> { + #[validate] + body: &'a models::ObjectUntypedProps, + } + #[tracing::instrument(skip_all)] fn untyped_property_get_validation( - body: Option, -) -> std::result::Result<(Option,), ValidationErrors> { - if let Some(body) = &body { - let b = UntypedPropertyGetBodyValidator { body }; - b.validate()?; - } + body: Option, +) -> std::result::Result<( + Option, +), ValidationErrors> +{ + if let Some(body) = &body { + let b = UntypedPropertyGetBodyValidator { body }; + b.validate()?; + } - Ok((body,)) +Ok(( + body, +)) } /// UntypedPropertyGet - GET /untyped_property #[tracing::instrument(skip_all)] async fn untyped_property_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = untyped_property_get_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + untyped_property_get_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .untyped_property_get(method, host, cookies, body) - .await; + let result = api_impl.as_ref().untyped_property_get( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UntypedPropertyGetResponse::Status200_CheckThatUntypedPropertiesWorks => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UntypedPropertyGetResponse::Status200_CheckThatUntypedPropertiesWorks + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn uuid_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn uuid_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// UuidGet - GET /uuid #[tracing::instrument(skip_all)] async fn uuid_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = uuid_get_validation(); - let Ok(()) = validation else { - return Response::builder() + let validation = + uuid_get_validation( + ) + ; + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().uuid_get(method, host, cookies).await; + let result = api_impl.as_ref().uuid_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UuidGetResponse::Status200_DuplicateResponseLongText(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + UuidGetResponse::Status200_DuplicateResponseLongText + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct XmlExtraPostBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct XmlExtraPostBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] -fn xml_extra_post_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) +fn xml_extra_post_validation( + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// XmlExtraPost - POST /xml_extra #[tracing::instrument(skip_all)] async fn xml_extra_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = xml_extra_post_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + xml_extra_post_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .xml_extra_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().xml_extra_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - XmlExtraPostResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - XmlExtraPostResponse::Status400_BadRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + XmlExtraPostResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + XmlExtraPostResponse::Status400_BadRequest + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct XmlOtherPostBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct XmlOtherPostBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] -fn xml_other_post_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) +fn xml_other_post_validation( + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// XmlOtherPost - POST /xml_other #[tracing::instrument(skip_all)] async fn xml_other_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = xml_other_post_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + xml_other_post_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .xml_other_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().xml_other_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - XmlOtherPostResponse::Status201_OK(body) => { - let mut response = response.status(201); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + XmlOtherPostResponse::Status201_OK + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - XmlOtherPostResponse::Status400_BadRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(201); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + XmlOtherPostResponse::Status400_BadRequest + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct XmlOtherPutBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct XmlOtherPutBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] -fn xml_other_put_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) +fn xml_other_put_validation( + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// XmlOtherPut - PUT /xml_other #[tracing::instrument(skip_all)] async fn xml_other_put( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = xml_other_put_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + xml_other_put_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .xml_other_put(method, host, cookies, body) - .await; + let result = api_impl.as_ref().xml_other_put( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - XmlOtherPutResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - XmlOtherPutResponse::Status400_BadRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + XmlOtherPutResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + XmlOtherPutResponse::Status400_BadRequest + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct XmlPostBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct XmlPostBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] -fn xml_post_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) +fn xml_post_validation( + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// XmlPost - POST /xml #[tracing::instrument(skip_all)] async fn xml_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = xml_post_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + xml_post_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .xml_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().xml_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - XmlPostResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - XmlPostResponse::Status400_BadRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + XmlPostResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + XmlPostResponse::Status400_BadRequest + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct XmlPutBodyValidator<'a> { - body: &'a [u8], -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct XmlPutBodyValidator<'a> { + body: &'a [u8], + } + #[tracing::instrument(skip_all)] -fn xml_put_validation(body: Bytes) -> std::result::Result<(Bytes,), ValidationErrors> { - Ok((body,)) +fn xml_put_validation( + body: Bytes, +) -> std::result::Result<( + Bytes, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// XmlPut - PUT /xml #[tracing::instrument(skip_all)] async fn xml_put( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: Bytes, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: Bytes, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = xml_put_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + xml_put_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().xml_put(method, host, cookies, body).await; + let result = api_impl.as_ref().xml_put( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - XmlPutResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - XmlPutResponse::Status400_BadRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + XmlPutResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + XmlPutResponse::Status400_BadRequest + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateRepoBodyValidator<'a> { - #[validate] - body: &'a models::ObjectParam, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateRepoBodyValidator<'a> { + #[validate] + body: &'a models::ObjectParam, + } + #[tracing::instrument(skip_all)] fn create_repo_validation( - body: models::ObjectParam, -) -> std::result::Result<(models::ObjectParam,), ValidationErrors> { - let b = CreateRepoBodyValidator { body: &body }; - b.validate()?; + body: models::ObjectParam, +) -> std::result::Result<( + models::ObjectParam, +), ValidationErrors> +{ + let b = CreateRepoBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateRepo - POST /repos #[tracing::instrument(skip_all)] async fn create_repo( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = create_repo_validation(body); - let Ok((body,)) = validation else { - return Response::builder() + let validation = + create_repo_validation( + body, + ) + ; + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_repo(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_repo( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateRepoResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateRepoResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_repo_info_validation( - path_params: models::GetRepoInfoPathParams, -) -> std::result::Result<(models::GetRepoInfoPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetRepoInfoPathParams, +) -> std::result::Result<( + models::GetRepoInfoPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetRepoInfo - GET /repos/{repoId} #[tracing::instrument(skip_all)] async fn get_repo_info( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - let validation = get_repo_info_validation(path_params); - let Ok((path_params,)) = validation else { - return Response::builder() + let validation = + get_repo_info_validation( + path_params, + ) + ; + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_repo_info(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_repo_info( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetRepoInfoResponse::Status200_OK(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetRepoInfoResponse::Status200_OK + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/header.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/header.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index 553ab3558136..a19cbbbba29e 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,695 +14,772 @@ use types::*; pub const BASE_PATH: &str = "/v2"; pub const API_VERSION: &str = "1.0.0"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestSpecialTagsResponse { /// successful operation - Status200_SuccessfulOperation(models::Client), + Status200_SuccessfulOperation + (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum Call123exampleResponse { /// success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FakeOuterBooleanSerializeResponse { /// Output boolean - Status200_OutputBoolean(bool), + Status200_OutputBoolean + (bool) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FakeOuterCompositeSerializeResponse { /// Output composite - Status200_OutputComposite(models::OuterComposite), + Status200_OutputComposite + (models::OuterComposite) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FakeOuterNumberSerializeResponse { /// Output number - Status200_OutputNumber(f64), + Status200_OutputNumber + (f64) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FakeOuterStringSerializeResponse { /// Output string - Status200_OutputString(String), + Status200_OutputString + (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FakeResponseWithNumericalDescriptionResponse { /// 1234 - Status200, + Status200 } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum HyphenParamResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestBodyWithQueryParamsResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestClientModelResponse { /// successful operation - Status200_SuccessfulOperation(models::Client), + Status200_SuccessfulOperation + (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestEndpointParametersResponse { /// Invalid username supplied - Status400_InvalidUsernameSupplied, + Status400_InvalidUsernameSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestEnumParametersResponse { /// Invalid request - Status400_InvalidRequest, + Status400_InvalidRequest + , /// Not found - Status404_NotFound, + Status404_NotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestInlineAdditionalPropertiesResponse { /// successful operation - Status200_SuccessfulOperation, + Status200_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestJsonFormDataResponse { /// successful operation - Status200_SuccessfulOperation, + Status200_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum TestClassnameResponse { /// successful operation - Status200_SuccessfulOperation(models::Client), + Status200_SuccessfulOperation + (models::Client) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum AddPetResponse { /// Invalid input - Status405_InvalidInput, + Status405_InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeletePetResponse { /// Invalid pet value - Status400_InvalidPetValue, + Status400_InvalidPetValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FindPetsByStatusResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid status value - Status400_InvalidStatusValue, + Status400_InvalidStatusValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FindPetsByTagsResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid tag value - Status400_InvalidTagValue, + Status400_InvalidTagValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetPetByIdResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Pet not found - Status404_PetNotFound, + Status404_PetNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdatePetResponse { /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Pet not found - Status404_PetNotFound, + Status404_PetNotFound + , /// Validation exception - Status405_ValidationException, + Status405_ValidationException } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdatePetWithFormResponse { /// Invalid input - Status405_InvalidInput, + Status405_InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UploadFileResponse { /// successful operation - Status200_SuccessfulOperation(models::ApiResponse), + Status200_SuccessfulOperation + (models::ApiResponse) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeleteOrderResponse { /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Order not found - Status404_OrderNotFound, + Status404_OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetInventoryResponse { /// successful operation - Status200_SuccessfulOperation(std::collections::HashMap), + Status200_SuccessfulOperation + (std::collections::HashMap) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetOrderByIdResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Order not found - Status404_OrderNotFound, + Status404_OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum PlaceOrderResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid Order - Status400_InvalidOrder, + Status400_InvalidOrder } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUserResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUsersWithArrayInputResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUsersWithListInputResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeleteUserResponse { /// Invalid username supplied - Status400_InvalidUsernameSupplied, + Status400_InvalidUsernameSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetUserByNameResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid username supplied - Status400_InvalidUsernameSupplied, + Status400_InvalidUsernameSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum LoginUserResponse { /// successful operation - Status200_SuccessfulOperation { + Status200_SuccessfulOperation + { body: String, - x_rate_limit: Option, - x_expires_after: Option>, - }, + x_rate_limit: + Option< + i32 + > + , + x_expires_after: + Option< + chrono::DateTime:: + > + } + , /// Invalid username/password supplied - Status400_InvalidUsername, + Status400_InvalidUsername } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum LogoutUserResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdateUserResponse { /// Invalid user supplied - Status400_InvalidUserSupplied, + Status400_InvalidUserSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// To test special tags. - /// - /// TestSpecialTags - PATCH /v2/another-fake/dummy - async fn test_special_tags( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, - ) -> Result; - /// Call123example - GET /v2/fake/operation-with-numeric-id - async fn call123example( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// To test special tags. + /// + /// TestSpecialTags - PATCH /v2/another-fake/dummy + async fn test_special_tags( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Client, + ) -> Result; - /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean - async fn fake_outer_boolean_serialize( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, - ) -> Result; - /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite - async fn fake_outer_composite_serialize( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, - ) -> Result; + /// Call123example - GET /v2/fake/operation-with-numeric-id + async fn call123example( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// FakeOuterNumberSerialize - POST /v2/fake/outer/number - async fn fake_outer_number_serialize( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, - ) -> Result; - /// FakeOuterStringSerialize - POST /v2/fake/outer/string - async fn fake_outer_string_serialize( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Option, - ) -> Result; + /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean + async fn fake_outer_boolean_serialize( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Option, + ) -> Result; - /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description - async fn fake_response_with_numerical_description( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} - async fn hyphen_param( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::HyphenParamPathParams, - ) -> Result; + /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite + async fn fake_outer_composite_serialize( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Option, + ) -> Result; - /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params - async fn test_body_with_query_params( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::TestBodyWithQueryParamsQueryParams, - body: models::User, - ) -> Result; - /// To test \"client\" model. - /// - /// TestClientModel - PATCH /v2/fake - async fn test_client_model( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, - ) -> Result; + /// FakeOuterNumberSerialize - POST /v2/fake/outer/number + async fn fake_outer_number_serialize( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Option, + ) -> Result; - /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트. - /// - /// TestEndpointParameters - POST /v2/fake - async fn test_endpoint_parameters( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// To test enum parameters. - /// - /// TestEnumParameters - GET /v2/fake - async fn test_enum_parameters( - &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::TestEnumParametersHeaderParams, - query_params: models::TestEnumParametersQueryParams, - ) -> Result; + /// FakeOuterStringSerialize - POST /v2/fake/outer/string + async fn fake_outer_string_serialize( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Option, + ) -> Result; - /// test inline additionalProperties. - /// - /// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties - async fn test_inline_additional_properties( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: std::collections::HashMap, - ) -> Result; - /// test json serialization of form data. - /// - /// TestJsonFormData - GET /v2/fake/jsonFormData - async fn test_json_form_data( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description + async fn fake_response_with_numerical_description( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// To test class name in snake case. - /// - /// TestClassname - PATCH /v2/fake_classname_test - async fn test_classname( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Client, - ) -> Result; - /// Add a new pet to the store. - /// - /// AddPet - POST /v2/pet - async fn add_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, - ) -> Result; + /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} + async fn hyphen_param( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::HyphenParamPathParams, + ) -> Result; - /// Deletes a pet. - /// - /// DeletePet - DELETE /v2/pet/{petId} - async fn delete_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, - ) -> Result; - /// Finds Pets by status. - /// - /// FindPetsByStatus - GET /v2/pet/findByStatus - async fn find_pets_by_status( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByStatusQueryParams, - ) -> Result; + /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params + async fn test_body_with_query_params( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::TestBodyWithQueryParamsQueryParams, + body: models::User, + ) -> Result; - /// Finds Pets by tags. - /// - /// FindPetsByTags - GET /v2/pet/findByTags - async fn find_pets_by_tags( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByTagsQueryParams, - ) -> Result; - /// Find pet by ID. - /// - /// GetPetById - GET /v2/pet/{petId} - async fn get_pet_by_id( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetPetByIdPathParams, - ) -> Result; + /// To test \"client\" model. + /// + /// TestClientModel - PATCH /v2/fake + async fn test_client_model( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Client, + ) -> Result; - /// Update an existing pet. - /// - /// UpdatePet - PUT /v2/pet - async fn update_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, - ) -> Result; - /// Updates a pet in the store with form data. - /// - /// UpdatePetWithForm - POST /v2/pet/{petId} - async fn update_pet_with_form( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdatePetWithFormPathParams, - ) -> Result; + /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트. + /// + /// TestEndpointParameters - POST /v2/fake + async fn test_endpoint_parameters( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// uploads an image. - /// - /// UploadFile - POST /v2/pet/{petId}/uploadImage - async fn upload_file( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UploadFilePathParams, - body: Multipart, - ) -> Result; - /// Delete purchase order by ID. - /// - /// DeleteOrder - DELETE /v2/store/order/{order_id} - async fn delete_order( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteOrderPathParams, - ) -> Result; + /// To test enum parameters. + /// + /// TestEnumParameters - GET /v2/fake + async fn test_enum_parameters( + &self, + method: Method, + host: Host, + cookies: CookieJar, + header_params: models::TestEnumParametersHeaderParams, + query_params: models::TestEnumParametersQueryParams, + ) -> Result; - /// Returns pet inventories by status. - /// - /// GetInventory - GET /v2/store/inventory - async fn get_inventory( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// Find purchase order by ID. - /// - /// GetOrderById - GET /v2/store/order/{order_id} - async fn get_order_by_id( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetOrderByIdPathParams, - ) -> Result; + /// test inline additionalProperties. + /// + /// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties + async fn test_inline_additional_properties( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: std::collections::HashMap, + ) -> Result; - /// Place an order for a pet. - /// - /// PlaceOrder - POST /v2/store/order - async fn place_order( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Order, - ) -> Result; - /// Create user. - /// - /// CreateUser - POST /v2/user - async fn create_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::User, - ) -> Result; + /// test json serialization of form data. + /// + /// TestJsonFormData - GET /v2/fake/jsonFormData + async fn test_json_form_data( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// Creates list of users with given input array. - /// - /// CreateUsersWithArrayInput - POST /v2/user/createWithArray - async fn create_users_with_array_input( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, - ) -> Result; - /// Creates list of users with given input array. - /// - /// CreateUsersWithListInput - POST /v2/user/createWithList - async fn create_users_with_list_input( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, - ) -> Result; + /// To test class name in snake case. + /// + /// TestClassname - PATCH /v2/fake_classname_test + async fn test_classname( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Client, + ) -> Result; - /// Delete user. - /// - /// DeleteUser - DELETE /v2/user/{username} - async fn delete_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteUserPathParams, - ) -> Result; - /// Get user by user name. - /// - /// GetUserByName - GET /v2/user/{username} - async fn get_user_by_name( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetUserByNamePathParams, - ) -> Result; + /// Add a new pet to the store. + /// + /// AddPet - POST /v2/pet + async fn add_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Pet, + ) -> Result; - /// Logs user into the system. - /// - /// LoginUser - GET /v2/user/login - async fn login_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::LoginUserQueryParams, - ) -> Result; - /// Logs out current logged in user session. - /// - /// LogoutUser - GET /v2/user/logout - async fn logout_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// Deletes a pet. + /// + /// DeletePet - DELETE /v2/pet/{petId} + async fn delete_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + header_params: models::DeletePetHeaderParams, + path_params: models::DeletePetPathParams, + ) -> Result; + + + /// Finds Pets by status. + /// + /// FindPetsByStatus - GET /v2/pet/findByStatus + async fn find_pets_by_status( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::FindPetsByStatusQueryParams, + ) -> Result; + + + /// Finds Pets by tags. + /// + /// FindPetsByTags - GET /v2/pet/findByTags + async fn find_pets_by_tags( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::FindPetsByTagsQueryParams, + ) -> Result; + + + /// Find pet by ID. + /// + /// GetPetById - GET /v2/pet/{petId} + async fn get_pet_by_id( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetPetByIdPathParams, + ) -> Result; + + + /// Update an existing pet. + /// + /// UpdatePet - PUT /v2/pet + async fn update_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Pet, + ) -> Result; + + + /// Updates a pet in the store with form data. + /// + /// UpdatePetWithForm - POST /v2/pet/{petId} + async fn update_pet_with_form( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UpdatePetWithFormPathParams, + ) -> Result; + + + /// uploads an image. + /// + /// UploadFile - POST /v2/pet/{petId}/uploadImage + async fn upload_file( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UploadFilePathParams, + body: Multipart, + ) -> Result; + + + /// Delete purchase order by ID. + /// + /// DeleteOrder - DELETE /v2/store/order/{order_id} + async fn delete_order( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::DeleteOrderPathParams, + ) -> Result; + + + /// Returns pet inventories by status. + /// + /// GetInventory - GET /v2/store/inventory + async fn get_inventory( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Find purchase order by ID. + /// + /// GetOrderById - GET /v2/store/order/{order_id} + async fn get_order_by_id( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetOrderByIdPathParams, + ) -> Result; + + + /// Place an order for a pet. + /// + /// PlaceOrder - POST /v2/store/order + async fn place_order( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Order, + ) -> Result; + + + /// Create user. + /// + /// CreateUser - POST /v2/user + async fn create_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::User, + ) -> Result; + + + /// Creates list of users with given input array. + /// + /// CreateUsersWithArrayInput - POST /v2/user/createWithArray + async fn create_users_with_array_input( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Vec, + ) -> Result; + + + /// Creates list of users with given input array. + /// + /// CreateUsersWithListInput - POST /v2/user/createWithList + async fn create_users_with_list_input( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Vec, + ) -> Result; + + + /// Delete user. + /// + /// DeleteUser - DELETE /v2/user/{username} + async fn delete_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::DeleteUserPathParams, + ) -> Result; + + + /// Get user by user name. + /// + /// GetUserByName - GET /v2/user/{username} + async fn get_user_by_name( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetUserByNamePathParams, + ) -> Result; + + + /// Logs user into the system. + /// + /// LoginUser - GET /v2/user/login + async fn login_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::LoginUserQueryParams, + ) -> Result; + + + /// Logs out current logged in user session. + /// + /// LogoutUser - GET /v2/user/logout + async fn logout_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Updated user. + /// + /// UpdateUser - PUT /v2/user/{username} + async fn update_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UpdateUserPathParams, + body: models::User, + ) -> Result; - /// Updated user. - /// - /// UpdateUser - PUT /v2/user/{username} - async fn update_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdateUserPathParams, - body: models::User, - ) -> Result; } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 78cda8e9db4a..3ba9efc9eb7a 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -7,163 +7,218 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct HyphenParamPathParams { - /// Parameter with hyphen in name - pub hyphen_param: String, -} + + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct HyphenParamPathParams { + /// Parameter with hyphen in name + pub hyphen_param: String, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct TestBodyWithQueryParamsQueryParams { - #[serde(rename = "query")] - pub query: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct TestEnumParametersHeaderParams { - pub enum_header_string_array: Option>, - pub enum_header_string: Option, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct TestBodyWithQueryParamsQueryParams { + #[serde(rename = "query")] + pub query: String, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct TestEnumParametersQueryParams { - /// Query parameter enum test (string array) - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "enum_query_string_array")] - #[serde(skip_serializing_if = "Option::is_none")] - pub enum_query_string_array: Option>, - /// Query parameter enum test (string) - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "enum_query_string")] - #[serde(skip_serializing_if = "Option::is_none")] - pub enum_query_string: Option, - /// Query parameter enum test (double) - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "enum_query_integer")] - #[serde(skip_serializing_if = "Option::is_none")] - pub enum_query_integer: Option, - /// Query parameter enum test (double) - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "enum_query_double")] - #[serde(skip_serializing_if = "Option::is_none")] - pub enum_query_double: Option, -} + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct TestEnumParametersHeaderParams { + pub enum_header_string_array: Option>, + pub enum_header_string: Option, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeletePetHeaderParams { - pub api_key: Option, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct TestEnumParametersQueryParams { + /// Query parameter enum test (string array) + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "enum_query_string_array")] + #[serde(skip_serializing_if="Option::is_none")] + pub enum_query_string_array: Option>, + /// Query parameter enum test (string) + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "enum_query_string")] + #[serde(skip_serializing_if="Option::is_none")] + pub enum_query_string: Option, + /// Query parameter enum test (double) + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "enum_query_integer")] + #[serde(skip_serializing_if="Option::is_none")] + pub enum_query_integer: Option, + /// Query parameter enum test (double) + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "enum_query_double")] + #[serde(skip_serializing_if="Option::is_none")] + pub enum_query_double: Option, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeletePetPathParams { - /// Pet id to delete - pub pet_id: i64, -} + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeletePetHeaderParams { + pub api_key: Option, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct FindPetsByStatusQueryParams { - /// Status values that need to be considered for filter - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "status")] - pub status: Vec, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeletePetPathParams { + /// Pet id to delete + pub pet_id: i64, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct FindPetsByTagsQueryParams { - /// Tags to filter by - #[serde(rename = "tags")] - pub tags: Vec, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetPetByIdPathParams { - /// ID of pet to return - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct FindPetsByStatusQueryParams { + /// Status values that need to be considered for filter + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "status")] + pub status: Vec, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UpdatePetWithFormPathParams { - /// ID of pet that needs to be updated - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct FindPetsByTagsQueryParams { + /// Tags to filter by + #[serde(rename = "tags")] + pub tags: Vec, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UploadFilePathParams { - /// ID of pet to update - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetPetByIdPathParams { + /// ID of pet to return + pub pet_id: i64, + } + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UpdatePetWithFormPathParams { + /// ID of pet that needs to be updated + pub pet_id: i64, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UploadFilePathParams { + /// ID of pet to update + pub pet_id: i64, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeleteOrderPathParams { + /// ID of the order that needs to be deleted + pub order_id: String, + } + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetOrderByIdPathParams { + /// ID of pet that needs to be fetched + #[validate( + range(min = 1, max = 5), + )] + pub order_id: i64, + } + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeleteUserPathParams { + /// The name that needs to be deleted + pub username: String, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetUserByNamePathParams { + /// The name that needs to be fetched. Use user1 for testing. + pub username: String, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct LoginUserQueryParams { + /// The user name for login + #[serde(rename = "username")] + pub username: String, + /// The password for login in clear text + #[serde(rename = "password")] + pub password: String, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UpdateUserPathParams { + /// name that need to be deleted + pub username: String, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeleteOrderPathParams { - /// ID of the order that needs to be deleted - pub order_id: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetOrderByIdPathParams { - /// ID of pet that needs to be fetched - #[validate(range(min = 1, max = 5))] - pub order_id: i64, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeleteUserPathParams { - /// The name that needs to be deleted - pub username: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetUserByNamePathParams { - /// The name that needs to be fetched. Use user1 for testing. - pub username: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct LoginUserQueryParams { - /// The user name for login - #[serde(rename = "username")] - pub username: String, - /// The password for login in clear text - #[serde(rename = "password")] - pub password: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UpdateUserPathParams { - /// name that need to be deleted - pub username: String, -} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AdditionalPropertiesClass { #[serde(rename = "map_property")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub map_property: Option>, #[serde(rename = "map_of_map_property")] - #[serde(skip_serializing_if = "Option::is_none")] - pub map_of_map_property: - Option>>, + #[serde(skip_serializing_if="Option::is_none")] + pub map_of_map_property: Option>>, + } + impl AdditionalPropertiesClass { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> AdditionalPropertiesClass { @@ -203,8 +258,7 @@ impl std::str::FromStr for AdditionalPropertiesClass { #[allow(dead_code)] struct IntermediateRep { pub map_property: Vec>, - pub map_of_map_property: - Vec>>, + pub map_of_map_property: Vec>>, } let mut intermediate_rep = IntermediateRep::default(); @@ -216,11 +270,7 @@ impl std::str::FromStr for AdditionalPropertiesClass { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing AdditionalPropertiesClass".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing AdditionalPropertiesClass".to_string()) }; if let Some(key) = key_result { @@ -250,16 +300,13 @@ impl std::str::FromStr for AdditionalPropertiesClass { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AdditionalPropertiesClass - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AdditionalPropertiesClass - value: {} is invalid {}", + hdr_value, e)) } } } @@ -270,25 +317,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesClass - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AdditionalPropertiesClass - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Animal { @@ -296,13 +345,15 @@ pub struct Animal { pub class_name: String, #[serde(rename = "color")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub color: Option, + } + impl Animal { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(class_name: String) -> Animal { + pub fn new(class_name: String, ) -> Animal { Animal { class_name, color: Some("red".to_string()), @@ -316,11 +367,18 @@ impl Animal { impl std::string::ToString for Animal { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("className".to_string()), Some(self.class_name.to_string()), - self.color - .as_ref() - .map(|color| ["color".to_string(), color.to_string()].join(",")), + + + self.color.as_ref().map(|color| { + [ + "color".to_string(), + color.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -351,29 +409,17 @@ impl std::str::FromStr for Animal { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Animal".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Animal".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "className" => intermediate_rep.class_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "className" => intermediate_rep.class_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "color" => intermediate_rep.color.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Animal".to_string(), - ) - } + "color" => intermediate_rep.color.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Animal".to_string()) } } @@ -383,11 +429,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_else(|| "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(), }) } @@ -399,16 +441,13 @@ impl std::str::FromStr for Animal { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Animal - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Animal - value: {} is invalid {}", + hdr_value, e)) } } } @@ -419,25 +458,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Animal - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Animal - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AnimalFarm(Vec); @@ -461,7 +499,7 @@ impl std::convert::From for Vec { } impl std::iter::FromIterator for AnimalFarm { - fn from_iter>(u: U) -> Self { + fn from_iter>(u: U) -> Self { AnimalFarm(Vec::::from_iter(u)) } } @@ -511,10 +549,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::>() - .join(",") + self.iter().map(|x| x.to_string()).collect::>().join(",") } } @@ -526,29 +561,28 @@ impl std::str::FromStr for AnimalFarm { fn from_str(s: &str) -> std::result::Result { let mut items = vec![]; - for item in s.split(',') { + for item in s.split(',') + { items.push(item.parse()?); } std::result::Result::Ok(AnimalFarm(items)) } } + // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AnimalFarm - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnimalFarm - value: {} is invalid {}", + hdr_value, e)) } } } @@ -559,41 +593,45 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnimalFarm - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AnimalFarm - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ApiResponse { #[serde(rename = "code")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub code: Option, #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub r#type: Option, #[serde(rename = "message")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub message: Option, + } + impl ApiResponse { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ApiResponse { @@ -611,15 +649,30 @@ impl ApiResponse { impl std::string::ToString for ApiResponse { fn to_string(&self) -> String { let params: Vec> = vec![ - self.code - .as_ref() - .map(|code| ["code".to_string(), code.to_string()].join(",")), - self.r#type - .as_ref() - .map(|r#type| ["type".to_string(), r#type.to_string()].join(",")), - self.message - .as_ref() - .map(|message| ["message".to_string(), message.to_string()].join(",")), + + self.code.as_ref().map(|code| { + [ + "code".to_string(), + code.to_string(), + ].join(",") + }), + + + self.r#type.as_ref().map(|r#type| { + [ + "type".to_string(), + r#type.to_string(), + ].join(",") + }), + + + self.message.as_ref().map(|message| { + [ + "message".to_string(), + message.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -651,33 +704,19 @@ impl std::str::FromStr for ApiResponse { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ApiResponse".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ApiResponse".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "code" => intermediate_rep.code.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "code" => intermediate_rep.code.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "type" => intermediate_rep.r#type.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "type" => intermediate_rep.r#type.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "message" => intermediate_rep.message.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ApiResponse".to_string(), - ) - } + "message" => intermediate_rep.message.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ApiResponse".to_string()) } } @@ -700,16 +739,13 @@ impl std::str::FromStr for ApiResponse { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ApiResponse - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ApiResponse - value: {} is invalid {}", + hdr_value, e)) } } } @@ -720,33 +756,37 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ApiResponse - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ApiResponse - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfArrayOfNumberOnly { #[serde(rename = "ArrayArrayNumber")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_array_number: Option>>, + } + impl ArrayOfArrayOfNumberOnly { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ArrayOfArrayOfNumberOnly { @@ -793,11 +833,7 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ArrayOfArrayOfNumberOnly".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ArrayOfArrayOfNumberOnly".to_string()) }; if let Some(key) = key_result { @@ -825,16 +861,13 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ArrayOfArrayOfNumberOnly - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ArrayOfArrayOfNumberOnly - value: {} is invalid {}", + hdr_value, e)) } } } @@ -845,37 +878,43 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayOfArrayOfNumberOnly - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ArrayOfArrayOfNumberOnly - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayOfNumberOnly { #[serde(rename = "ArrayNumber")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_number: Option>, + } + impl ArrayOfNumberOnly { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ArrayOfNumberOnly { - ArrayOfNumberOnly { array_number: None } + ArrayOfNumberOnly { + array_number: None, + } } } @@ -884,17 +923,16 @@ impl ArrayOfNumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for ArrayOfNumberOnly { fn to_string(&self) -> String { - let params: Vec> = vec![self.array_number.as_ref().map(|array_number| { - [ - "ArrayNumber".to_string(), - array_number - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") - })]; + let params: Vec> = vec![ + + self.array_number.as_ref().map(|array_number| { + [ + "ArrayNumber".to_string(), + array_number.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -923,25 +961,14 @@ impl std::str::FromStr for ArrayOfNumberOnly { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ArrayOfNumberOnly".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ArrayOfNumberOnly".to_string()) }; 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(), - ) - } + "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()) } } @@ -962,16 +989,13 @@ impl std::str::FromStr for ArrayOfNumberOnly { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ArrayOfNumberOnly - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ArrayOfNumberOnly - value: {} is invalid {}", + hdr_value, e)) } } } @@ -982,46 +1006,50 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayOfNumberOnly - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ArrayOfNumberOnly - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ArrayTest { #[serde(rename = "array_of_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_of_string: Option>, #[serde(rename = "array_array_of_integer")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_array_of_integer: Option>>, #[serde(rename = "array_array_of_model")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_array_of_model: Option>>, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_of_enum")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_of_enum: Option>, + } + impl ArrayTest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ArrayTest { @@ -1040,31 +1068,26 @@ impl ArrayTest { impl std::string::ToString for ArrayTest { fn to_string(&self) -> String { let params: Vec> = vec![ + self.array_of_string.as_ref().map(|array_of_string| { [ "array_of_string".to_string(), - array_of_string - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + array_of_string.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + // Skipping array_array_of_integer in query parameter serialization // Skipping array_array_of_model in query parameter serialization + + self.array_of_enum.as_ref().map(|array_of_enum| { [ "array_of_enum".to_string(), - array_of_enum - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + array_of_enum.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1097,45 +1120,17 @@ impl std::str::FromStr for ArrayTest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ArrayTest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ArrayTest".to_string()) }; 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(), - ) - } - "array_array_of_model" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in ArrayTest" - .to_string(), - ) - } - "array_of_enum" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in ArrayTest" - .to_string(), - ) - } - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ArrayTest".to_string(), - ) - } + "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()), + "array_array_of_model" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayTest".to_string()), + "array_of_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in ArrayTest".to_string()), + _ => return std::result::Result::Err("Unexpected key while parsing ArrayTest".to_string()) } } @@ -1159,16 +1154,13 @@ impl std::str::FromStr for ArrayTest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ArrayTest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ArrayTest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1179,54 +1171,58 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayTest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ArrayTest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Capitalization { #[serde(rename = "smallCamel")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub small_camel: Option, #[serde(rename = "CapitalCamel")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub capital_camel: Option, #[serde(rename = "small_Snake")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub small_snake: Option, #[serde(rename = "Capital_Snake")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub capital_snake: Option, #[serde(rename = "SCA_ETH_Flow_Points")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub sca_eth_flow_points: Option, - /// Name of the pet +/// Name of the pet #[serde(rename = "ATT_NAME")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub att_name: Option, + } + impl Capitalization { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Capitalization { @@ -1247,30 +1243,54 @@ impl Capitalization { impl std::string::ToString for Capitalization { fn to_string(&self) -> String { let params: Vec> = vec![ - self.small_camel - .as_ref() - .map(|small_camel| ["smallCamel".to_string(), small_camel.to_string()].join(",")), + + self.small_camel.as_ref().map(|small_camel| { + [ + "smallCamel".to_string(), + small_camel.to_string(), + ].join(",") + }), + + self.capital_camel.as_ref().map(|capital_camel| { - ["CapitalCamel".to_string(), capital_camel.to_string()].join(",") + [ + "CapitalCamel".to_string(), + capital_camel.to_string(), + ].join(",") }), - self.small_snake - .as_ref() - .map(|small_snake| ["small_Snake".to_string(), small_snake.to_string()].join(",")), + + + self.small_snake.as_ref().map(|small_snake| { + [ + "small_Snake".to_string(), + small_snake.to_string(), + ].join(",") + }), + + self.capital_snake.as_ref().map(|capital_snake| { - ["Capital_Snake".to_string(), capital_snake.to_string()].join(",") + [ + "Capital_Snake".to_string(), + capital_snake.to_string(), + ].join(",") }), - self.sca_eth_flow_points - .as_ref() - .map(|sca_eth_flow_points| { - [ - "SCA_ETH_Flow_Points".to_string(), - sca_eth_flow_points.to_string(), - ] - .join(",") - }), - self.att_name - .as_ref() - .map(|att_name| ["ATT_NAME".to_string(), att_name.to_string()].join(",")), + + + self.sca_eth_flow_points.as_ref().map(|sca_eth_flow_points| { + [ + "SCA_ETH_Flow_Points".to_string(), + sca_eth_flow_points.to_string(), + ].join(",") + }), + + + self.att_name.as_ref().map(|att_name| { + [ + "ATT_NAME".to_string(), + att_name.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1305,45 +1325,25 @@ impl std::str::FromStr for Capitalization { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Capitalization".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Capitalization".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "smallCamel" => intermediate_rep.small_camel.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "smallCamel" => intermediate_rep.small_camel.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "CapitalCamel" => intermediate_rep.capital_camel.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "CapitalCamel" => intermediate_rep.capital_camel.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "small_Snake" => intermediate_rep.small_snake.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "small_Snake" => intermediate_rep.small_snake.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "Capital_Snake" => intermediate_rep.capital_snake.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "Capital_Snake" => intermediate_rep.capital_snake.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "SCA_ETH_Flow_Points" => intermediate_rep.sca_eth_flow_points.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "SCA_ETH_Flow_Points" => intermediate_rep.sca_eth_flow_points.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "ATT_NAME" => intermediate_rep.att_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Capitalization".to_string(), - ) - } + "ATT_NAME" => intermediate_rep.att_name.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Capitalization".to_string()) } } @@ -1369,16 +1369,13 @@ impl std::str::FromStr for Capitalization { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Capitalization - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Capitalization - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1389,25 +1386,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Capitalization - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Capitalization - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Cat { @@ -1415,17 +1414,19 @@ pub struct Cat { pub class_name: String, #[serde(rename = "color")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub color: Option, #[serde(rename = "declawed")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub declawed: Option, + } + impl Cat { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(class_name: String) -> Cat { + pub fn new(class_name: String, ) -> Cat { Cat { class_name, color: Some("red".to_string()), @@ -1440,14 +1441,26 @@ impl Cat { impl std::string::ToString for Cat { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("className".to_string()), Some(self.class_name.to_string()), - self.color - .as_ref() - .map(|color| ["color".to_string(), color.to_string()].join(",")), - self.declawed - .as_ref() - .map(|declawed| ["declawed".to_string(), declawed.to_string()].join(",")), + + + self.color.as_ref().map(|color| { + [ + "color".to_string(), + color.to_string(), + ].join(",") + }), + + + self.declawed.as_ref().map(|declawed| { + [ + "declawed".to_string(), + declawed.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1479,31 +1492,19 @@ impl std::str::FromStr for Cat { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Cat".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Cat".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "className" => intermediate_rep.class_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "className" => intermediate_rep.class_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "color" => intermediate_rep.color.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "color" => intermediate_rep.color.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "declawed" => intermediate_rep.declawed.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Cat".to_string(), - ) - } + "declawed" => intermediate_rep.declawed.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Cat".to_string()) } } @@ -1513,11 +1514,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_else(|| "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(), }) @@ -1533,11 +1530,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Cat - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Cat - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1548,35 +1544,41 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Cat - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Cat - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Category { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "name")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + } + impl Category { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Category { @@ -1593,12 +1595,22 @@ impl Category { impl std::string::ToString for Category { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.name - .as_ref() - .map(|name| ["name".to_string(), name.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.name.as_ref().map(|name| { + [ + "name".to_string(), + name.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1629,29 +1641,17 @@ impl std::str::FromStr for Category { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Category".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Category".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Category".to_string(), - ) - } + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Category".to_string()) } } @@ -1673,16 +1673,13 @@ impl std::str::FromStr for Category { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Category - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Category - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1693,39 +1690,44 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Category - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Category - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Model for testing model with \"_class\" property + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ClassModel { #[serde(rename = "_class")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub _class: Option, + } + impl ClassModel { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ClassModel { - ClassModel { _class: None } + ClassModel { + _class: None, + } } } @@ -1734,10 +1736,16 @@ impl ClassModel { /// Should be implemented in a serde serializer impl std::string::ToString for ClassModel { fn to_string(&self) -> String { - let params: Vec> = vec![self - ._class - .as_ref() - .map(|_class| ["_class".to_string(), _class.to_string()].join(","))]; + let params: Vec> = vec![ + + self._class.as_ref().map(|_class| { + [ + "_class".to_string(), + _class.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -1766,25 +1774,15 @@ impl std::str::FromStr for ClassModel { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ClassModel".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ClassModel".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "_class" => intermediate_rep._class.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ClassModel".to_string(), - ) - } + "_class" => intermediate_rep._class.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ClassModel".to_string()) } } @@ -1805,16 +1803,13 @@ impl std::str::FromStr for ClassModel { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ClassModel - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ClassModel - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1825,37 +1820,43 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ClassModel - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ClassModel - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Client { #[serde(rename = "client")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub client: Option, + } + impl Client { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Client { - Client { client: None } + Client { + client: None, + } } } @@ -1864,10 +1865,16 @@ impl Client { /// Should be implemented in a serde serializer impl std::string::ToString for Client { fn to_string(&self) -> String { - let params: Vec> = vec![self - .client - .as_ref() - .map(|client| ["client".to_string(), client.to_string()].join(","))]; + let params: Vec> = vec![ + + self.client.as_ref().map(|client| { + [ + "client".to_string(), + client.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -1896,25 +1903,15 @@ impl std::str::FromStr for Client { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Client".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Client".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "client" => intermediate_rep.client.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Client".to_string(), - ) - } + "client" => intermediate_rep.client.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Client".to_string()) } } @@ -1935,16 +1932,13 @@ impl std::str::FromStr for Client { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Client - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Client - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1955,25 +1949,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Client - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Client - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Dog { @@ -1981,17 +1977,19 @@ pub struct Dog { pub class_name: String, #[serde(rename = "color")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub color: Option, #[serde(rename = "breed")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub breed: Option, + } + impl Dog { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(class_name: String) -> Dog { + pub fn new(class_name: String, ) -> Dog { Dog { class_name, color: Some("red".to_string()), @@ -2006,14 +2004,26 @@ impl Dog { impl std::string::ToString for Dog { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("className".to_string()), Some(self.class_name.to_string()), - self.color - .as_ref() - .map(|color| ["color".to_string(), color.to_string()].join(",")), - self.breed - .as_ref() - .map(|breed| ["breed".to_string(), breed.to_string()].join(",")), + + + self.color.as_ref().map(|color| { + [ + "color".to_string(), + color.to_string(), + ].join(",") + }), + + + self.breed.as_ref().map(|breed| { + [ + "breed".to_string(), + breed.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -2045,31 +2055,19 @@ impl std::str::FromStr for Dog { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Dog".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Dog".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "className" => intermediate_rep.class_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "className" => intermediate_rep.class_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "color" => intermediate_rep.color.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "color" => intermediate_rep.color.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "breed" => intermediate_rep.breed.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Dog".to_string(), - ) - } + "breed" => intermediate_rep.breed.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Dog".to_string()) } } @@ -2079,11 +2077,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_else(|| "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(), }) @@ -2099,11 +2093,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Dog - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Dog - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2114,31 +2107,37 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Dog - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Dog - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { #[serde(rename = "$special[property.name]")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub dollar_special_left_square_bracket_property_period_name_right_square_bracket: Option, + } + impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { @@ -2179,8 +2178,7 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu #[derive(Default)] #[allow(dead_code)] struct IntermediateRep { - pub dollar_special_left_square_bracket_property_period_name_right_square_bracket: - Vec, + pub dollar_special_left_square_bracket_property_period_name_right_square_bracket: Vec, } let mut intermediate_rep = IntermediateRep::default(); @@ -2218,18 +2216,10 @@ impl std::str::FromStr for DollarSpecialLeftSquareBracketModelPeriodNameRightSqu // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl - std::convert::TryFrom< - header::IntoHeaderValue, - > for HeaderValue -{ +impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue< - DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket, - >, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { std::result::Result::Ok(value) => std::result::Result::Ok(value), @@ -2241,9 +2231,7 @@ impl } #[cfg(feature = "server")] -impl std::convert::TryFrom - for header::IntoHeaderValue -{ +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { @@ -2263,25 +2251,33 @@ impl std::convert::TryFrom } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumArrays { - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "just_symbol")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub just_symbol: Option, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_enum")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_enum: Option>, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_array_enum")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub array_array_enum: Option>>, + } + impl EnumArrays { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> EnumArrays { @@ -2299,21 +2295,24 @@ impl EnumArrays { impl std::string::ToString for EnumArrays { fn to_string(&self) -> String { let params: Vec> = vec![ - self.just_symbol - .as_ref() - .map(|just_symbol| ["just_symbol".to_string(), just_symbol.to_string()].join(",")), + + self.just_symbol.as_ref().map(|just_symbol| { + [ + "just_symbol".to_string(), + just_symbol.to_string(), + ].join(",") + }), + + self.array_enum.as_ref().map(|array_enum| { [ "array_enum".to_string(), - array_enum - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ] - .join(",") + array_enum.iter().map(|x| x.to_string()).collect::>().join(","), + ].join(",") }), + // Skipping array_array_enum in query parameter serialization + ]; params.into_iter().flatten().collect::>().join(",") @@ -2345,37 +2344,17 @@ impl std::str::FromStr for EnumArrays { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing EnumArrays".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing EnumArrays".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "just_symbol" => intermediate_rep.just_symbol.push( - ::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(), - ) - } + "just_symbol" => intermediate_rep.just_symbol.push(::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()) } } @@ -2398,16 +2377,13 @@ impl std::str::FromStr for EnumArrays { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for EnumArrays - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumArrays - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2418,33 +2394,30 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArrays - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into EnumArrays - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Enumeration of values. /// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` /// which helps with FFI. #[allow(non_camel_case_types)] #[repr(C)] -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] pub enum EnumClass { #[serde(rename = "_abc")] @@ -2478,36 +2451,42 @@ impl std::str::FromStr for EnumClass { } } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumTest { - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub enum_string: Option, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_string_required")] pub enum_string_required: String, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_integer")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub enum_integer: Option, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_number")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub enum_number: Option, #[serde(rename = "outerEnum")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub outer_enum: Option, + } + impl EnumTest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(enum_string_required: String) -> EnumTest { + pub fn new(enum_string_required: String, ) -> EnumTest { EnumTest { enum_string: None, enum_string_required, @@ -2524,18 +2503,36 @@ impl EnumTest { impl std::string::ToString for EnumTest { fn to_string(&self) -> String { let params: Vec> = vec![ - self.enum_string - .as_ref() - .map(|enum_string| ["enum_string".to_string(), enum_string.to_string()].join(",")), + + self.enum_string.as_ref().map(|enum_string| { + [ + "enum_string".to_string(), + enum_string.to_string(), + ].join(",") + }), + + Some("enum_string_required".to_string()), Some(self.enum_string_required.to_string()), + + self.enum_integer.as_ref().map(|enum_integer| { - ["enum_integer".to_string(), enum_integer.to_string()].join(",") + [ + "enum_integer".to_string(), + enum_integer.to_string(), + ].join(",") }), - self.enum_number - .as_ref() - .map(|enum_number| ["enum_number".to_string(), enum_number.to_string()].join(",")), + + + self.enum_number.as_ref().map(|enum_number| { + [ + "enum_number".to_string(), + enum_number.to_string(), + ].join(",") + }), + // Skipping outerEnum in query parameter serialization + ]; params.into_iter().flatten().collect::>().join(",") @@ -2569,42 +2566,23 @@ impl std::str::FromStr for EnumTest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing EnumTest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing EnumTest".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "enum_string" => intermediate_rep.enum_string.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "enum_string" => intermediate_rep.enum_string.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_string_required" => intermediate_rep.enum_string_required.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "enum_string_required" => intermediate_rep.enum_string_required.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_integer" => intermediate_rep.enum_integer.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "enum_integer" => intermediate_rep.enum_integer.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_number" => intermediate_rep.enum_number.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "enum_number" => intermediate_rep.enum_number.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "outerEnum" => intermediate_rep.outer_enum.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing EnumTest".to_string(), - ) - } + "outerEnum" => intermediate_rep.outer_enum.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing EnumTest".to_string()) } } @@ -2615,11 +2593,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_else(|| "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(), @@ -2633,16 +2607,13 @@ impl std::str::FromStr for EnumTest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for EnumTest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumTest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2653,83 +2624,102 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into EnumTest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct FormatTest { #[serde(rename = "integer")] - #[validate(range(min = 10, max = 100))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + range(min = 10, max = 100), + )] + #[serde(skip_serializing_if="Option::is_none")] pub integer: Option, #[serde(rename = "int32")] - #[validate(range(min = 20, max = 200))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + range(min = 20, max = 200), + )] + #[serde(skip_serializing_if="Option::is_none")] pub int32: Option, #[serde(rename = "int64")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub int64: Option, #[serde(rename = "number")] - #[validate(range(min = 32.1, max = 543.2))] + #[validate( + range(min = 32.1, max = 543.2), + )] pub number: f64, #[serde(rename = "float")] - #[validate(range(min = 54.3, max = 987.6))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + range(min = 54.3, max = 987.6), + )] + #[serde(skip_serializing_if="Option::is_none")] pub float: Option, #[serde(rename = "double")] - #[validate(range(min = 67.8, max = 123.4))] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + range(min = 67.8, max = 123.4), + )] + #[serde(skip_serializing_if="Option::is_none")] pub double: Option, #[serde(rename = "string")] - #[validate(regex = "RE_FORMATTEST_STRING")] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + regex = "RE_FORMATTEST_STRING", + )] + #[serde(skip_serializing_if="Option::is_none")] pub string: Option, #[serde(rename = "byte")] - #[validate(custom = "validate_byte_formattest_byte")] + #[validate( + custom ="validate_byte_formattest_byte" + )] pub byte: ByteArray, #[serde(rename = "binary")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub binary: Option, #[serde(rename = "date")] pub date: chrono::naive::NaiveDate, #[serde(rename = "dateTime")] - #[serde(skip_serializing_if = "Option::is_none")] - pub date_time: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub date_time: Option>, #[serde(rename = "uuid")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub uuid: Option, #[serde(rename = "password")] - #[validate(length(min = 10, max = 64))] + #[validate( + length(min = 10, max = 64), + )] pub password: String, + } lazy_static::lazy_static! { @@ -2739,7 +2729,7 @@ lazy_static::lazy_static! { static ref RE_FORMATTEST_BYTE: regex::bytes::Regex = regex::bytes::Regex::new(r"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$").unwrap(); } fn validate_byte_formattest_byte( - b: &ByteArray, + b: &ByteArray ) -> std::result::Result<(), validator::ValidationError> { if !RE_FORMATTEST_BYTE.is_match(&b.0) { return Err(validator::ValidationError::new("Character not allowed")); @@ -2749,12 +2739,7 @@ fn validate_byte_formattest_byte( impl FormatTest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new( - number: f64, - byte: ByteArray, - date: chrono::naive::NaiveDate, - password: String, - ) -> FormatTest { + pub fn new(number: f64, byte: ByteArray, date: chrono::naive::NaiveDate, password: String, ) -> FormatTest { FormatTest { integer: None, int32: None, @@ -2779,26 +2764,58 @@ impl FormatTest { impl std::string::ToString for FormatTest { fn to_string(&self) -> String { let params: Vec> = vec![ - self.integer - .as_ref() - .map(|integer| ["integer".to_string(), integer.to_string()].join(",")), - self.int32 - .as_ref() - .map(|int32| ["int32".to_string(), int32.to_string()].join(",")), - self.int64 - .as_ref() - .map(|int64| ["int64".to_string(), int64.to_string()].join(",")), + + self.integer.as_ref().map(|integer| { + [ + "integer".to_string(), + integer.to_string(), + ].join(",") + }), + + + self.int32.as_ref().map(|int32| { + [ + "int32".to_string(), + int32.to_string(), + ].join(",") + }), + + + self.int64.as_ref().map(|int64| { + [ + "int64".to_string(), + int64.to_string(), + ].join(",") + }), + + Some("number".to_string()), Some(self.number.to_string()), - self.float - .as_ref() - .map(|float| ["float".to_string(), float.to_string()].join(",")), - self.double - .as_ref() - .map(|double| ["double".to_string(), double.to_string()].join(",")), - self.string - .as_ref() - .map(|string| ["string".to_string(), string.to_string()].join(",")), + + + self.float.as_ref().map(|float| { + [ + "float".to_string(), + float.to_string(), + ].join(",") + }), + + + self.double.as_ref().map(|double| { + [ + "double".to_string(), + double.to_string(), + ].join(",") + }), + + + self.string.as_ref().map(|string| { + [ + "string".to_string(), + string.to_string(), + ].join(",") + }), + // Skipping byte in query parameter serialization // Skipping byte in query parameter serialization @@ -2810,8 +2827,11 @@ impl std::string::ToString for FormatTest { // Skipping dateTime in query parameter serialization // Skipping uuid in query parameter serialization + + Some("password".to_string()), Some(self.password.to_string()), + ]; params.into_iter().flatten().collect::>().join(",") @@ -2839,7 +2859,7 @@ impl std::str::FromStr for FormatTest { pub byte: Vec, pub binary: Vec, pub date: Vec, - pub date_time: Vec>, + pub date_time: Vec>, pub uuid: Vec, pub password: Vec, } @@ -2853,80 +2873,37 @@ impl std::str::FromStr for FormatTest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing FormatTest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing FormatTest".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "integer" => intermediate_rep - .integer - .push(::from_str(val).map_err(|x| x.to_string())?), + "integer" => intermediate_rep.integer.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "int32" => intermediate_rep.int32.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "int32" => intermediate_rep.int32.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "int64" => intermediate_rep.int64.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "int64" => intermediate_rep.int64.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "number" => intermediate_rep.number.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "number" => intermediate_rep.number.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "float" => intermediate_rep.float.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "float" => intermediate_rep.float.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "double" => intermediate_rep.double.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "double" => intermediate_rep.double.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "string" => intermediate_rep.string.push( - ::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(), - ) - } + "string" => intermediate_rep.string.push(::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( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), + "date" => intermediate_rep.date.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "dateTime" => intermediate_rep.date_time.push( - as std::str::FromStr>::from_str(val) - .map_err(|x| x.to_string())?, - ), + "dateTime" => intermediate_rep.date_time.push( as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "uuid" => intermediate_rep.uuid.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), + "uuid" => intermediate_rep.uuid.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "password" => intermediate_rep.password.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing FormatTest".to_string(), - ) - } + "password" => intermediate_rep.password.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing FormatTest".to_string()) } } @@ -2939,32 +2916,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_else(|| "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_else(|| "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_else(|| "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_else(|| "password missing in FormatTest".to_string())?, + password: intermediate_rep.password.into_iter().next().ok_or_else(|| "password missing in FormatTest".to_string())?, }) } } @@ -2975,16 +2936,13 @@ impl std::str::FromStr for FormatTest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for FormatTest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for FormatTest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -2995,37 +2953,41 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into FormatTest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into FormatTest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct HasOnlyReadOnly { #[serde(rename = "bar")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub bar: Option, #[serde(rename = "foo")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub foo: Option, + } + impl HasOnlyReadOnly { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> HasOnlyReadOnly { @@ -3042,12 +3004,22 @@ impl HasOnlyReadOnly { impl std::string::ToString for HasOnlyReadOnly { fn to_string(&self) -> String { let params: Vec> = vec![ - self.bar - .as_ref() - .map(|bar| ["bar".to_string(), bar.to_string()].join(",")), - self.foo - .as_ref() - .map(|foo| ["foo".to_string(), foo.to_string()].join(",")), + + self.bar.as_ref().map(|bar| { + [ + "bar".to_string(), + bar.to_string(), + ].join(",") + }), + + + self.foo.as_ref().map(|foo| { + [ + "foo".to_string(), + foo.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -3078,29 +3050,17 @@ impl std::str::FromStr for HasOnlyReadOnly { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing HasOnlyReadOnly".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing HasOnlyReadOnly".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "bar" => intermediate_rep.bar.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "bar" => intermediate_rep.bar.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "foo" => intermediate_rep.foo.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing HasOnlyReadOnly".to_string(), - ) - } + "foo" => intermediate_rep.foo.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing HasOnlyReadOnly".to_string()) } } @@ -3122,16 +3082,13 @@ impl std::str::FromStr for HasOnlyReadOnly { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for HasOnlyReadOnly - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for HasOnlyReadOnly - value: {} is invalid {}", + hdr_value, e)) } } } @@ -3142,33 +3099,37 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into HasOnlyReadOnly - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into HasOnlyReadOnly - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct List { #[serde(rename = "123-list")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub param_123_list: Option, + } + impl List { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> List { @@ -3183,10 +3144,16 @@ impl List { /// Should be implemented in a serde serializer impl std::string::ToString for List { fn to_string(&self) -> String { - let params: Vec> = vec![self - .param_123_list - .as_ref() - .map(|param_123_list| ["123-list".to_string(), param_123_list.to_string()].join(","))]; + let params: Vec> = vec![ + + self.param_123_list.as_ref().map(|param_123_list| { + [ + "123-list".to_string(), + param_123_list.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -3215,23 +3182,15 @@ impl std::str::FromStr for List { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing List".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing List".to_string()) }; 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( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing List".to_string(), - ) - } + "123-list" => intermediate_rep.param_123_list.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing List".to_string()) } } @@ -3252,16 +3211,13 @@ impl std::str::FromStr for List { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for List - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for List - value: {} is invalid {}", + hdr_value, e)) } } } @@ -3272,43 +3228,47 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into List - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into List - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MapTest { #[serde(rename = "map_map_of_string")] - #[serde(skip_serializing_if = "Option::is_none")] - pub map_map_of_string: - Option>>, + #[serde(skip_serializing_if="Option::is_none")] + pub map_map_of_string: Option>>, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "map_map_of_enum")] - #[serde(skip_serializing_if = "Option::is_none")] - pub map_map_of_enum: - Option>>, + #[serde(skip_serializing_if="Option::is_none")] + pub map_map_of_enum: Option>>, - /// Note: inline enums are not fully supported by openapi-generator +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "map_of_enum_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub map_of_enum_string: Option>, + } + impl MapTest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> MapTest { @@ -3351,10 +3311,8 @@ impl std::str::FromStr for MapTest { #[derive(Default)] #[allow(dead_code)] struct IntermediateRep { - pub map_map_of_string: - Vec>>, - pub map_map_of_enum: - Vec>>, + pub map_map_of_string: Vec>>, + pub map_map_of_enum: Vec>>, pub map_of_enum_string: Vec>, } @@ -3367,39 +3325,16 @@ impl std::str::FromStr for MapTest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing MapTest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing MapTest".to_string()) }; 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(), - ) - } - "map_of_enum_string" => { - return std::result::Result::Err( - "Parsing a container in this style is not supported in MapTest" - .to_string(), - ) - } - _ => { - return std::result::Result::Err( - "Unexpected key while parsing MapTest".to_string(), - ) - } + "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()), + "map_of_enum_string" => return std::result::Result::Err("Parsing a container in this style is not supported in MapTest".to_string()), + _ => return std::result::Result::Err("Unexpected key while parsing MapTest".to_string()) } } @@ -3422,16 +3357,13 @@ impl std::str::FromStr for MapTest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for MapTest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MapTest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -3442,41 +3374,45 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MapTest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into MapTest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MixedPropertiesAndAdditionalPropertiesClass { #[serde(rename = "uuid")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub uuid: Option, #[serde(rename = "dateTime")] - #[serde(skip_serializing_if = "Option::is_none")] - pub date_time: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub date_time: Option>, #[serde(rename = "map")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub map: Option>, + } + impl MixedPropertiesAndAdditionalPropertiesClass { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> MixedPropertiesAndAdditionalPropertiesClass { @@ -3519,7 +3455,7 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { #[allow(dead_code)] struct IntermediateRep { pub uuid: Vec, - pub date_time: Vec>, + pub date_time: Vec>, pub map: Vec>, } @@ -3530,14 +3466,10 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { let mut key_result = string_iter.next(); while key_result.is_some() { - let val = - match string_iter.next() { - Some(x) => x, - None => return std::result::Result::Err( - "Missing value while parsing MixedPropertiesAndAdditionalPropertiesClass" - .to_string(), - ), - }; + let val = match string_iter.next() { + Some(x) => x, + None => return std::result::Result::Err("Missing value while parsing MixedPropertiesAndAdditionalPropertiesClass".to_string()) + }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] @@ -3567,14 +3499,10 @@ impl std::str::FromStr for MixedPropertiesAndAdditionalPropertiesClass { // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl std::convert::TryFrom> - for HeaderValue -{ +impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { std::result::Result::Ok(value) => std::result::Result::Ok(value), @@ -3586,9 +3514,7 @@ impl std::convert::TryFrom - for header::IntoHeaderValue -{ +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { @@ -3608,20 +3534,27 @@ impl std::convert::TryFrom } } + + + /// Model for testing model name starting with number + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Model200Response { #[serde(rename = "name")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub name: Option, #[serde(rename = "class")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub class: Option, + } + impl Model200Response { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Model200Response { @@ -3638,12 +3571,22 @@ impl Model200Response { impl std::string::ToString for Model200Response { fn to_string(&self) -> String { let params: Vec> = vec![ - self.name - .as_ref() - .map(|name| ["name".to_string(), name.to_string()].join(",")), - self.class - .as_ref() - .map(|class| ["class".to_string(), class.to_string()].join(",")), + + self.name.as_ref().map(|name| { + [ + "name".to_string(), + name.to_string(), + ].join(",") + }), + + + self.class.as_ref().map(|class| { + [ + "class".to_string(), + class.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -3674,29 +3617,17 @@ impl std::str::FromStr for Model200Response { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Model200Response".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Model200Response".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "class" => intermediate_rep.class.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Model200Response".to_string(), - ) - } + "class" => intermediate_rep.class.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Model200Response".to_string()) } } @@ -3718,16 +3649,13 @@ impl std::str::FromStr for Model200Response { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Model200Response - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Model200Response - value: {} is invalid {}", + hdr_value, e)) } } } @@ -3738,27 +3666,28 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Model200Response - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Model200Response - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Model for testing model name same as property name + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Name { @@ -3766,21 +3695,23 @@ pub struct Name { pub name: i32, #[serde(rename = "snake_case")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub snake_case: Option, #[serde(rename = "property")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub property: Option, #[serde(rename = "123Number")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub param_123_number: Option, + } + impl Name { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(name: i32) -> Name { + pub fn new(name: i32, ) -> Name { Name { name, snake_case: None, @@ -3796,17 +3727,34 @@ impl Name { impl std::string::ToString for Name { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("name".to_string()), Some(self.name.to_string()), - self.snake_case - .as_ref() - .map(|snake_case| ["snake_case".to_string(), snake_case.to_string()].join(",")), - self.property - .as_ref() - .map(|property| ["property".to_string(), property.to_string()].join(",")), - self.param_123_number.as_ref().map(|param_123_number| { - ["123Number".to_string(), param_123_number.to_string()].join(",") + + + self.snake_case.as_ref().map(|snake_case| { + [ + "snake_case".to_string(), + snake_case.to_string(), + ].join(",") }), + + + self.property.as_ref().map(|property| { + [ + "property".to_string(), + property.to_string(), + ].join(",") + }), + + + self.param_123_number.as_ref().map(|param_123_number| { + [ + "123Number".to_string(), + param_123_number.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -3839,35 +3787,21 @@ impl std::str::FromStr for Name { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Name".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Name".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "snake_case" => intermediate_rep.snake_case.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "snake_case" => intermediate_rep.snake_case.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "property" => intermediate_rep.property.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "property" => intermediate_rep.property.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "123Number" => intermediate_rep.param_123_number.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Name".to_string(), - ) - } + "123Number" => intermediate_rep.param_123_number.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Name".to_string()) } } @@ -3877,11 +3811,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_else(|| "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(), @@ -3895,16 +3825,13 @@ impl std::str::FromStr for Name { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Name - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Name - value: {} is invalid {}", + hdr_value, e)) } } } @@ -3915,35 +3842,43 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Name - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Name - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct NumberOnly { #[serde(rename = "JustNumber")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub just_number: Option, + } + impl NumberOnly { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> NumberOnly { - NumberOnly { just_number: None } + NumberOnly { + just_number: None, + } } } @@ -3952,10 +3887,16 @@ impl NumberOnly { /// Should be implemented in a serde serializer impl std::string::ToString for NumberOnly { fn to_string(&self) -> String { - let params: Vec> = vec![self - .just_number - .as_ref() - .map(|just_number| ["JustNumber".to_string(), just_number.to_string()].join(","))]; + let params: Vec> = vec![ + + self.just_number.as_ref().map(|just_number| { + [ + "JustNumber".to_string(), + just_number.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -3984,25 +3925,15 @@ impl std::str::FromStr for NumberOnly { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing NumberOnly".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing NumberOnly".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "JustNumber" => intermediate_rep.just_number.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing NumberOnly".to_string(), - ) - } + "JustNumber" => intermediate_rep.just_number.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing NumberOnly".to_string()) } } @@ -4023,16 +3954,13 @@ impl std::str::FromStr for NumberOnly { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for NumberOnly - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for NumberOnly - value: {} is invalid {}", + hdr_value, e)) } } } @@ -4043,37 +3971,43 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into NumberOnly - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into NumberOnly - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectContainingObjectWithOnlyAdditionalProperties { #[serde(rename = "inner")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub inner: Option, + } + impl ObjectContainingObjectWithOnlyAdditionalProperties { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ObjectContainingObjectWithOnlyAdditionalProperties { - ObjectContainingObjectWithOnlyAdditionalProperties { inner: None } + ObjectContainingObjectWithOnlyAdditionalProperties { + inner: None, + } } } @@ -4140,16 +4074,10 @@ impl std::str::FromStr for ObjectContainingObjectWithOnlyAdditionalProperties { // Methods for converting between header::IntoHeaderValue and HeaderValue #[cfg(feature = "server")] -impl - std::convert::TryFrom< - header::IntoHeaderValue, - > for HeaderValue -{ +impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { std::result::Result::Ok(value) => std::result::Result::Ok(value), @@ -4161,9 +4089,7 @@ impl } #[cfg(feature = "server")] -impl std::convert::TryFrom - for header::IntoHeaderValue -{ +impl std::convert::TryFrom for header::IntoHeaderValue { type Error = String; fn try_from(hdr_value: HeaderValue) -> std::result::Result { @@ -4183,6 +4109,9 @@ impl std::convert::TryFrom } } + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectWithOnlyAdditionalProperties(std::collections::HashMap); @@ -4193,17 +4122,13 @@ impl validator::Validate for ObjectWithOnlyAdditionalProperties { } } -impl std::convert::From> - for ObjectWithOnlyAdditionalProperties -{ +impl std::convert::From> for ObjectWithOnlyAdditionalProperties { fn from(x: std::collections::HashMap) -> Self { ObjectWithOnlyAdditionalProperties(x) } } -impl std::convert::From - for std::collections::HashMap -{ +impl std::convert::From for std::collections::HashMap { fn from(x: ObjectWithOnlyAdditionalProperties) -> Self { x.0 } @@ -4239,42 +4164,46 @@ impl ::std::str::FromStr for ObjectWithOnlyAdditionalProperties { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err( - "Parsing additionalProperties for ObjectWithOnlyAdditionalProperties is not supported", - ) + std::result::Result::Err("Parsing additionalProperties for ObjectWithOnlyAdditionalProperties is not supported") } } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Order { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "petId")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub pet_id: Option, #[serde(rename = "quantity")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ship_date: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub ship_date: Option>, - /// Order Status - /// Note: inline enums are not fully supported by openapi-generator +/// Order Status +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub status: Option, #[serde(rename = "complete")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub complete: Option, + } + impl Order { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Order { @@ -4295,22 +4224,48 @@ impl Order { impl std::string::ToString for Order { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.pet_id - .as_ref() - .map(|pet_id| ["petId".to_string(), pet_id.to_string()].join(",")), - self.quantity - .as_ref() - .map(|quantity| ["quantity".to_string(), quantity.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.pet_id.as_ref().map(|pet_id| { + [ + "petId".to_string(), + pet_id.to_string(), + ].join(",") + }), + + + self.quantity.as_ref().map(|quantity| { + [ + "quantity".to_string(), + quantity.to_string(), + ].join(",") + }), + // Skipping shipDate in query parameter serialization - self.status - .as_ref() - .map(|status| ["status".to_string(), status.to_string()].join(",")), - self.complete - .as_ref() - .map(|complete| ["complete".to_string(), complete.to_string()].join(",")), + + + self.status.as_ref().map(|status| { + [ + "status".to_string(), + status.to_string(), + ].join(",") + }), + + + self.complete.as_ref().map(|complete| { + [ + "complete".to_string(), + complete.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -4331,7 +4286,7 @@ impl std::str::FromStr for Order { pub id: Vec, pub pet_id: Vec, pub quantity: Vec, - pub ship_date: Vec>, + pub ship_date: Vec>, pub status: Vec, pub complete: Vec, } @@ -4345,46 +4300,25 @@ impl std::str::FromStr for Order { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Order".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Order".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "petId" => intermediate_rep.pet_id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "petId" => intermediate_rep.pet_id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "quantity" => intermediate_rep.quantity.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "quantity" => intermediate_rep.quantity.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "shipDate" => intermediate_rep.ship_date.push( - as std::str::FromStr>::from_str(val) - .map_err(|x| x.to_string())?, - ), + "shipDate" => intermediate_rep.ship_date.push( as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "status" => intermediate_rep.status.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "complete" => intermediate_rep.complete.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Order".to_string(), - ) - } + "complete" => intermediate_rep.complete.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) } } @@ -4410,16 +4344,13 @@ impl std::str::FromStr for Order { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Order - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Order - value: {} is invalid {}", + hdr_value, e)) } } } @@ -4430,23 +4361,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Order - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Order - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterBoolean(bool); @@ -4482,22 +4414,29 @@ impl std::ops::DerefMut for OuterBoolean { } } + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterComposite { #[serde(rename = "my_number")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub my_number: Option, #[serde(rename = "my_string")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub my_string: Option, #[serde(rename = "my_boolean")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub my_boolean: Option, + } + impl OuterComposite { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> OuterComposite { @@ -4515,15 +4454,30 @@ impl OuterComposite { impl std::string::ToString for OuterComposite { fn to_string(&self) -> String { let params: Vec> = vec![ - self.my_number - .as_ref() - .map(|my_number| ["my_number".to_string(), my_number.to_string()].join(",")), - self.my_string - .as_ref() - .map(|my_string| ["my_string".to_string(), my_string.to_string()].join(",")), - self.my_boolean - .as_ref() - .map(|my_boolean| ["my_boolean".to_string(), my_boolean.to_string()].join(",")), + + self.my_number.as_ref().map(|my_number| { + [ + "my_number".to_string(), + my_number.to_string(), + ].join(",") + }), + + + self.my_string.as_ref().map(|my_string| { + [ + "my_string".to_string(), + my_string.to_string(), + ].join(",") + }), + + + self.my_boolean.as_ref().map(|my_boolean| { + [ + "my_boolean".to_string(), + my_boolean.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -4555,33 +4509,19 @@ impl std::str::FromStr for OuterComposite { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing OuterComposite".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing OuterComposite".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "my_number" => intermediate_rep.my_number.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "my_number" => intermediate_rep.my_number.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "my_string" => intermediate_rep.my_string.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "my_string" => intermediate_rep.my_string.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "my_boolean" => intermediate_rep.my_boolean.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing OuterComposite".to_string(), - ) - } + "my_boolean" => intermediate_rep.my_boolean.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing OuterComposite".to_string()) } } @@ -4604,16 +4544,13 @@ impl std::str::FromStr for OuterComposite { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for OuterComposite - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OuterComposite - value: {} is invalid {}", + hdr_value, e)) } } } @@ -4624,33 +4561,30 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterComposite - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into OuterComposite - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Enumeration of values. /// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` /// which helps with FFI. #[allow(non_camel_case_types)] #[repr(C)] -#[derive( - Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, -)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] pub enum OuterEnum { #[serde(rename = "placed")] @@ -4684,6 +4618,7 @@ impl std::str::FromStr for OuterEnum { } } + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterNumber(f64); @@ -4719,6 +4654,8 @@ impl std::ops::DerefMut for OuterNumber { } } + + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterString(String); @@ -4737,7 +4674,7 @@ impl std::convert::From for OuterString { impl std::string::ToString for OuterString { fn to_string(&self) -> String { - self.0.to_string() + self.0.to_string() } } @@ -4767,15 +4704,20 @@ impl std::ops::DerefMut for OuterString { } } + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Pet { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "category")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub category: Option, #[serde(rename = "name")] @@ -4785,19 +4727,21 @@ pub struct Pet { pub photo_urls: Vec, #[serde(rename = "tags")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub tags: Option>, - /// pet status in the store - /// Note: inline enums are not fully supported by openapi-generator +/// pet status in the store +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub status: Option, + } + impl Pet { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(name: String, photo_urls: Vec) -> Pet { + pub fn new(name: String, photo_urls: Vec, ) -> Pet { Pet { id: None, category: None, @@ -4815,24 +4759,34 @@ impl Pet { impl std::string::ToString for Pet { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + // Skipping category in query parameter serialization + + Some("name".to_string()), Some(self.name.to_string()), + + Some("photoUrls".to_string()), - Some( - self.photo_urls - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ), + Some(self.photo_urls.iter().map(|x| x.to_string()).collect::>().join(",")), + // Skipping tags in query parameter serialization - self.status - .as_ref() - .map(|status| ["status".to_string(), status.to_string()].join(",")), + + + self.status.as_ref().map(|status| { + [ + "status".to_string(), + status.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -4867,46 +4821,23 @@ impl std::str::FromStr for Pet { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Pet".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Pet".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "category" => intermediate_rep.category.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), + "category" => intermediate_rep.category.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::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(), - ) - } + "name" => intermediate_rep.name.push(::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( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Pet".to_string(), - ) - } + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Pet".to_string()) } } @@ -4918,16 +4849,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_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())?, + 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(), }) @@ -4943,11 +4866,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Pet - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Pet - value: {} is invalid {}", + hdr_value, e)) } } } @@ -4958,35 +4880,41 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Pet - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Pet - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ReadOnlyFirst { #[serde(rename = "bar")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub bar: Option, #[serde(rename = "baz")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub baz: Option, + } + impl ReadOnlyFirst { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ReadOnlyFirst { @@ -5003,12 +4931,22 @@ impl ReadOnlyFirst { impl std::string::ToString for ReadOnlyFirst { fn to_string(&self) -> String { let params: Vec> = vec![ - self.bar - .as_ref() - .map(|bar| ["bar".to_string(), bar.to_string()].join(",")), - self.baz - .as_ref() - .map(|baz| ["baz".to_string(), baz.to_string()].join(",")), + + self.bar.as_ref().map(|bar| { + [ + "bar".to_string(), + bar.to_string(), + ].join(",") + }), + + + self.baz.as_ref().map(|baz| { + [ + "baz".to_string(), + baz.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -5039,29 +4977,17 @@ impl std::str::FromStr for ReadOnlyFirst { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ReadOnlyFirst".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ReadOnlyFirst".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "bar" => intermediate_rep.bar.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "bar" => intermediate_rep.bar.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "baz" => intermediate_rep.baz.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ReadOnlyFirst".to_string(), - ) - } + "baz" => intermediate_rep.baz.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ReadOnlyFirst".to_string()) } } @@ -5083,16 +5009,13 @@ impl std::str::FromStr for ReadOnlyFirst { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ReadOnlyFirst - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ReadOnlyFirst - value: {} is invalid {}", + hdr_value, e)) } } } @@ -5103,39 +5026,44 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ReadOnlyFirst - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ReadOnlyFirst - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// Model for testing reserved words + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Return { #[serde(rename = "return")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub r#return: Option, + } + impl Return { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Return { - Return { r#return: None } + Return { + r#return: None, + } } } @@ -5144,10 +5072,16 @@ impl Return { /// Should be implemented in a serde serializer impl std::string::ToString for Return { fn to_string(&self) -> String { - let params: Vec> = vec![self - .r#return - .as_ref() - .map(|r#return| ["return".to_string(), r#return.to_string()].join(","))]; + let params: Vec> = vec![ + + self.r#return.as_ref().map(|r#return| { + [ + "return".to_string(), + r#return.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -5176,25 +5110,15 @@ impl std::str::FromStr for Return { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Return".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Return".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "return" => intermediate_rep.r#return.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Return".to_string(), - ) - } + "return" => intermediate_rep.r#return.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Return".to_string()) } } @@ -5215,16 +5139,13 @@ impl std::str::FromStr for Return { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Return - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Return - value: {} is invalid {}", + hdr_value, e)) } } } @@ -5235,37 +5156,41 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Return - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Return - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Tag { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "name")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + } + impl Tag { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Tag { @@ -5282,12 +5207,22 @@ impl Tag { impl std::string::ToString for Tag { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.name - .as_ref() - .map(|name| ["name".to_string(), name.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.name.as_ref().map(|name| { + [ + "name".to_string(), + name.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -5318,27 +5253,17 @@ impl std::str::FromStr for Tag { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Tag".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Tag".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Tag".to_string(), - ) - } + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Tag".to_string()) } } @@ -5363,11 +5288,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Tag - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Tag - value: {} is invalid {}", + hdr_value, e)) } } } @@ -5378,60 +5302,66 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Tag - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Tag - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct User { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "username")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub username: Option, #[serde(rename = "firstName")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub first_name: Option, #[serde(rename = "lastName")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub last_name: Option, #[serde(rename = "email")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub email: Option, #[serde(rename = "password")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub password: Option, #[serde(rename = "phone")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub phone: Option, - /// User Status +/// User Status #[serde(rename = "userStatus")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub user_status: Option, + } + impl User { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> User { @@ -5454,30 +5384,70 @@ impl User { impl std::string::ToString for User { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.username - .as_ref() - .map(|username| ["username".to_string(), username.to_string()].join(",")), - self.first_name - .as_ref() - .map(|first_name| ["firstName".to_string(), first_name.to_string()].join(",")), - self.last_name - .as_ref() - .map(|last_name| ["lastName".to_string(), last_name.to_string()].join(",")), - self.email - .as_ref() - .map(|email| ["email".to_string(), email.to_string()].join(",")), - self.password - .as_ref() - .map(|password| ["password".to_string(), password.to_string()].join(",")), - self.phone - .as_ref() - .map(|phone| ["phone".to_string(), phone.to_string()].join(",")), - self.user_status - .as_ref() - .map(|user_status| ["userStatus".to_string(), user_status.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.username.as_ref().map(|username| { + [ + "username".to_string(), + username.to_string(), + ].join(",") + }), + + + self.first_name.as_ref().map(|first_name| { + [ + "firstName".to_string(), + first_name.to_string(), + ].join(",") + }), + + + self.last_name.as_ref().map(|last_name| { + [ + "lastName".to_string(), + last_name.to_string(), + ].join(",") + }), + + + self.email.as_ref().map(|email| { + [ + "email".to_string(), + email.to_string(), + ].join(",") + }), + + + self.password.as_ref().map(|password| { + [ + "password".to_string(), + password.to_string(), + ].join(",") + }), + + + self.phone.as_ref().map(|phone| { + [ + "phone".to_string(), + phone.to_string(), + ].join(",") + }), + + + self.user_status.as_ref().map(|user_status| { + [ + "userStatus".to_string(), + user_status.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -5514,51 +5484,29 @@ impl std::str::FromStr for User { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing User".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing User".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "username" => intermediate_rep.username.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "username" => intermediate_rep.username.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "firstName" => intermediate_rep.first_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "firstName" => intermediate_rep.first_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "lastName" => intermediate_rep.last_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "lastName" => intermediate_rep.last_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "email" => intermediate_rep.email.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "email" => intermediate_rep.email.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "password" => intermediate_rep.password.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "password" => intermediate_rep.password.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "phone" => intermediate_rep.phone.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "phone" => intermediate_rep.phone.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "userStatus" => intermediate_rep.user_status.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing User".to_string(), - ) - } + "userStatus" => intermediate_rep.user_status.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing User".to_string()) } } @@ -5586,16 +5534,13 @@ impl std::str::FromStr for User { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for User - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for User - value: {} is invalid {}", + hdr_value, e)) } } } @@ -5606,19 +5551,20 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into User - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into User - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 521d140f42b8..2657be589088 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -12,18 +12,42 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{ - AddPetResponse, Api, Call123exampleResponse, CreateUserResponse, - CreateUsersWithArrayInputResponse, CreateUsersWithListInputResponse, DeleteOrderResponse, - DeletePetResponse, DeleteUserResponse, FakeOuterBooleanSerializeResponse, - FakeOuterCompositeSerializeResponse, FakeOuterNumberSerializeResponse, - FakeOuterStringSerializeResponse, FakeResponseWithNumericalDescriptionResponse, - FindPetsByStatusResponse, FindPetsByTagsResponse, GetInventoryResponse, GetOrderByIdResponse, - GetPetByIdResponse, GetUserByNameResponse, HyphenParamResponse, LoginUserResponse, - LogoutUserResponse, PlaceOrderResponse, TestBodyWithQueryParamsResponse, TestClassnameResponse, - TestClientModelResponse, TestEndpointParametersResponse, TestEnumParametersResponse, - TestInlineAdditionalPropertiesResponse, TestJsonFormDataResponse, TestSpecialTagsResponse, - UpdatePetResponse, UpdatePetWithFormResponse, UpdateUserResponse, UploadFileResponse, +use crate::{Api, + TestSpecialTagsResponse, + Call123exampleResponse, + FakeOuterBooleanSerializeResponse, + FakeOuterCompositeSerializeResponse, + FakeOuterNumberSerializeResponse, + FakeOuterStringSerializeResponse, + FakeResponseWithNumericalDescriptionResponse, + HyphenParamResponse, + TestBodyWithQueryParamsResponse, + TestClientModelResponse, + TestEndpointParametersResponse, + TestEnumParametersResponse, + TestInlineAdditionalPropertiesResponse, + TestJsonFormDataResponse, + TestClassnameResponse, + AddPetResponse, + DeletePetResponse, + FindPetsByStatusResponse, + FindPetsByTagsResponse, + GetPetByIdResponse, + UpdatePetResponse, + UpdatePetWithFormResponse, + UploadFileResponse, + DeleteOrderResponse, + GetInventoryResponse, + GetOrderByIdResponse, + PlaceOrderResponse, + CreateUserResponse, + CreateUsersWithArrayInputResponse, + CreateUsersWithListInputResponse, + DeleteUserResponse, + GetUserByNameResponse, + LoginUserResponse, + LogoutUserResponse, + UpdateUserResponse }; /// Setup API Server. @@ -34,2788 +58,3155 @@ where { // build our application with a route Router::new() - .route("/v2/another-fake/dummy", patch(test_special_tags::)) - .route( - "/v2/fake", - get(test_enum_parameters::) - .patch(test_client_model::) - .post(test_endpoint_parameters::), + .route("/v2/another-fake/dummy", + patch(test_special_tags::) ) - .route( - "/v2/fake/body-with-query-params", - put(test_body_with_query_params::), + .route("/v2/fake", + get(test_enum_parameters::).patch(test_client_model::).post(test_endpoint_parameters::) ) - .route( - "/v2/fake/hyphenParam/:hyphen_param", - get(hyphen_param::), + .route("/v2/fake/body-with-query-params", + put(test_body_with_query_params::) ) - .route( - "/v2/fake/inline-additionalProperties", - post(test_inline_additional_properties::), + .route("/v2/fake/hyphenParam/:hyphen_param", + get(hyphen_param::) ) - .route("/v2/fake/jsonFormData", get(test_json_form_data::)) - .route( - "/v2/fake/operation-with-numeric-id", - get(call123example::), + .route("/v2/fake/inline-additionalProperties", + post(test_inline_additional_properties::) ) - .route( - "/v2/fake/outer/boolean", - post(fake_outer_boolean_serialize::), + .route("/v2/fake/jsonFormData", + get(test_json_form_data::) ) - .route( - "/v2/fake/outer/composite", - post(fake_outer_composite_serialize::), + .route("/v2/fake/operation-with-numeric-id", + get(call123example::) ) - .route( - "/v2/fake/outer/number", - post(fake_outer_number_serialize::), + .route("/v2/fake/outer/boolean", + post(fake_outer_boolean_serialize::) ) - .route( - "/v2/fake/outer/string", - post(fake_outer_string_serialize::), + .route("/v2/fake/outer/composite", + post(fake_outer_composite_serialize::) ) - .route( - "/v2/fake/response-with-numerical-description", - get(fake_response_with_numerical_description::), + .route("/v2/fake/outer/number", + post(fake_outer_number_serialize::) ) - .route("/v2/fake_classname_test", patch(test_classname::)) - .route("/v2/pet", post(add_pet::).put(update_pet::)) - .route( - "/v2/pet/:pet_id", - delete(delete_pet::) - .get(get_pet_by_id::) - .post(update_pet_with_form::), + .route("/v2/fake/outer/string", + post(fake_outer_string_serialize::) ) - .route("/v2/pet/:pet_id/uploadImage", post(upload_file::)) - .route("/v2/pet/findByStatus", get(find_pets_by_status::)) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route("/v2/store/inventory", get(get_inventory::)) - .route("/v2/store/order", post(place_order::)) - .route( - "/v2/store/order/:order_id", - delete(delete_order::).get(get_order_by_id::), + .route("/v2/fake/response-with-numerical-description", + get(fake_response_with_numerical_description::) ) - .route("/v2/user", post(create_user::)) - .route( - "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), + .route("/v2/fake_classname_test", + patch(test_classname::) ) - .route( - "/v2/user/createWithArray", - post(create_users_with_array_input::), + .route("/v2/pet", + post(add_pet::).put(update_pet::) ) - .route( - "/v2/user/createWithList", - post(create_users_with_list_input::), + .route("/v2/pet/:pet_id", + delete(delete_pet::).get(get_pet_by_id::).post(update_pet_with_form::) + ) + .route("/v2/pet/:pet_id/uploadImage", + post(upload_file::) + ) + .route("/v2/pet/findByStatus", + get(find_pets_by_status::) + ) + .route("/v2/pet/findByTags", + get(find_pets_by_tags::) + ) + .route("/v2/store/inventory", + get(get_inventory::) + ) + .route("/v2/store/order", + post(place_order::) + ) + .route("/v2/store/order/:order_id", + delete(delete_order::).get(get_order_by_id::) + ) + .route("/v2/user", + post(create_user::) + ) + .route("/v2/user/:username", + delete(delete_user::).get(get_user_by_name::).put(update_user::) + ) + .route("/v2/user/createWithArray", + post(create_users_with_array_input::) + ) + .route("/v2/user/createWithList", + post(create_users_with_list_input::) + ) + .route("/v2/user/login", + get(login_user::) + ) + .route("/v2/user/logout", + get(logout_user::) ) - .route("/v2/user/login", get(login_user::)) - .route("/v2/user/logout", get(logout_user::)) .with_state(api_impl) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct TestSpecialTagsBodyValidator<'a> { - #[validate] - body: &'a models::Client, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct TestSpecialTagsBodyValidator<'a> { + #[validate] + body: &'a models::Client, + } + #[tracing::instrument(skip_all)] fn test_special_tags_validation( - body: models::Client, -) -> std::result::Result<(models::Client,), ValidationErrors> { - let b = TestSpecialTagsBodyValidator { body: &body }; - b.validate()?; + body: models::Client, +) -> std::result::Result<( + models::Client, +), ValidationErrors> +{ + let b = TestSpecialTagsBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// TestSpecialTags - PATCH /v2/another-fake/dummy #[tracing::instrument(skip_all)] async fn test_special_tags( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || test_special_tags_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_special_tags_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_special_tags(method, host, cookies, body) - .await; + let result = api_impl.as_ref().test_special_tags( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestSpecialTagsResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + TestSpecialTagsResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn call123example_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn call123example_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// Call123example - GET /v2/fake/operation-with-numeric-id #[tracing::instrument(skip_all)] async fn call123example( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || call123example_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + call123example_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .call123example(method, host, cookies) - .await; + let result = api_impl.as_ref().call123example( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - Call123exampleResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + Call123exampleResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct FakeOuterBooleanSerializeBodyValidator<'a> { - #[validate] - body: &'a models::OuterBoolean, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct FakeOuterBooleanSerializeBodyValidator<'a> { + #[validate] + body: &'a models::OuterBoolean, + } + #[tracing::instrument(skip_all)] fn fake_outer_boolean_serialize_validation( - body: Option, -) -> std::result::Result<(Option,), ValidationErrors> { - if let Some(body) = &body { - let b = FakeOuterBooleanSerializeBodyValidator { body }; - b.validate()?; - } + body: Option, +) -> std::result::Result<( + Option, +), ValidationErrors> +{ + if let Some(body) = &body { + let b = FakeOuterBooleanSerializeBodyValidator { body }; + b.validate()?; + } - Ok((body,)) +Ok(( + body, +)) } /// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean #[tracing::instrument(skip_all)] async fn fake_outer_boolean_serialize( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || fake_outer_boolean_serialize_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + fake_outer_boolean_serialize_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .fake_outer_boolean_serialize(method, host, cookies, body) - .await; + let result = api_impl.as_ref().fake_outer_boolean_serialize( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FakeOuterBooleanSerializeResponse::Status200_OutputBoolean(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FakeOuterBooleanSerializeResponse::Status200_OutputBoolean + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct FakeOuterCompositeSerializeBodyValidator<'a> { - #[validate] - body: &'a models::OuterComposite, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct FakeOuterCompositeSerializeBodyValidator<'a> { + #[validate] + body: &'a models::OuterComposite, + } + #[tracing::instrument(skip_all)] fn fake_outer_composite_serialize_validation( - body: Option, -) -> std::result::Result<(Option,), ValidationErrors> { - if let Some(body) = &body { - let b = FakeOuterCompositeSerializeBodyValidator { body }; - b.validate()?; - } + body: Option, +) -> std::result::Result<( + Option, +), ValidationErrors> +{ + if let Some(body) = &body { + let b = FakeOuterCompositeSerializeBodyValidator { body }; + b.validate()?; + } - Ok((body,)) +Ok(( + body, +)) } /// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite #[tracing::instrument(skip_all)] async fn fake_outer_composite_serialize( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || fake_outer_composite_serialize_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + fake_outer_composite_serialize_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .fake_outer_composite_serialize(method, host, cookies, body) - .await; + let result = api_impl.as_ref().fake_outer_composite_serialize( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FakeOuterCompositeSerializeResponse::Status200_OutputComposite(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FakeOuterCompositeSerializeResponse::Status200_OutputComposite + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct FakeOuterNumberSerializeBodyValidator<'a> { - #[validate] - body: &'a models::OuterNumber, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct FakeOuterNumberSerializeBodyValidator<'a> { + #[validate] + body: &'a models::OuterNumber, + } + #[tracing::instrument(skip_all)] fn fake_outer_number_serialize_validation( - body: Option, -) -> std::result::Result<(Option,), ValidationErrors> { - if let Some(body) = &body { - let b = FakeOuterNumberSerializeBodyValidator { body }; - b.validate()?; - } + body: Option, +) -> std::result::Result<( + Option, +), ValidationErrors> +{ + if let Some(body) = &body { + let b = FakeOuterNumberSerializeBodyValidator { body }; + b.validate()?; + } - Ok((body,)) +Ok(( + body, +)) } /// FakeOuterNumberSerialize - POST /v2/fake/outer/number #[tracing::instrument(skip_all)] async fn fake_outer_number_serialize( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || fake_outer_number_serialize_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + fake_outer_number_serialize_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .fake_outer_number_serialize(method, host, cookies, body) - .await; + let result = api_impl.as_ref().fake_outer_number_serialize( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FakeOuterNumberSerializeResponse::Status200_OutputNumber(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FakeOuterNumberSerializeResponse::Status200_OutputNumber + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct FakeOuterStringSerializeBodyValidator<'a> { - #[validate] - body: &'a models::OuterString, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct FakeOuterStringSerializeBodyValidator<'a> { + #[validate] + body: &'a models::OuterString, + } + #[tracing::instrument(skip_all)] fn fake_outer_string_serialize_validation( - body: Option, -) -> std::result::Result<(Option,), ValidationErrors> { - if let Some(body) = &body { - let b = FakeOuterStringSerializeBodyValidator { body }; - b.validate()?; - } + body: Option, +) -> std::result::Result<( + Option, +), ValidationErrors> +{ + if let Some(body) = &body { + let b = FakeOuterStringSerializeBodyValidator { body }; + b.validate()?; + } - Ok((body,)) +Ok(( + body, +)) } /// FakeOuterStringSerialize - POST /v2/fake/outer/string #[tracing::instrument(skip_all)] async fn fake_outer_string_serialize( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || fake_outer_string_serialize_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + fake_outer_string_serialize_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .fake_outer_string_serialize(method, host, cookies, body) - .await; + let result = api_impl.as_ref().fake_outer_string_serialize( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FakeOuterStringSerializeResponse::Status200_OutputString(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FakeOuterStringSerializeResponse::Status200_OutputString + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn fake_response_with_numerical_description_validation() -> std::result::Result<(), ValidationErrors> +fn fake_response_with_numerical_description_validation( +) -> std::result::Result<( +), ValidationErrors> { - Ok(()) + +Ok(( +)) } /// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description #[tracing::instrument(skip_all)] async fn fake_response_with_numerical_description( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || fake_response_with_numerical_description_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + fake_response_with_numerical_description_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .fake_response_with_numerical_description(method, host, cookies) - .await; + let result = api_impl.as_ref().fake_response_with_numerical_description( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FakeResponseWithNumericalDescriptionResponse::Status200 => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + FakeResponseWithNumericalDescriptionResponse::Status200 + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn hyphen_param_validation( - path_params: models::HyphenParamPathParams, -) -> std::result::Result<(models::HyphenParamPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::HyphenParamPathParams, +) -> std::result::Result<( + models::HyphenParamPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param} #[tracing::instrument(skip_all)] async fn hyphen_param( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || hyphen_param_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + hyphen_param_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .hyphen_param(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().hyphen_param( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - HyphenParamResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + HyphenParamResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct TestBodyWithQueryParamsBodyValidator<'a> { - #[validate] - body: &'a models::User, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct TestBodyWithQueryParamsBodyValidator<'a> { + #[validate] + body: &'a models::User, + } + #[tracing::instrument(skip_all)] fn test_body_with_query_params_validation( - query_params: models::TestBodyWithQueryParamsQueryParams, - body: models::User, -) -> std::result::Result<(models::TestBodyWithQueryParamsQueryParams, models::User), ValidationErrors> + query_params: models::TestBodyWithQueryParamsQueryParams, + body: models::User, +) -> std::result::Result<( + models::TestBodyWithQueryParamsQueryParams, + models::User, +), ValidationErrors> { - query_params.validate()?; - let b = TestBodyWithQueryParamsBodyValidator { body: &body }; - b.validate()?; + query_params.validate()?; + let b = TestBodyWithQueryParamsBodyValidator { body: &body }; + b.validate()?; - Ok((query_params, body)) +Ok(( + query_params, + body, +)) } /// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params #[tracing::instrument(skip_all)] async fn test_body_with_query_params( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || { - test_body_with_query_params_validation(query_params, body) - }) - .await - .unwrap(); - let Ok((query_params, body)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_body_with_query_params_validation( + query_params, + body, + ) + ).await.unwrap(); + + let Ok(( + query_params, + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_body_with_query_params(method, host, cookies, query_params, body) - .await; + let result = api_impl.as_ref().test_body_with_query_params( + method, + host, + cookies, + query_params, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestBodyWithQueryParamsResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + TestBodyWithQueryParamsResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct TestClientModelBodyValidator<'a> { - #[validate] - body: &'a models::Client, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct TestClientModelBodyValidator<'a> { + #[validate] + body: &'a models::Client, + } + #[tracing::instrument(skip_all)] fn test_client_model_validation( - body: models::Client, -) -> std::result::Result<(models::Client,), ValidationErrors> { - let b = TestClientModelBodyValidator { body: &body }; - b.validate()?; + body: models::Client, +) -> std::result::Result<( + models::Client, +), ValidationErrors> +{ + let b = TestClientModelBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// TestClientModel - PATCH /v2/fake #[tracing::instrument(skip_all)] async fn test_client_model( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || test_client_model_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_client_model_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_client_model(method, host, cookies, body) - .await; + let result = api_impl.as_ref().test_client_model( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestClientModelResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + TestClientModelResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn test_endpoint_parameters_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn test_endpoint_parameters_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// TestEndpointParameters - POST /v2/fake #[tracing::instrument(skip_all)] async fn test_endpoint_parameters( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || test_endpoint_parameters_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_endpoint_parameters_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_endpoint_parameters(method, host, cookies) - .await; + let result = api_impl.as_ref().test_endpoint_parameters( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestEndpointParametersResponse::Status400_InvalidUsernameSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - TestEndpointParametersResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + TestEndpointParametersResponse::Status400_InvalidUsernameSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + TestEndpointParametersResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn test_enum_parameters_validation( - header_params: models::TestEnumParametersHeaderParams, - query_params: models::TestEnumParametersQueryParams, -) -> std::result::Result< - ( - models::TestEnumParametersHeaderParams, - models::TestEnumParametersQueryParams, - ), - ValidationErrors, -> { - header_params.validate()?; - query_params.validate()?; + header_params: models::TestEnumParametersHeaderParams, + query_params: models::TestEnumParametersQueryParams, +) -> std::result::Result<( + models::TestEnumParametersHeaderParams, + models::TestEnumParametersQueryParams, +), ValidationErrors> +{ + header_params.validate()?; + query_params.validate()?; - Ok((header_params, query_params)) +Ok(( + header_params, + query_params, +)) } /// TestEnumParameters - GET /v2/fake #[tracing::instrument(skip_all)] async fn test_enum_parameters( - method: Method, - host: Host, - cookies: CookieJar, - headers: HeaderMap, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + headers: HeaderMap, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { // Header parameters let header_params = { - let header_enum_header_string_array = - headers.get(HeaderName::from_static("enum_header_string_array")); + let header_enum_header_string_array = headers.get(HeaderName::from_static("enum_header_string_array")); - let header_enum_header_string_array = match header_enum_header_string_array { - Some(v) => match header::IntoHeaderValue::>::try_from((*v).clone()) { - Ok(result) => Some(result.0), - Err(err) => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!( - "Invalid header enum_header_string_array - {}", - err - ))) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }, - None => None, - }; - let header_enum_header_string = headers.get(HeaderName::from_static("enum_header_string")); + let header_enum_header_string_array = match header_enum_header_string_array { + Some(v) => match header::IntoHeaderValue::>::try_from((*v).clone()) { + Ok(result) => + Some(result.0), + Err(err) => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header enum_header_string_array - {}", err))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - let header_enum_header_string = match header_enum_header_string { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { - Ok(result) => Some(result.0), - Err(err) => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!( - "Invalid header enum_header_string - {}", - err - ))) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }, - None => None, - }; + }, + }, + None => { + None + } + }; + let header_enum_header_string = headers.get(HeaderName::from_static("enum_header_string")); - models::TestEnumParametersHeaderParams { - enum_header_string_array: header_enum_header_string_array, - enum_header_string: header_enum_header_string, - } - }; + let header_enum_header_string = match header_enum_header_string { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Ok(result) => + Some(result.0), + Err(err) => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header enum_header_string - {}", err))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || { - test_enum_parameters_validation(header_params, query_params) - }) - .await - .unwrap(); + }, + }, + None => { + None + } + }; - let Ok((header_params, query_params)) = validation else { - return Response::builder() + models::TestEnumParametersHeaderParams { + enum_header_string_array: header_enum_header_string_array, + enum_header_string: header_enum_header_string, + } + }; + + + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_enum_parameters_validation( + header_params, + query_params, + ) + ).await.unwrap(); + + let Ok(( + header_params, + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_enum_parameters(method, host, cookies, header_params, query_params) - .await; + let result = api_impl.as_ref().test_enum_parameters( + method, + host, + cookies, + header_params, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestEnumParametersResponse::Status400_InvalidRequest => { - let mut response = response.status(400); - response.body(Body::empty()) - } - TestEnumParametersResponse::Status404_NotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + TestEnumParametersResponse::Status400_InvalidRequest + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + TestEnumParametersResponse::Status404_NotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct TestInlineAdditionalPropertiesBodyValidator<'a> { - body: &'a std::collections::HashMap, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct TestInlineAdditionalPropertiesBodyValidator<'a> { + body: &'a std::collections::HashMap, + } + #[tracing::instrument(skip_all)] fn test_inline_additional_properties_validation( - body: std::collections::HashMap, -) -> std::result::Result<(std::collections::HashMap,), ValidationErrors> { - let b = TestInlineAdditionalPropertiesBodyValidator { body: &body }; - b.validate()?; + body: std::collections::HashMap, +) -> std::result::Result<( + std::collections::HashMap, +), ValidationErrors> +{ + let b = TestInlineAdditionalPropertiesBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties #[tracing::instrument(skip_all)] async fn test_inline_additional_properties( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || test_inline_additional_properties_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_inline_additional_properties_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_inline_additional_properties(method, host, cookies, body) - .await; + let result = api_impl.as_ref().test_inline_additional_properties( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestInlineAdditionalPropertiesResponse::Status200_SuccessfulOperation => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + TestInlineAdditionalPropertiesResponse::Status200_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn test_json_form_data_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn test_json_form_data_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// TestJsonFormData - GET /v2/fake/jsonFormData #[tracing::instrument(skip_all)] async fn test_json_form_data( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || test_json_form_data_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_json_form_data_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_json_form_data(method, host, cookies) - .await; + let result = api_impl.as_ref().test_json_form_data( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestJsonFormDataResponse::Status200_SuccessfulOperation => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + TestJsonFormDataResponse::Status200_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct TestClassnameBodyValidator<'a> { - #[validate] - body: &'a models::Client, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct TestClassnameBodyValidator<'a> { + #[validate] + body: &'a models::Client, + } + #[tracing::instrument(skip_all)] fn test_classname_validation( - body: models::Client, -) -> std::result::Result<(models::Client,), ValidationErrors> { - let b = TestClassnameBodyValidator { body: &body }; - b.validate()?; + body: models::Client, +) -> std::result::Result<( + models::Client, +), ValidationErrors> +{ + let b = TestClassnameBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// TestClassname - PATCH /v2/fake_classname_test #[tracing::instrument(skip_all)] async fn test_classname( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || test_classname_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + test_classname_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .test_classname(method, host, cookies, body) - .await; + let result = api_impl.as_ref().test_classname( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - TestClassnameResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + TestClassnameResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct AddPetBodyValidator<'a> { - #[validate] - body: &'a models::Pet, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct AddPetBodyValidator<'a> { + #[validate] + body: &'a models::Pet, + } + #[tracing::instrument(skip_all)] -fn add_pet_validation(body: models::Pet) -> std::result::Result<(models::Pet,), ValidationErrors> { - let b = AddPetBodyValidator { body: &body }; - b.validate()?; +fn add_pet_validation( + body: models::Pet, +) -> std::result::Result<( + models::Pet, +), ValidationErrors> +{ + let b = AddPetBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// AddPet - POST /v2/pet #[tracing::instrument(skip_all)] async fn add_pet( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || add_pet_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + add_pet_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().add_pet(method, host, cookies, body).await; + let result = api_impl.as_ref().add_pet( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - AddPetResponse::Status405_InvalidInput => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + AddPetResponse::Status405_InvalidInput + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_pet_validation( - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, -) -> std::result::Result< - (models::DeletePetHeaderParams, models::DeletePetPathParams), - ValidationErrors, -> { - header_params.validate()?; - path_params.validate()?; + header_params: models::DeletePetHeaderParams, + path_params: models::DeletePetPathParams, +) -> std::result::Result<( + models::DeletePetHeaderParams, + models::DeletePetPathParams, +), ValidationErrors> +{ + header_params.validate()?; + path_params.validate()?; - Ok((header_params, path_params)) +Ok(( + header_params, + path_params, +)) } /// DeletePet - DELETE /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn delete_pet( - method: Method, - host: Host, - cookies: CookieJar, - headers: HeaderMap, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + headers: HeaderMap, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { // Header parameters let header_params = { - let header_api_key = headers.get(HeaderName::from_static("api_key")); + let header_api_key = headers.get(HeaderName::from_static("api_key")); - let header_api_key = match header_api_key { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { - Ok(result) => Some(result.0), - Err(err) => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Invalid header api_key - {}", err))) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }, - None => None, - }; + let header_api_key = match header_api_key { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Ok(result) => + Some(result.0), + Err(err) => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header api_key - {}", err))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - models::DeletePetHeaderParams { - api_key: header_api_key, - } - }; + }, + }, + None => { + None + } + }; - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || delete_pet_validation(header_params, path_params)) - .await - .unwrap(); + models::DeletePetHeaderParams { + api_key: header_api_key, + } + }; - let Ok((header_params, path_params)) = validation else { - return Response::builder() + + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_pet_validation( + header_params, + path_params, + ) + ).await.unwrap(); + + let Ok(( + header_params, + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_pet(method, host, cookies, header_params, path_params) - .await; + let result = api_impl.as_ref().delete_pet( + method, + host, + cookies, + header_params, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeletePetResponse::Status400_InvalidPetValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeletePetResponse::Status400_InvalidPetValue + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn find_pets_by_status_validation( - query_params: models::FindPetsByStatusQueryParams, -) -> std::result::Result<(models::FindPetsByStatusQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::FindPetsByStatusQueryParams, +) -> std::result::Result<( + models::FindPetsByStatusQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// FindPetsByStatus - GET /v2/pet/findByStatus #[tracing::instrument(skip_all)] async fn find_pets_by_status( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || find_pets_by_status_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + find_pets_by_status_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .find_pets_by_status(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().find_pets_by_status( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FindPetsByStatusResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FindPetsByStatusResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - FindPetsByStatusResponse::Status400_InvalidStatusValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + FindPetsByStatusResponse::Status400_InvalidStatusValue + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn find_pets_by_tags_validation( - query_params: models::FindPetsByTagsQueryParams, -) -> std::result::Result<(models::FindPetsByTagsQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::FindPetsByTagsQueryParams, +) -> std::result::Result<( + models::FindPetsByTagsQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// FindPetsByTags - GET /v2/pet/findByTags #[tracing::instrument(skip_all)] async fn find_pets_by_tags( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || find_pets_by_tags_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + find_pets_by_tags_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .find_pets_by_tags(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().find_pets_by_tags( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FindPetsByTagsResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FindPetsByTagsResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - FindPetsByTagsResponse::Status400_InvalidTagValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + FindPetsByTagsResponse::Status400_InvalidTagValue + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_pet_by_id_validation( - path_params: models::GetPetByIdPathParams, -) -> std::result::Result<(models::GetPetByIdPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetPetByIdPathParams, +) -> std::result::Result<( + models::GetPetByIdPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetPetById - GET /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn get_pet_by_id( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_pet_by_id_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_pet_by_id_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_pet_by_id(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_pet_by_id( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetPetByIdResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetPetByIdResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetPetByIdResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetPetByIdResponse::Status404_PetNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetPetByIdResponse::Status400_InvalidIDSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetPetByIdResponse::Status404_PetNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct UpdatePetBodyValidator<'a> { - #[validate] - body: &'a models::Pet, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct UpdatePetBodyValidator<'a> { + #[validate] + body: &'a models::Pet, + } + #[tracing::instrument(skip_all)] fn update_pet_validation( - body: models::Pet, -) -> std::result::Result<(models::Pet,), ValidationErrors> { - let b = UpdatePetBodyValidator { body: &body }; - b.validate()?; + body: models::Pet, +) -> std::result::Result<( + models::Pet, +), ValidationErrors> +{ + let b = UpdatePetBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// UpdatePet - PUT /v2/pet #[tracing::instrument(skip_all)] async fn update_pet( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || update_pet_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_pet_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_pet(method, host, cookies, body) - .await; + let result = api_impl.as_ref().update_pet( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdatePetResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - UpdatePetResponse::Status404_PetNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - UpdatePetResponse::Status405_ValidationException => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UpdatePetResponse::Status400_InvalidIDSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + UpdatePetResponse::Status404_PetNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + UpdatePetResponse::Status405_ValidationException + => { + + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn update_pet_with_form_validation( - path_params: models::UpdatePetWithFormPathParams, -) -> std::result::Result<(models::UpdatePetWithFormPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::UpdatePetWithFormPathParams, +) -> std::result::Result<( + models::UpdatePetWithFormPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// UpdatePetWithForm - POST /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn update_pet_with_form( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || update_pet_with_form_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_pet_with_form_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_pet_with_form(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().update_pet_with_form( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdatePetWithFormResponse::Status405_InvalidInput => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UpdatePetWithFormResponse::Status405_InvalidInput + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn upload_file_validation( - path_params: models::UploadFilePathParams, -) -> std::result::Result<(models::UploadFilePathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::UploadFilePathParams, +) -> std::result::Result<( + models::UploadFilePathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// UploadFile - POST /v2/pet/{petId}/uploadImage #[tracing::instrument(skip_all)] async fn upload_file( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, - body: Multipart, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, + body: Multipart, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || upload_file_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + upload_file_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .upload_file(method, host, cookies, path_params, body) - .await; + let result = api_impl.as_ref().upload_file( + method, + host, + cookies, + path_params, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UploadFileResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + UploadFileResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_order_validation( - path_params: models::DeleteOrderPathParams, -) -> std::result::Result<(models::DeleteOrderPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::DeleteOrderPathParams, +) -> std::result::Result<( + models::DeleteOrderPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// DeleteOrder - DELETE /v2/store/order/{order_id} #[tracing::instrument(skip_all)] async fn delete_order( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || delete_order_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_order_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_order(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().delete_order( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeleteOrderResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - DeleteOrderResponse::Status404_OrderNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeleteOrderResponse::Status400_InvalidIDSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + DeleteOrderResponse::Status404_OrderNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn get_inventory_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn get_inventory_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// GetInventory - GET /v2/store/inventory #[tracing::instrument(skip_all)] async fn get_inventory( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_inventory_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_inventory_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().get_inventory(method, host, cookies).await; + let result = api_impl.as_ref().get_inventory( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetInventoryResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetInventoryResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_order_by_id_validation( - path_params: models::GetOrderByIdPathParams, -) -> std::result::Result<(models::GetOrderByIdPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetOrderByIdPathParams, +) -> std::result::Result<( + models::GetOrderByIdPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetOrderById - GET /v2/store/order/{order_id} #[tracing::instrument(skip_all)] async fn get_order_by_id( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_order_by_id_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_order_by_id_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_order_by_id(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_order_by_id( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetOrderByIdResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetOrderByIdResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetOrderByIdResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetOrderByIdResponse::Status404_OrderNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetOrderByIdResponse::Status400_InvalidIDSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetOrderByIdResponse::Status404_OrderNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct PlaceOrderBodyValidator<'a> { - #[validate] - body: &'a models::Order, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct PlaceOrderBodyValidator<'a> { + #[validate] + body: &'a models::Order, + } + #[tracing::instrument(skip_all)] fn place_order_validation( - body: models::Order, -) -> std::result::Result<(models::Order,), ValidationErrors> { - let b = PlaceOrderBodyValidator { body: &body }; - b.validate()?; + body: models::Order, +) -> std::result::Result<( + models::Order, +), ValidationErrors> +{ + let b = PlaceOrderBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// PlaceOrder - POST /v2/store/order #[tracing::instrument(skip_all)] async fn place_order( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || place_order_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + place_order_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .place_order(method, host, cookies, body) - .await; + let result = api_impl.as_ref().place_order( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - PlaceOrderResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + PlaceOrderResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - PlaceOrderResponse::Status400_InvalidOrder => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + PlaceOrderResponse::Status400_InvalidOrder + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUserBodyValidator<'a> { - #[validate] - body: &'a models::User, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUserBodyValidator<'a> { + #[validate] + body: &'a models::User, + } + #[tracing::instrument(skip_all)] fn create_user_validation( - body: models::User, -) -> std::result::Result<(models::User,), ValidationErrors> { - let b = CreateUserBodyValidator { body: &body }; - b.validate()?; + body: models::User, +) -> std::result::Result<( + models::User, +), ValidationErrors> +{ + let b = CreateUserBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUser - POST /v2/user #[tracing::instrument(skip_all)] async fn create_user( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || create_user_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_user_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_user(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_user( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUserResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUserResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUsersWithArrayInputBodyValidator<'a> { - #[validate] - body: &'a Vec, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUsersWithArrayInputBodyValidator<'a> { + #[validate] + body: &'a Vec, + } + #[tracing::instrument(skip_all)] fn create_users_with_array_input_validation( - body: Vec, -) -> std::result::Result<(Vec,), ValidationErrors> { - let b = CreateUsersWithArrayInputBodyValidator { body: &body }; - b.validate()?; + body: Vec, +) -> std::result::Result<( + Vec, +), ValidationErrors> +{ + let b = CreateUsersWithArrayInputBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUsersWithArrayInput - POST /v2/user/createWithArray #[tracing::instrument(skip_all)] async fn create_users_with_array_input( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || create_users_with_array_input_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_users_with_array_input_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_users_with_array_input(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_users_with_array_input( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUsersWithArrayInputResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUsersWithArrayInputResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUsersWithListInputBodyValidator<'a> { - #[validate] - body: &'a Vec, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUsersWithListInputBodyValidator<'a> { + #[validate] + body: &'a Vec, + } + #[tracing::instrument(skip_all)] fn create_users_with_list_input_validation( - body: Vec, -) -> std::result::Result<(Vec,), ValidationErrors> { - let b = CreateUsersWithListInputBodyValidator { body: &body }; - b.validate()?; + body: Vec, +) -> std::result::Result<( + Vec, +), ValidationErrors> +{ + let b = CreateUsersWithListInputBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUsersWithListInput - POST /v2/user/createWithList #[tracing::instrument(skip_all)] async fn create_users_with_list_input( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || create_users_with_list_input_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_users_with_list_input_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_users_with_list_input(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_users_with_list_input( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUsersWithListInputResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUsersWithListInputResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_user_validation( - path_params: models::DeleteUserPathParams, -) -> std::result::Result<(models::DeleteUserPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::DeleteUserPathParams, +) -> std::result::Result<( + models::DeleteUserPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// DeleteUser - DELETE /v2/user/{username} #[tracing::instrument(skip_all)] async fn delete_user( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || delete_user_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_user_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_user(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().delete_user( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeleteUserResponse::Status400_InvalidUsernameSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - DeleteUserResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeleteUserResponse::Status400_InvalidUsernameSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + DeleteUserResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_user_by_name_validation( - path_params: models::GetUserByNamePathParams, -) -> std::result::Result<(models::GetUserByNamePathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetUserByNamePathParams, +) -> std::result::Result<( + models::GetUserByNamePathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetUserByName - GET /v2/user/{username} #[tracing::instrument(skip_all)] async fn get_user_by_name( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_user_by_name_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_user_by_name_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_user_by_name(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_user_by_name( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetUserByNameResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetUserByNameResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetUserByNameResponse::Status400_InvalidUsernameSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetUserByNameResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetUserByNameResponse::Status400_InvalidUsernameSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetUserByNameResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn login_user_validation( - query_params: models::LoginUserQueryParams, -) -> std::result::Result<(models::LoginUserQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::LoginUserQueryParams, +) -> std::result::Result<( + models::LoginUserQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// LoginUser - GET /v2/user/login #[tracing::instrument(skip_all)] async fn login_user( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || login_user_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + login_user_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .login_user(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().login_user( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - LoginUserResponse::Status200_SuccessfulOperation { - body, - x_rate_limit, - x_expires_after, - } => { - if let Some(x_rate_limit) = x_rate_limit { - let x_rate_limit = match header::IntoHeaderValue(x_rate_limit).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + let resp = match result { + Ok(rsp) => match rsp { + LoginUserResponse::Status200_SuccessfulOperation + { + body, + x_rate_limit, + x_expires_after + } + => { + if let Some(x_rate_limit) = x_rate_limit { + let x_rate_limit = match header::IntoHeaderValue(x_rate_limit).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling x_rate_limit header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("x-rate-limit"), x_rate_limit); - } - } - if let Some(x_expires_after) = x_expires_after { - let x_expires_after = match header::IntoHeaderValue(x_expires_after).try_into() - { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("x-rate-limit"), + x_rate_limit + ); + } + } + if let Some(x_expires_after) = x_expires_after { + let x_expires_after = match header::IntoHeaderValue(x_expires_after).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling x_expires_after header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("x-expires-after"), x_expires_after); - } - } + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("x-expires-after"), + x_expires_after + ); + } + } - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = body; - response.body(Body::from(body_content)) - } - LoginUserResponse::Status400_InvalidUsername => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let body_content = body; + response.body(Body::from(body_content)) + }, + LoginUserResponse::Status400_InvalidUsername + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn logout_user_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn logout_user_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// LogoutUser - GET /v2/user/logout #[tracing::instrument(skip_all)] async fn logout_user( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || logout_user_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + logout_user_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().logout_user(method, host, cookies).await; + let result = api_impl.as_ref().logout_user( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - LogoutUserResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + LogoutUserResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct UpdateUserBodyValidator<'a> { - #[validate] - body: &'a models::User, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct UpdateUserBodyValidator<'a> { + #[validate] + body: &'a models::User, + } + #[tracing::instrument(skip_all)] fn update_user_validation( - path_params: models::UpdateUserPathParams, - body: models::User, -) -> std::result::Result<(models::UpdateUserPathParams, models::User), ValidationErrors> { - path_params.validate()?; - let b = UpdateUserBodyValidator { body: &body }; - b.validate()?; + path_params: models::UpdateUserPathParams, + body: models::User, +) -> std::result::Result<( + models::UpdateUserPathParams, + models::User, +), ValidationErrors> +{ + path_params.validate()?; + let b = UpdateUserBodyValidator { body: &body }; + b.validate()?; - Ok((path_params, body)) +Ok(( + path_params, + body, +)) } /// UpdateUser - PUT /v2/user/{username} #[tracing::instrument(skip_all)] async fn update_user( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || update_user_validation(path_params, body)) - .await - .unwrap(); - let Ok((path_params, body)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_user_validation( + path_params, + body, + ) + ).await.unwrap(); + + let Ok(( + path_params, + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_user(method, host, cookies, path_params, body) - .await; + let result = api_impl.as_ref().update_user( + method, + host, + cookies, + path_params, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdateUserResponse::Status400_InvalidUserSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - UpdateUserResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UpdateUserResponse::Status400_InvalidUserSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + UpdateUserResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + diff --git a/samples/server/petstore/rust-axum/output/petstore/src/header.rs b/samples/server/petstore/rust-axum/output/petstore/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/header.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/lib.rs b/samples/server/petstore/rust-axum/output/petstore/src/lib.rs index eef1a4fbdc1d..287ff425af9c 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,429 +14,490 @@ use types::*; pub const BASE_PATH: &str = "/v2"; pub const API_VERSION: &str = "1.0.0"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum AddPetResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid input - Status405_InvalidInput, + Status405_InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeletePetResponse { /// Invalid pet value - Status400_InvalidPetValue, + Status400_InvalidPetValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FindPetsByStatusResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid status value - Status400_InvalidStatusValue, + Status400_InvalidStatusValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FindPetsByTagsResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid tag value - Status400_InvalidTagValue, + Status400_InvalidTagValue } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetPetByIdResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Pet not found - Status404_PetNotFound, + Status404_PetNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdatePetResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Pet not found - Status404_PetNotFound, + Status404_PetNotFound + , /// Validation exception - Status405_ValidationException, + Status405_ValidationException } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdatePetWithFormResponse { /// Invalid input - Status405_InvalidInput, + Status405_InvalidInput } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UploadFileResponse { /// successful operation - Status200_SuccessfulOperation(models::ApiResponse), + Status200_SuccessfulOperation + (models::ApiResponse) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeleteOrderResponse { /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Order not found - Status404_OrderNotFound, + Status404_OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetInventoryResponse { /// successful operation - Status200_SuccessfulOperation(std::collections::HashMap), + Status200_SuccessfulOperation + (std::collections::HashMap) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetOrderByIdResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid ID supplied - Status400_InvalidIDSupplied, + Status400_InvalidIDSupplied + , /// Order not found - Status404_OrderNotFound, + Status404_OrderNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum PlaceOrderResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid Order - Status400_InvalidOrder, + Status400_InvalidOrder } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUserResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUsersWithArrayInputResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum CreateUsersWithListInputResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DeleteUserResponse { /// Invalid username supplied - Status400_InvalidUsernameSupplied, + Status400_InvalidUsernameSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetUserByNameResponse { /// successful operation - Status200_SuccessfulOperation(String), + Status200_SuccessfulOperation + (String) + , /// Invalid username supplied - Status400_InvalidUsernameSupplied, + Status400_InvalidUsernameSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum LoginUserResponse { /// successful operation - Status200_SuccessfulOperation { + Status200_SuccessfulOperation + { body: String, - set_cookie: Option, - x_rate_limit: Option, - x_expires_after: Option>, - }, + set_cookie: + Option< + String + > + , + x_rate_limit: + Option< + i32 + > + , + x_expires_after: + Option< + chrono::DateTime:: + > + } + , /// Invalid username/password supplied - Status400_InvalidUsername, + Status400_InvalidUsername } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum LogoutUserResponse { /// successful operation - Status0_SuccessfulOperation, + Status0_SuccessfulOperation } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum UpdateUserResponse { /// Invalid user supplied - Status400_InvalidUserSupplied, + Status400_InvalidUserSupplied + , /// User not found - Status404_UserNotFound, + Status404_UserNotFound } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// Add a new pet to the store. - /// - /// AddPet - POST /v2/pet - async fn add_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, - ) -> Result; - /// Deletes a pet. - /// - /// DeletePet - DELETE /v2/pet/{petId} - async fn delete_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, - ) -> Result; + /// Add a new pet to the store. + /// + /// AddPet - POST /v2/pet + async fn add_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Pet, + ) -> Result; - /// Finds Pets by status. - /// - /// FindPetsByStatus - GET /v2/pet/findByStatus - async fn find_pets_by_status( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByStatusQueryParams, - ) -> Result; - /// Finds Pets by tags. - /// - /// FindPetsByTags - GET /v2/pet/findByTags - async fn find_pets_by_tags( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::FindPetsByTagsQueryParams, - ) -> Result; + /// Deletes a pet. + /// + /// DeletePet - DELETE /v2/pet/{petId} + async fn delete_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + header_params: models::DeletePetHeaderParams, + path_params: models::DeletePetPathParams, + ) -> Result; - /// Find pet by ID. - /// - /// GetPetById - GET /v2/pet/{petId} - async fn get_pet_by_id( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetPetByIdPathParams, - ) -> Result; - /// Update an existing pet. - /// - /// UpdatePet - PUT /v2/pet - async fn update_pet( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Pet, - ) -> Result; + /// Finds Pets by status. + /// + /// FindPetsByStatus - GET /v2/pet/findByStatus + async fn find_pets_by_status( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::FindPetsByStatusQueryParams, + ) -> Result; - /// Updates a pet in the store with form data. - /// - /// UpdatePetWithForm - POST /v2/pet/{petId} - async fn update_pet_with_form( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdatePetWithFormPathParams, - ) -> Result; - /// uploads an image. - /// - /// UploadFile - POST /v2/pet/{petId}/uploadImage - async fn upload_file( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UploadFilePathParams, - body: Multipart, - ) -> Result; + /// Finds Pets by tags. + /// + /// FindPetsByTags - GET /v2/pet/findByTags + async fn find_pets_by_tags( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::FindPetsByTagsQueryParams, + ) -> Result; - /// Delete purchase order by ID. - /// - /// DeleteOrder - DELETE /v2/store/order/{orderId} - async fn delete_order( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteOrderPathParams, - ) -> Result; - /// Returns pet inventories by status. - /// - /// GetInventory - GET /v2/store/inventory - async fn get_inventory( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// Find pet by ID. + /// + /// GetPetById - GET /v2/pet/{petId} + async fn get_pet_by_id( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetPetByIdPathParams, + ) -> Result; - /// Find purchase order by ID. - /// - /// GetOrderById - GET /v2/store/order/{orderId} - async fn get_order_by_id( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetOrderByIdPathParams, - ) -> Result; - /// Place an order for a pet. - /// - /// PlaceOrder - POST /v2/store/order - async fn place_order( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::Order, - ) -> Result; + /// Update an existing pet. + /// + /// UpdatePet - PUT /v2/pet + async fn update_pet( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Pet, + ) -> Result; - /// Create user. - /// - /// CreateUser - POST /v2/user - async fn create_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::User, - ) -> Result; - /// Creates list of users with given input array. - /// - /// CreateUsersWithArrayInput - POST /v2/user/createWithArray - async fn create_users_with_array_input( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, - ) -> Result; + /// Updates a pet in the store with form data. + /// + /// UpdatePetWithForm - POST /v2/pet/{petId} + async fn update_pet_with_form( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UpdatePetWithFormPathParams, + ) -> Result; - /// Creates list of users with given input array. - /// - /// CreateUsersWithListInput - POST /v2/user/createWithList - async fn create_users_with_list_input( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: Vec, - ) -> Result; - /// Delete user. - /// - /// DeleteUser - DELETE /v2/user/{username} - async fn delete_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::DeleteUserPathParams, - ) -> Result; + /// uploads an image. + /// + /// UploadFile - POST /v2/pet/{petId}/uploadImage + async fn upload_file( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UploadFilePathParams, + body: Multipart, + ) -> Result; - /// Get user by user name. - /// - /// GetUserByName - GET /v2/user/{username} - async fn get_user_by_name( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::GetUserByNamePathParams, - ) -> Result; - /// Logs user into the system. - /// - /// LoginUser - GET /v2/user/login - async fn login_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - query_params: models::LoginUserQueryParams, - ) -> Result; + /// Delete purchase order by ID. + /// + /// DeleteOrder - DELETE /v2/store/order/{orderId} + async fn delete_order( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::DeleteOrderPathParams, + ) -> Result; - /// Logs out current logged in user session. - /// - /// LogoutUser - GET /v2/user/logout - async fn logout_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// Updated user. - /// - /// UpdateUser - PUT /v2/user/{username} - async fn update_user( - &self, - method: Method, - host: Host, - cookies: CookieJar, - path_params: models::UpdateUserPathParams, - body: models::User, - ) -> Result; + /// Returns pet inventories by status. + /// + /// GetInventory - GET /v2/store/inventory + async fn get_inventory( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Find purchase order by ID. + /// + /// GetOrderById - GET /v2/store/order/{orderId} + async fn get_order_by_id( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetOrderByIdPathParams, + ) -> Result; + + + /// Place an order for a pet. + /// + /// PlaceOrder - POST /v2/store/order + async fn place_order( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::Order, + ) -> Result; + + + /// Create user. + /// + /// CreateUser - POST /v2/user + async fn create_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::User, + ) -> Result; + + + /// Creates list of users with given input array. + /// + /// CreateUsersWithArrayInput - POST /v2/user/createWithArray + async fn create_users_with_array_input( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Vec, + ) -> Result; + + + /// Creates list of users with given input array. + /// + /// CreateUsersWithListInput - POST /v2/user/createWithList + async fn create_users_with_list_input( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: Vec, + ) -> Result; + + + /// Delete user. + /// + /// DeleteUser - DELETE /v2/user/{username} + async fn delete_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::DeleteUserPathParams, + ) -> Result; + + + /// Get user by user name. + /// + /// GetUserByName - GET /v2/user/{username} + async fn get_user_by_name( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::GetUserByNamePathParams, + ) -> Result; + + + /// Logs user into the system. + /// + /// LoginUser - GET /v2/user/login + async fn login_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + query_params: models::LoginUserQueryParams, + ) -> Result; + + + /// Logs out current logged in user session. + /// + /// LogoutUser - GET /v2/user/logout + async fn logout_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Updated user. + /// + /// UpdateUser - PUT /v2/user/{username} + async fn update_user( + &self, + method: Method, + host: Host, + cookies: CookieJar, + path_params: models::UpdateUserPathParams, + body: models::User, + ) -> Result; + } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/petstore/src/models.rs b/samples/server/petstore/rust-axum/output/petstore/src/models.rs index 2ad59347109b..1199eeb54f04 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/models.rs @@ -7,127 +7,166 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeletePetHeaderParams { - pub api_key: Option, -} + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeletePetHeaderParams { + pub api_key: Option, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeletePetPathParams { - /// Pet id to delete - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeletePetPathParams { + /// Pet id to delete + pub pet_id: i64, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct FindPetsByStatusQueryParams { - /// Status values that need to be considered for filter - /// Note: inline enums are not fully supported by openapi-generator - #[serde(rename = "status")] - pub status: Vec, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct FindPetsByTagsQueryParams { - /// Tags to filter by - #[serde(rename = "tags")] - pub tags: Vec, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct FindPetsByStatusQueryParams { + /// Status values that need to be considered for filter + /// Note: inline enums are not fully supported by openapi-generator + #[serde(rename = "status")] + pub status: Vec, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetPetByIdPathParams { - /// ID of pet to return - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct FindPetsByTagsQueryParams { + /// Tags to filter by + #[serde(rename = "tags")] + pub tags: Vec, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UpdatePetWithFormPathParams { - /// ID of pet that needs to be updated - pub pet_id: i64, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetPetByIdPathParams { + /// ID of pet to return + pub pet_id: i64, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UploadFilePathParams { - /// ID of pet to update - pub pet_id: i64, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeleteOrderPathParams { - /// ID of the order that needs to be deleted - pub order_id: String, -} + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UpdatePetWithFormPathParams { + /// ID of pet that needs to be updated + pub pet_id: i64, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetOrderByIdPathParams { - /// ID of pet that needs to be fetched - #[validate(range(min = 1, max = 5))] - pub order_id: i64, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct DeleteUserPathParams { - /// The name that needs to be deleted - pub username: String, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UploadFilePathParams { + /// ID of pet to update + pub pet_id: i64, + } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct GetUserByNamePathParams { - /// The name that needs to be fetched. Use user1 for testing. - pub username: String, -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct LoginUserQueryParams { - /// The user name for login - #[serde(rename = "username")] - #[validate(regex = "RE_LOGINUSERQUERYPARAMS_USERNAME")] - pub username: String, - /// The password for login in clear text - #[serde(rename = "password")] - pub password: String, -} + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeleteOrderPathParams { + /// ID of the order that needs to be deleted + pub order_id: String, + } + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetOrderByIdPathParams { + /// ID of pet that needs to be fetched + #[validate( + range(min = 1, max = 5), + )] + pub order_id: i64, + } + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct DeleteUserPathParams { + /// The name that needs to be deleted + pub username: String, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct GetUserByNamePathParams { + /// The name that needs to be fetched. Use user1 for testing. + pub username: String, + } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct LoginUserQueryParams { + /// The user name for login + #[serde(rename = "username")] + #[validate( + regex = "RE_LOGINUSERQUERYPARAMS_USERNAME", + )] + pub username: String, + /// The password for login in clear text + #[serde(rename = "password")] + pub password: String, + } + + lazy_static::lazy_static! { + static ref RE_LOGINUSERQUERYPARAMS_USERNAME: regex::Regex = regex::Regex::new(r"^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$").unwrap(); + } + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] + #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] + pub struct UpdateUserPathParams { + /// name that need to be deleted + pub username: String, + } + -lazy_static::lazy_static! { - static ref RE_LOGINUSERQUERYPARAMS_USERNAME: regex::Regex = regex::Regex::new(r"^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$").unwrap(); -} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] -#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct UpdateUserPathParams { - /// name that need to be deleted - pub username: String, -} /// Describes the result of uploading an image resource + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ApiResponse { #[serde(rename = "code")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub code: Option, #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub r#type: Option, #[serde(rename = "message")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub message: Option, + } + impl ApiResponse { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ApiResponse { @@ -145,15 +184,30 @@ impl ApiResponse { impl std::string::ToString for ApiResponse { fn to_string(&self) -> String { let params: Vec> = vec![ - self.code - .as_ref() - .map(|code| ["code".to_string(), code.to_string()].join(",")), - self.r#type - .as_ref() - .map(|r#type| ["type".to_string(), r#type.to_string()].join(",")), - self.message - .as_ref() - .map(|message| ["message".to_string(), message.to_string()].join(",")), + + self.code.as_ref().map(|code| { + [ + "code".to_string(), + code.to_string(), + ].join(",") + }), + + + self.r#type.as_ref().map(|r#type| { + [ + "type".to_string(), + r#type.to_string(), + ].join(",") + }), + + + self.message.as_ref().map(|message| { + [ + "message".to_string(), + message.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -185,33 +239,19 @@ impl std::str::FromStr for ApiResponse { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ApiResponse".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ApiResponse".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "code" => intermediate_rep.code.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "code" => intermediate_rep.code.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "type" => intermediate_rep.r#type.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "type" => intermediate_rep.r#type.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "message" => intermediate_rep.message.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ApiResponse".to_string(), - ) - } + "message" => intermediate_rep.message.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ApiResponse".to_string()) } } @@ -234,16 +274,13 @@ impl std::str::FromStr for ApiResponse { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ApiResponse - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ApiResponse - value: {} is invalid {}", + hdr_value, e)) } } } @@ -254,38 +291,42 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ApiResponse - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ApiResponse - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// A category for a pet + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Category { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "name")] - #[validate(regex = "RE_CATEGORY_NAME")] - #[serde(skip_serializing_if = "Option::is_none")] + #[validate( + regex = "RE_CATEGORY_NAME", + )] + #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + } lazy_static::lazy_static! { @@ -308,12 +349,22 @@ impl Category { impl std::string::ToString for Category { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.name - .as_ref() - .map(|name| ["name".to_string(), name.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.name.as_ref().map(|name| { + [ + "name".to_string(), + name.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -344,29 +395,17 @@ impl std::str::FromStr for Category { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Category".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Category".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Category".to_string(), - ) - } + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Category".to_string()) } } @@ -388,16 +427,13 @@ impl std::str::FromStr for Category { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Category - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Category - value: {} is invalid {}", + hdr_value, e)) } } } @@ -408,57 +444,60 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Category - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Category - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// An order for a pets from the pet store + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Order { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "petId")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub pet_id: Option, #[serde(rename = "quantity")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub quantity: Option, #[serde(rename = "shipDate")] - #[serde(skip_serializing_if = "Option::is_none")] - pub ship_date: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub ship_date: Option>, - /// Order Status - /// Note: inline enums are not fully supported by openapi-generator +/// Order Status +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub status: Option, #[serde(rename = "complete")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub complete: Option, + } + impl Order { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Order { @@ -479,22 +518,48 @@ impl Order { impl std::string::ToString for Order { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.pet_id - .as_ref() - .map(|pet_id| ["petId".to_string(), pet_id.to_string()].join(",")), - self.quantity - .as_ref() - .map(|quantity| ["quantity".to_string(), quantity.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.pet_id.as_ref().map(|pet_id| { + [ + "petId".to_string(), + pet_id.to_string(), + ].join(",") + }), + + + self.quantity.as_ref().map(|quantity| { + [ + "quantity".to_string(), + quantity.to_string(), + ].join(",") + }), + // Skipping shipDate in query parameter serialization - self.status - .as_ref() - .map(|status| ["status".to_string(), status.to_string()].join(",")), - self.complete - .as_ref() - .map(|complete| ["complete".to_string(), complete.to_string()].join(",")), + + + self.status.as_ref().map(|status| { + [ + "status".to_string(), + status.to_string(), + ].join(",") + }), + + + self.complete.as_ref().map(|complete| { + [ + "complete".to_string(), + complete.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -515,7 +580,7 @@ impl std::str::FromStr for Order { pub id: Vec, pub pet_id: Vec, pub quantity: Vec, - pub ship_date: Vec>, + pub ship_date: Vec>, pub status: Vec, pub complete: Vec, } @@ -529,46 +594,25 @@ impl std::str::FromStr for Order { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing Order".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing Order".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "petId" => intermediate_rep.pet_id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "petId" => intermediate_rep.pet_id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "quantity" => intermediate_rep.quantity.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "quantity" => intermediate_rep.quantity.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "shipDate" => intermediate_rep.ship_date.push( - as std::str::FromStr>::from_str(val) - .map_err(|x| x.to_string())?, - ), + "shipDate" => intermediate_rep.ship_date.push( as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "status" => intermediate_rep.status.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "complete" => intermediate_rep.complete.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Order".to_string(), - ) - } + "complete" => intermediate_rep.complete.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) } } @@ -594,16 +638,13 @@ impl std::str::FromStr for Order { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Order - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Order - value: {} is invalid {}", + hdr_value, e)) } } } @@ -614,34 +655,37 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Order - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Order - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// A pet for sale in the pet store + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Pet { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "category")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub category: Option, #[serde(rename = "name")] @@ -651,19 +695,21 @@ pub struct Pet { pub photo_urls: Vec, #[serde(rename = "tags")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub tags: Option>, - /// pet status in the store - /// Note: inline enums are not fully supported by openapi-generator +/// pet status in the store +/// Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub status: Option, + } + impl Pet { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(name: String, photo_urls: Vec) -> Pet { + pub fn new(name: String, photo_urls: Vec, ) -> Pet { Pet { id: None, category: None, @@ -681,24 +727,34 @@ impl Pet { impl std::string::ToString for Pet { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + // Skipping category in query parameter serialization + + Some("name".to_string()), Some(self.name.to_string()), + + Some("photoUrls".to_string()), - Some( - self.photo_urls - .iter() - .map(|x| x.to_string()) - .collect::>() - .join(","), - ), + Some(self.photo_urls.iter().map(|x| x.to_string()).collect::>().join(",")), + // Skipping tags in query parameter serialization - self.status - .as_ref() - .map(|status| ["status".to_string(), status.to_string()].join(",")), + + + self.status.as_ref().map(|status| { + [ + "status".to_string(), + status.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -733,46 +789,23 @@ impl std::str::FromStr for Pet { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Pet".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Pet".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "category" => intermediate_rep.category.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), + "category" => intermediate_rep.category.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::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(), - ) - } + "name" => intermediate_rep.name.push(::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( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Pet".to_string(), - ) - } + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Pet".to_string()) } } @@ -784,16 +817,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_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())?, + 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(), }) @@ -809,11 +834,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Pet - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Pet - value: {} is invalid {}", + hdr_value, e)) } } } @@ -824,37 +848,42 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Pet - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Pet - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// A tag for a pet + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct Tag { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "name")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub name: Option, + } + impl Tag { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> Tag { @@ -871,12 +900,22 @@ impl Tag { impl std::string::ToString for Tag { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.name - .as_ref() - .map(|name| ["name".to_string(), name.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.name.as_ref().map(|name| { + [ + "name".to_string(), + name.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -907,27 +946,17 @@ impl std::str::FromStr for Tag { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing Tag".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing Tag".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "name" => intermediate_rep.name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing Tag".to_string(), - ) - } + "name" => intermediate_rep.name.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing Tag".to_string()) } } @@ -952,11 +981,10 @@ impl std::convert::TryFrom> for HeaderValue { fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for Tag - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Tag - value: {} is invalid {}", + hdr_value, e)) } } } @@ -967,62 +995,67 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into Tag - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Tag - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// A User who is purchasing from the pet store + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct User { #[serde(rename = "id")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub id: Option, #[serde(rename = "username")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub username: Option, #[serde(rename = "firstName")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub first_name: Option, #[serde(rename = "lastName")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub last_name: Option, #[serde(rename = "email")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub email: Option, #[serde(rename = "password")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub password: Option, #[serde(rename = "phone")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub phone: Option, - /// User Status +/// User Status #[serde(rename = "userStatus")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub user_status: Option, + } + impl User { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> User { @@ -1045,30 +1078,70 @@ impl User { impl std::string::ToString for User { fn to_string(&self) -> String { let params: Vec> = vec![ - self.id - .as_ref() - .map(|id| ["id".to_string(), id.to_string()].join(",")), - self.username - .as_ref() - .map(|username| ["username".to_string(), username.to_string()].join(",")), - self.first_name - .as_ref() - .map(|first_name| ["firstName".to_string(), first_name.to_string()].join(",")), - self.last_name - .as_ref() - .map(|last_name| ["lastName".to_string(), last_name.to_string()].join(",")), - self.email - .as_ref() - .map(|email| ["email".to_string(), email.to_string()].join(",")), - self.password - .as_ref() - .map(|password| ["password".to_string(), password.to_string()].join(",")), - self.phone - .as_ref() - .map(|phone| ["phone".to_string(), phone.to_string()].join(",")), - self.user_status - .as_ref() - .map(|user_status| ["userStatus".to_string(), user_status.to_string()].join(",")), + + self.id.as_ref().map(|id| { + [ + "id".to_string(), + id.to_string(), + ].join(",") + }), + + + self.username.as_ref().map(|username| { + [ + "username".to_string(), + username.to_string(), + ].join(",") + }), + + + self.first_name.as_ref().map(|first_name| { + [ + "firstName".to_string(), + first_name.to_string(), + ].join(",") + }), + + + self.last_name.as_ref().map(|last_name| { + [ + "lastName".to_string(), + last_name.to_string(), + ].join(",") + }), + + + self.email.as_ref().map(|email| { + [ + "email".to_string(), + email.to_string(), + ].join(",") + }), + + + self.password.as_ref().map(|password| { + [ + "password".to_string(), + password.to_string(), + ].join(",") + }), + + + self.phone.as_ref().map(|phone| { + [ + "phone".to_string(), + phone.to_string(), + ].join(",") + }), + + + self.user_status.as_ref().map(|user_status| { + [ + "userStatus".to_string(), + user_status.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -1105,51 +1178,29 @@ impl std::str::FromStr for User { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err("Missing value while parsing User".to_string()) - } + None => return std::result::Result::Err("Missing value while parsing User".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "username" => intermediate_rep.username.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "username" => intermediate_rep.username.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "firstName" => intermediate_rep.first_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "firstName" => intermediate_rep.first_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "lastName" => intermediate_rep.last_name.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "lastName" => intermediate_rep.last_name.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "email" => intermediate_rep.email.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "email" => intermediate_rep.email.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "password" => intermediate_rep.password.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "password" => intermediate_rep.password.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "phone" => intermediate_rep.phone.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "phone" => intermediate_rep.phone.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "userStatus" => intermediate_rep.user_status.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing User".to_string(), - ) - } + "userStatus" => intermediate_rep.user_status.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing User".to_string()) } } @@ -1177,16 +1228,13 @@ impl std::str::FromStr for User { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for User - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for User - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1197,19 +1245,20 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) - } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into User - {}", - value, err - )), - }, - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into User - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 87e0b820afb8..89007f8055b9 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -12,13 +12,27 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{ - AddPetResponse, Api, CreateUserResponse, CreateUsersWithArrayInputResponse, - CreateUsersWithListInputResponse, DeleteOrderResponse, DeletePetResponse, DeleteUserResponse, - FindPetsByStatusResponse, FindPetsByTagsResponse, GetInventoryResponse, GetOrderByIdResponse, - GetPetByIdResponse, GetUserByNameResponse, LoginUserResponse, LogoutUserResponse, - PlaceOrderResponse, UpdatePetResponse, UpdatePetWithFormResponse, UpdateUserResponse, - UploadFileResponse, +use crate::{Api, + AddPetResponse, + DeletePetResponse, + FindPetsByStatusResponse, + FindPetsByTagsResponse, + GetPetByIdResponse, + UpdatePetResponse, + UpdatePetWithFormResponse, + UploadFileResponse, + DeleteOrderResponse, + GetInventoryResponse, + GetOrderByIdResponse, + PlaceOrderResponse, + CreateUserResponse, + CreateUsersWithArrayInputResponse, + CreateUsersWithListInputResponse, + DeleteUserResponse, + GetUserByNameResponse, + LoginUserResponse, + LogoutUserResponse, + UpdateUserResponse }; /// Setup API Server. @@ -29,1602 +43,1862 @@ where { // build our application with a route Router::new() - .route("/v2/pet", post(add_pet::).put(update_pet::)) - .route( - "/v2/pet/:pet_id", - delete(delete_pet::) - .get(get_pet_by_id::) - .post(update_pet_with_form::), + .route("/v2/pet", + post(add_pet::).put(update_pet::) ) - .route("/v2/pet/:pet_id/uploadImage", post(upload_file::)) - .route("/v2/pet/findByStatus", get(find_pets_by_status::)) - .route("/v2/pet/findByTags", get(find_pets_by_tags::)) - .route("/v2/store/inventory", get(get_inventory::)) - .route("/v2/store/order", post(place_order::)) - .route( - "/v2/store/order/:order_id", - delete(delete_order::).get(get_order_by_id::), + .route("/v2/pet/:pet_id", + delete(delete_pet::).get(get_pet_by_id::).post(update_pet_with_form::) ) - .route("/v2/user", post(create_user::)) - .route( - "/v2/user/:username", - delete(delete_user::) - .get(get_user_by_name::) - .put(update_user::), + .route("/v2/pet/:pet_id/uploadImage", + post(upload_file::) ) - .route( - "/v2/user/createWithArray", - post(create_users_with_array_input::), + .route("/v2/pet/findByStatus", + get(find_pets_by_status::) ) - .route( - "/v2/user/createWithList", - post(create_users_with_list_input::), + .route("/v2/pet/findByTags", + get(find_pets_by_tags::) + ) + .route("/v2/store/inventory", + get(get_inventory::) + ) + .route("/v2/store/order", + post(place_order::) + ) + .route("/v2/store/order/:order_id", + delete(delete_order::).get(get_order_by_id::) + ) + .route("/v2/user", + post(create_user::) + ) + .route("/v2/user/:username", + delete(delete_user::).get(get_user_by_name::).put(update_user::) + ) + .route("/v2/user/createWithArray", + post(create_users_with_array_input::) + ) + .route("/v2/user/createWithList", + post(create_users_with_list_input::) + ) + .route("/v2/user/login", + get(login_user::) + ) + .route("/v2/user/logout", + get(logout_user::) ) - .route("/v2/user/login", get(login_user::)) - .route("/v2/user/logout", get(logout_user::)) .with_state(api_impl) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct AddPetBodyValidator<'a> { - #[validate] - body: &'a models::Pet, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct AddPetBodyValidator<'a> { + #[validate] + body: &'a models::Pet, + } + #[tracing::instrument(skip_all)] -fn add_pet_validation(body: models::Pet) -> std::result::Result<(models::Pet,), ValidationErrors> { - let b = AddPetBodyValidator { body: &body }; - b.validate()?; +fn add_pet_validation( + body: models::Pet, +) -> std::result::Result<( + models::Pet, +), ValidationErrors> +{ + let b = AddPetBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// AddPet - POST /v2/pet #[tracing::instrument(skip_all)] async fn add_pet( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || add_pet_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + add_pet_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().add_pet(method, host, cookies, body).await; + let result = api_impl.as_ref().add_pet( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - AddPetResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + AddPetResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - AddPetResponse::Status405_InvalidInput => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + AddPetResponse::Status405_InvalidInput + => { + + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_pet_validation( - header_params: models::DeletePetHeaderParams, - path_params: models::DeletePetPathParams, -) -> std::result::Result< - (models::DeletePetHeaderParams, models::DeletePetPathParams), - ValidationErrors, -> { - header_params.validate()?; - path_params.validate()?; + header_params: models::DeletePetHeaderParams, + path_params: models::DeletePetPathParams, +) -> std::result::Result<( + models::DeletePetHeaderParams, + models::DeletePetPathParams, +), ValidationErrors> +{ + header_params.validate()?; + path_params.validate()?; - Ok((header_params, path_params)) +Ok(( + header_params, + path_params, +)) } /// DeletePet - DELETE /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn delete_pet( - method: Method, - host: Host, - cookies: CookieJar, - headers: HeaderMap, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + headers: HeaderMap, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { // Header parameters let header_params = { - let header_api_key = headers.get(HeaderName::from_static("api_key")); + let header_api_key = headers.get(HeaderName::from_static("api_key")); - let header_api_key = match header_api_key { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { - Ok(result) => Some(result.0), - Err(err) => { - return Response::builder() - .status(StatusCode::BAD_REQUEST) - .body(Body::from(format!("Invalid header api_key - {}", err))) - .map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }); - } - }, - None => None, - }; + let header_api_key = match header_api_key { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Ok(result) => + Some(result.0), + Err(err) => { + return Response::builder() + .status(StatusCode::BAD_REQUEST) + .body(Body::from(format!("Invalid header api_key - {}", err))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - models::DeletePetHeaderParams { - api_key: header_api_key, - } - }; + }, + }, + None => { + None + } + }; - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || delete_pet_validation(header_params, path_params)) - .await - .unwrap(); + models::DeletePetHeaderParams { + api_key: header_api_key, + } + }; - let Ok((header_params, path_params)) = validation else { - return Response::builder() + + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_pet_validation( + header_params, + path_params, + ) + ).await.unwrap(); + + let Ok(( + header_params, + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_pet(method, host, cookies, header_params, path_params) - .await; + let result = api_impl.as_ref().delete_pet( + method, + host, + cookies, + header_params, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeletePetResponse::Status400_InvalidPetValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeletePetResponse::Status400_InvalidPetValue + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn find_pets_by_status_validation( - query_params: models::FindPetsByStatusQueryParams, -) -> std::result::Result<(models::FindPetsByStatusQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::FindPetsByStatusQueryParams, +) -> std::result::Result<( + models::FindPetsByStatusQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// FindPetsByStatus - GET /v2/pet/findByStatus #[tracing::instrument(skip_all)] async fn find_pets_by_status( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || find_pets_by_status_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + find_pets_by_status_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .find_pets_by_status(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().find_pets_by_status( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FindPetsByStatusResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FindPetsByStatusResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - FindPetsByStatusResponse::Status400_InvalidStatusValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + FindPetsByStatusResponse::Status400_InvalidStatusValue + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn find_pets_by_tags_validation( - query_params: models::FindPetsByTagsQueryParams, -) -> std::result::Result<(models::FindPetsByTagsQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::FindPetsByTagsQueryParams, +) -> std::result::Result<( + models::FindPetsByTagsQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// FindPetsByTags - GET /v2/pet/findByTags #[tracing::instrument(skip_all)] async fn find_pets_by_tags( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || find_pets_by_tags_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + find_pets_by_tags_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .find_pets_by_tags(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().find_pets_by_tags( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FindPetsByTagsResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FindPetsByTagsResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - FindPetsByTagsResponse::Status400_InvalidTagValue => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + FindPetsByTagsResponse::Status400_InvalidTagValue + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_pet_by_id_validation( - path_params: models::GetPetByIdPathParams, -) -> std::result::Result<(models::GetPetByIdPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetPetByIdPathParams, +) -> std::result::Result<( + models::GetPetByIdPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetPetById - GET /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn get_pet_by_id( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_pet_by_id_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_pet_by_id_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_pet_by_id(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_pet_by_id( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetPetByIdResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetPetByIdResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetPetByIdResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetPetByIdResponse::Status404_PetNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetPetByIdResponse::Status400_InvalidIDSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetPetByIdResponse::Status404_PetNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct UpdatePetBodyValidator<'a> { - #[validate] - body: &'a models::Pet, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct UpdatePetBodyValidator<'a> { + #[validate] + body: &'a models::Pet, + } + #[tracing::instrument(skip_all)] fn update_pet_validation( - body: models::Pet, -) -> std::result::Result<(models::Pet,), ValidationErrors> { - let b = UpdatePetBodyValidator { body: &body }; - b.validate()?; + body: models::Pet, +) -> std::result::Result<( + models::Pet, +), ValidationErrors> +{ + let b = UpdatePetBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// UpdatePet - PUT /v2/pet #[tracing::instrument(skip_all)] async fn update_pet( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || update_pet_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_pet_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_pet(method, host, cookies, body) - .await; + let result = api_impl.as_ref().update_pet( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdatePetResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + UpdatePetResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - UpdatePetResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - UpdatePetResponse::Status404_PetNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - UpdatePetResponse::Status405_ValidationException => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + UpdatePetResponse::Status400_InvalidIDSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + UpdatePetResponse::Status404_PetNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + UpdatePetResponse::Status405_ValidationException + => { + + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn update_pet_with_form_validation( - path_params: models::UpdatePetWithFormPathParams, -) -> std::result::Result<(models::UpdatePetWithFormPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::UpdatePetWithFormPathParams, +) -> std::result::Result<( + models::UpdatePetWithFormPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// UpdatePetWithForm - POST /v2/pet/{petId} #[tracing::instrument(skip_all)] async fn update_pet_with_form( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || update_pet_with_form_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_pet_with_form_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_pet_with_form(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().update_pet_with_form( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdatePetWithFormResponse::Status405_InvalidInput => { - let mut response = response.status(405); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UpdatePetWithFormResponse::Status405_InvalidInput + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(405); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn upload_file_validation( - path_params: models::UploadFilePathParams, -) -> std::result::Result<(models::UploadFilePathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::UploadFilePathParams, +) -> std::result::Result<( + models::UploadFilePathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// UploadFile - POST /v2/pet/{petId}/uploadImage #[tracing::instrument(skip_all)] async fn upload_file( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, - body: Multipart, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, + body: Multipart, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || upload_file_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + upload_file_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .upload_file(method, host, cookies, path_params, body) - .await; + let result = api_impl.as_ref().upload_file( + method, + host, + cookies, + path_params, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UploadFileResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + UploadFileResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_order_validation( - path_params: models::DeleteOrderPathParams, -) -> std::result::Result<(models::DeleteOrderPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::DeleteOrderPathParams, +) -> std::result::Result<( + models::DeleteOrderPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// DeleteOrder - DELETE /v2/store/order/{orderId} #[tracing::instrument(skip_all)] async fn delete_order( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || delete_order_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_order_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_order(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().delete_order( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeleteOrderResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - DeleteOrderResponse::Status404_OrderNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeleteOrderResponse::Status400_InvalidIDSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + DeleteOrderResponse::Status404_OrderNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn get_inventory_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn get_inventory_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// GetInventory - GET /v2/store/inventory #[tracing::instrument(skip_all)] async fn get_inventory( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_inventory_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_inventory_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().get_inventory(method, host, cookies).await; + let result = api_impl.as_ref().get_inventory( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetInventoryResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetInventoryResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_order_by_id_validation( - path_params: models::GetOrderByIdPathParams, -) -> std::result::Result<(models::GetOrderByIdPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetOrderByIdPathParams, +) -> std::result::Result<( + models::GetOrderByIdPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetOrderById - GET /v2/store/order/{orderId} #[tracing::instrument(skip_all)] async fn get_order_by_id( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_order_by_id_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_order_by_id_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_order_by_id(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_order_by_id( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetOrderByIdResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetOrderByIdResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetOrderByIdResponse::Status400_InvalidIDSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetOrderByIdResponse::Status404_OrderNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetOrderByIdResponse::Status400_InvalidIDSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetOrderByIdResponse::Status404_OrderNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct PlaceOrderBodyValidator<'a> { - #[validate] - body: &'a models::Order, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct PlaceOrderBodyValidator<'a> { + #[validate] + body: &'a models::Order, + } + #[tracing::instrument(skip_all)] fn place_order_validation( - body: models::Order, -) -> std::result::Result<(models::Order,), ValidationErrors> { - let b = PlaceOrderBodyValidator { body: &body }; - b.validate()?; + body: models::Order, +) -> std::result::Result<( + models::Order, +), ValidationErrors> +{ + let b = PlaceOrderBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// PlaceOrder - POST /v2/store/order #[tracing::instrument(skip_all)] async fn place_order( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || place_order_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + place_order_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .place_order(method, host, cookies, body) - .await; + let result = api_impl.as_ref().place_order( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - PlaceOrderResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + PlaceOrderResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - PlaceOrderResponse::Status400_InvalidOrder => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + PlaceOrderResponse::Status400_InvalidOrder + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUserBodyValidator<'a> { - #[validate] - body: &'a models::User, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUserBodyValidator<'a> { + #[validate] + body: &'a models::User, + } + #[tracing::instrument(skip_all)] fn create_user_validation( - body: models::User, -) -> std::result::Result<(models::User,), ValidationErrors> { - let b = CreateUserBodyValidator { body: &body }; - b.validate()?; + body: models::User, +) -> std::result::Result<( + models::User, +), ValidationErrors> +{ + let b = CreateUserBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUser - POST /v2/user #[tracing::instrument(skip_all)] async fn create_user( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || create_user_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_user_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_user(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_user( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUserResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUserResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUsersWithArrayInputBodyValidator<'a> { - #[validate] - body: &'a Vec, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUsersWithArrayInputBodyValidator<'a> { + #[validate] + body: &'a Vec, + } + #[tracing::instrument(skip_all)] fn create_users_with_array_input_validation( - body: Vec, -) -> std::result::Result<(Vec,), ValidationErrors> { - let b = CreateUsersWithArrayInputBodyValidator { body: &body }; - b.validate()?; + body: Vec, +) -> std::result::Result<( + Vec, +), ValidationErrors> +{ + let b = CreateUsersWithArrayInputBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUsersWithArrayInput - POST /v2/user/createWithArray #[tracing::instrument(skip_all)] async fn create_users_with_array_input( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || create_users_with_array_input_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_users_with_array_input_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_users_with_array_input(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_users_with_array_input( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUsersWithArrayInputResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUsersWithArrayInputResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct CreateUsersWithListInputBodyValidator<'a> { - #[validate] - body: &'a Vec, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct CreateUsersWithListInputBodyValidator<'a> { + #[validate] + body: &'a Vec, + } + #[tracing::instrument(skip_all)] fn create_users_with_list_input_validation( - body: Vec, -) -> std::result::Result<(Vec,), ValidationErrors> { - let b = CreateUsersWithListInputBodyValidator { body: &body }; - b.validate()?; + body: Vec, +) -> std::result::Result<( + Vec, +), ValidationErrors> +{ + let b = CreateUsersWithListInputBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// CreateUsersWithListInput - POST /v2/user/createWithList #[tracing::instrument(skip_all)] async fn create_users_with_list_input( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json>, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json>, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = - tokio::task::spawn_blocking(move || create_users_with_list_input_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + create_users_with_list_input_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .create_users_with_list_input(method, host, cookies, body) - .await; + let result = api_impl.as_ref().create_users_with_list_input( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - CreateUsersWithListInputResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + CreateUsersWithListInputResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn delete_user_validation( - path_params: models::DeleteUserPathParams, -) -> std::result::Result<(models::DeleteUserPathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::DeleteUserPathParams, +) -> std::result::Result<( + models::DeleteUserPathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// DeleteUser - DELETE /v2/user/{username} #[tracing::instrument(skip_all)] async fn delete_user( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || delete_user_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + delete_user_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .delete_user(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().delete_user( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DeleteUserResponse::Status400_InvalidUsernameSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - DeleteUserResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DeleteUserResponse::Status400_InvalidUsernameSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + DeleteUserResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn get_user_by_name_validation( - path_params: models::GetUserByNamePathParams, -) -> std::result::Result<(models::GetUserByNamePathParams,), ValidationErrors> { - path_params.validate()?; + path_params: models::GetUserByNamePathParams, +) -> std::result::Result<( + models::GetUserByNamePathParams, +), ValidationErrors> +{ + path_params.validate()?; - Ok((path_params,)) +Ok(( + path_params, +)) } /// GetUserByName - GET /v2/user/{username} #[tracing::instrument(skip_all)] async fn get_user_by_name( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_user_by_name_validation(path_params)) - .await - .unwrap(); - let Ok((path_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_user_by_name_validation( + path_params, + ) + ).await.unwrap(); + + let Ok(( + path_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_user_by_name(method, host, cookies, path_params) - .await; + let result = api_impl.as_ref().get_user_by_name( + method, + host, + cookies, + path_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetUserByNameResponse::Status200_SuccessfulOperation(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetUserByNameResponse::Status200_SuccessfulOperation + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - GetUserByNameResponse::Status400_InvalidUsernameSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - GetUserByNameResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + GetUserByNameResponse::Status400_InvalidUsernameSupplied + => { + + let mut response = response.status(400); + response.body(Body::empty()) + }, + GetUserByNameResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] fn login_user_validation( - query_params: models::LoginUserQueryParams, -) -> std::result::Result<(models::LoginUserQueryParams,), ValidationErrors> { - query_params.validate()?; + query_params: models::LoginUserQueryParams, +) -> std::result::Result<( + models::LoginUserQueryParams, +), ValidationErrors> +{ + query_params.validate()?; - Ok((query_params,)) +Ok(( + query_params, +)) } /// LoginUser - GET /v2/user/login #[tracing::instrument(skip_all)] async fn login_user( - method: Method, - host: Host, - cookies: CookieJar, - Query(query_params): Query, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + Query(query_params): Query, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || login_user_validation(query_params)) - .await - .unwrap(); - let Ok((query_params,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + login_user_validation( + query_params, + ) + ).await.unwrap(); + + let Ok(( + query_params, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .login_user(method, host, cookies, query_params) - .await; + let result = api_impl.as_ref().login_user( + method, + host, + cookies, + query_params, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - LoginUserResponse::Status200_SuccessfulOperation { - body, - set_cookie, - x_rate_limit, - x_expires_after, - } => { - if let Some(set_cookie) = set_cookie { - let set_cookie = match header::IntoHeaderValue(set_cookie).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + let resp = match result { + Ok(rsp) => match rsp { + LoginUserResponse::Status200_SuccessfulOperation + { + body, + set_cookie, + x_rate_limit, + x_expires_after + } + => { + if let Some(set_cookie) = set_cookie { + let set_cookie = match header::IntoHeaderValue(set_cookie).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling set_cookie header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert(HeaderName::from_static("set-cookie"), set_cookie); - } - } - if let Some(x_rate_limit) = x_rate_limit { - let x_rate_limit = match header::IntoHeaderValue(x_rate_limit).try_into() { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("set-cookie"), + set_cookie + ); + } + } + if let Some(x_rate_limit) = x_rate_limit { + let x_rate_limit = match header::IntoHeaderValue(x_rate_limit).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling x_rate_limit header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("x-rate-limit"), x_rate_limit); - } - } - if let Some(x_expires_after) = x_expires_after { - let x_expires_after = match header::IntoHeaderValue(x_expires_after).try_into() - { - Ok(val) => val, - Err(e) => { - return Response::builder() + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("x-rate-limit"), + x_rate_limit + ); + } + } + if let Some(x_expires_after) = x_expires_after { + let x_expires_after = match header::IntoHeaderValue(x_expires_after).try_into() { + Ok(val) => val, + Err(e) => { + return Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::from(format!("An internal server error occurred handling x_expires_after header - {}", e))).map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }); - } - }; + } + }; - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers - .insert(HeaderName::from_static("x-expires-after"), x_expires_after); - } - } + + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + HeaderName::from_static("x-expires-after"), + x_expires_after + ); + } + } - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/plain").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - let body_content = body; - response.body(Body::from(body_content)) - } - LoginUserResponse::Status400_InvalidUsername => { - let mut response = response.status(400); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let body_content = body; + response.body(Body::from(body_content)) + }, + LoginUserResponse::Status400_InvalidUsername + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn logout_user_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn logout_user_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// LogoutUser - GET /v2/user/logout #[tracing::instrument(skip_all)] async fn logout_user( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || logout_user_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + logout_user_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().logout_user(method, host, cookies).await; + let result = api_impl.as_ref().logout_user( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - LogoutUserResponse::Status0_SuccessfulOperation => { - let mut response = response.status(0); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + LogoutUserResponse::Status0_SuccessfulOperation + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(0); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct UpdateUserBodyValidator<'a> { - #[validate] - body: &'a models::User, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct UpdateUserBodyValidator<'a> { + #[validate] + body: &'a models::User, + } + #[tracing::instrument(skip_all)] fn update_user_validation( - path_params: models::UpdateUserPathParams, - body: models::User, -) -> std::result::Result<(models::UpdateUserPathParams, models::User), ValidationErrors> { - path_params.validate()?; - let b = UpdateUserBodyValidator { body: &body }; - b.validate()?; + path_params: models::UpdateUserPathParams, + body: models::User, +) -> std::result::Result<( + models::UpdateUserPathParams, + models::User, +), ValidationErrors> +{ + path_params.validate()?; + let b = UpdateUserBodyValidator { body: &body }; + b.validate()?; - Ok((path_params, body)) +Ok(( + path_params, + body, +)) } /// UpdateUser - PUT /v2/user/{username} #[tracing::instrument(skip_all)] async fn update_user( - method: Method, - host: Host, - cookies: CookieJar, - Path(path_params): Path, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + Path(path_params): Path, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || update_user_validation(path_params, body)) - .await - .unwrap(); - let Ok((path_params, body)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + update_user_validation( + path_params, + body, + ) + ).await.unwrap(); + + let Ok(( + path_params, + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .update_user(method, host, cookies, path_params, body) - .await; + let result = api_impl.as_ref().update_user( + method, + host, + cookies, + path_params, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - UpdateUserResponse::Status400_InvalidUserSupplied => { - let mut response = response.status(400); - response.body(Body::empty()) - } - UpdateUserResponse::Status404_UserNotFound => { - let mut response = response.status(404); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + UpdateUserResponse::Status400_InvalidUserSupplied + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(400); + response.body(Body::empty()) + }, + UpdateUserResponse::Status404_UserNotFound + => { + + let mut response = response.status(404); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/header.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/header.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs index 5b44cc42895e..f99c0799ecf7 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,25 +14,28 @@ use types::*; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "1.0"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum PingGetResponse { /// OK - Status201_OK, + Status201_OK } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// PingGet - GET /ping - async fn ping_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + + /// PingGet - GET /ping + async fn ping_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs index 58fc026395c4..34696c0ab8ae 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/models.rs @@ -6,3 +6,6 @@ use validator::Validate; #[cfg(feature = "server")] use crate::header; use crate::{models, types::*}; + + + diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 5ec08d2d341f..76578d0a4ec6 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -12,7 +12,9 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{Api, PingGetResponse}; +use crate::{Api, + PingGetResponse +}; /// Setup API Server. pub fn new(api_impl: I) -> Router @@ -22,59 +24,74 @@ where { // build our application with a route Router::new() - .route("/ping", get(ping_get::)) + .route("/ping", + get(ping_get::) + ) .with_state(api_impl) } + #[tracing::instrument(skip_all)] -fn ping_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn ping_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// PingGet - GET /ping #[tracing::instrument(skip_all)] async fn ping_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || ping_get_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + ping_get_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().ping_get(method, host, cookies).await; + let result = api_impl.as_ref().ping_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - PingGetResponse::Status201_OK => { - let mut response = response.status(201); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + PingGetResponse::Status201_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(201); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/header.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/header.rs index 7c530892fbf2..4d1cc4c6dccd 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/header.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/header.rs @@ -30,16 +30,11 @@ macro_rules! ihv_generate { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!( - "Unable to parse {} as a string: {}", - stringify!($t), - e - )), + Err(e) => Err(format!("Unable to parse {} as a string: {}", + stringify!($t), e)), }, - Err(e) => Err(format!( - "Unable to parse header {:?} as a string - {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to parse header {:?} as a string - {}", + hdr_value, e)), } } } @@ -74,17 +69,14 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue( hdr_value - .split(',') - .filter_map(|x| match x.trim() { - "" => None, - y => Some(y.to_string()), - }) - .collect(), - )), - Err(e) => Err(format!( - "Unable to parse header: {:?} as a string - {}", - hdr_value, e - )), + .split(',') + .filter_map(|x| match x.trim() { + "" => None, + y => Some(y.to_string()), + }) + .collect())), + Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_value, e)), } } } @@ -93,13 +85,11 @@ impl TryFrom>> for HeaderValue { type Error = String; fn try_from(hdr_value: IntoHeaderValue>) -> Result { - match HeaderValue::from_str(&hdr_value.0.join(", ")) { - Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} into a header - {}", - hdr_value, e - )), - } + match HeaderValue::from_str(&hdr_value.0.join(", ")) { + Ok(hdr_value) => Ok(hdr_value), + Err(e) => Err(format!("Unable to convert {:?} into a header - {}", + hdr_value, e)) + } } } @@ -111,7 +101,8 @@ impl TryFrom for IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> Result { match hdr_value.to_str() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), - Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)), + Err(e) => Err(format!("Unable to convert header {:?} to {}", + hdr_value, e)), } } } @@ -122,10 +113,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)) } } } @@ -139,12 +128,11 @@ impl TryFrom for IntoHeaderValue { match hdr_value.to_str() { Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), - Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse bool from {} - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert {:?} from a header {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} from a header {}", + hdr_value, e)), } } } @@ -155,10 +143,8 @@ impl TryFrom> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue) -> Result { match HeaderValue::from_str(&hdr_value.0.to_string()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert: {:?} into a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert: {:?} into a header: {}", + hdr_value, e)) } } } @@ -172,12 +158,11 @@ impl TryFrom for IntoHeaderValue> { match hdr_value.to_str() { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), - Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)), + Err(e) => Err(format!("Unable to parse: {} as date - {}", + hdr_value, e)), }, - Err(e) => Err(format!( - "Unable to convert header {:?} to string {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert header {:?} to string {}", + hdr_value, e)), } } } @@ -188,10 +173,8 @@ impl TryFrom>> for HeaderValue { fn try_from(hdr_value: IntoHeaderValue>) -> Result { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { Ok(hdr_value) => Ok(hdr_value), - Err(e) => Err(format!( - "Unable to convert {:?} to a header: {}", - hdr_value, e - )), + Err(e) => Err(format!("Unable to convert {:?} to a header: {}", + hdr_value, e)), } } } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs index 4024a01566dc..41f3a2ace3f0 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/lib.rs @@ -1,12 +1,4 @@ -#![allow( - missing_docs, - trivial_casts, - unused_variables, - unused_mut, - unused_imports, - unused_extern_crates, - non_camel_case_types -)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] #![allow(unused_imports, unused_attributes)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] @@ -22,167 +14,183 @@ use types::*; pub const BASE_PATH: &str = ""; pub const API_VERSION: &str = "2.3.4"; -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum AllOfGetResponse { /// OK - Status200_OK(models::AllOfObject), + Status200_OK + (models::AllOfObject) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DummyGetResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum DummyPutResponse { /// Success - Status200_Success, + Status200_Success } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum FileResponseGetResponse { /// Success - Status200_Success(ByteArray), + Status200_Success + (ByteArray) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum GetStructuredYamlResponse { /// OK - Status200_OK(String), + Status200_OK + (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum HtmlPostResponse { /// Success - Status200_Success(String), + Status200_Success + (String) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum PostYamlResponse { /// OK - Status204_OK, + Status204_OK } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum RawJsonGetResponse { /// Success - Status200_Success(crate::types::Object), + Status200_Success + (crate::types::Object) } -#[derive(Debug, PartialEq, Serialize, Deserialize)] + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[must_use] #[allow(clippy::large_enum_variant)] pub enum SoloObjectPostResponse { /// OK - Status204_OK, + Status204_OK } + /// API #[async_trait] #[allow(clippy::ptr_arg)] pub trait Api { - /// AllOfGet - GET /allOf - async fn all_of_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// A dummy endpoint to make the spec valid.. - /// - /// DummyGet - GET /dummy - async fn dummy_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// AllOfGet - GET /allOf + async fn all_of_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// DummyPut - PUT /dummy - async fn dummy_put( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: models::DummyPutRequest, - ) -> Result; - /// Get a file. - /// - /// FileResponseGet - GET /file_response - async fn file_response_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// A dummy endpoint to make the spec valid.. + /// + /// DummyGet - GET /dummy + async fn dummy_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; - /// GetStructuredYaml - GET /get-structured-yaml - async fn get_structured_yaml( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; - /// Test HTML handling. - /// - /// HtmlPost - POST /html - async fn html_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: String, - ) -> Result; + /// DummyPut - PUT /dummy + async fn dummy_put( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: models::DummyPutRequest, + ) -> Result; - /// PostYaml - POST /post-yaml - async fn post_yaml( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: String, - ) -> Result; - /// Get an arbitrary JSON blob.. - /// - /// RawJsonGet - GET /raw_json - async fn raw_json_get( - &self, - method: Method, - host: Host, - cookies: CookieJar, - ) -> Result; + /// Get a file. + /// + /// FileResponseGet - GET /file_response + async fn file_response_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// GetStructuredYaml - GET /get-structured-yaml + async fn get_structured_yaml( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Test HTML handling. + /// + /// HtmlPost - POST /html + async fn html_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: String, + ) -> Result; + + + /// PostYaml - POST /post-yaml + async fn post_yaml( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: String, + ) -> Result; + + + /// Get an arbitrary JSON blob.. + /// + /// RawJsonGet - GET /raw_json + async fn raw_json_get( + &self, + method: Method, + host: Host, + cookies: CookieJar, + ) -> Result; + + + /// Send an arbitrary JSON blob. + /// + /// SoloObjectPost - POST /solo-object + async fn solo_object_post( + &self, + method: Method, + host: Host, + cookies: CookieJar, + body: crate::types::Object, + ) -> Result; - /// Send an arbitrary JSON blob. - /// - /// SoloObjectPost - POST /solo-object - async fn solo_object_post( - &self, - method: Method, - host: Host, - cookies: CookieJar, - body: crate::types::Object, - ) -> Result; } #[cfg(feature = "server")] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs index edd388bdec18..e8afc229ad87 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs @@ -7,22 +7,38 @@ use validator::Validate; use crate::header; use crate::{models, types::*}; + + + + + + + + + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ANullableContainer { #[serde(rename = "NullableThing")] #[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(default = "default_optional_nullable")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub nullable_thing: Option>, #[serde(rename = "RequiredNullableThing")] pub required_nullable_thing: Nullable, + } + impl ANullableContainer { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_nullable_thing: Nullable) -> ANullableContainer { + pub fn new(required_nullable_thing: Nullable, ) -> ANullableContainer { ANullableContainer { nullable_thing: None, required_nullable_thing, @@ -36,21 +52,18 @@ impl ANullableContainer { impl std::string::ToString for ANullableContainer { fn to_string(&self) -> String { let params: Vec> = vec![ + self.nullable_thing.as_ref().map(|nullable_thing| { [ "NullableThing".to_string(), - nullable_thing - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ] - .join(",") + nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()), + ].join(",") }), + + Some("RequiredNullableThing".to_string()), - Some( - self.required_nullable_thing - .as_ref() - .map_or("null".to_string(), |x| x.to_string()), - ), + Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())), + ]; params.into_iter().flatten().collect::>().join(",") @@ -81,11 +94,7 @@ impl std::str::FromStr for ANullableContainer { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ANullableContainer".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ANullableContainer".to_string()) }; if let Some(key) = key_result { @@ -103,12 +112,8 @@ impl std::str::FromStr for ANullableContainer { // Use the intermediate representation to return the struct std::result::Result::Ok(ANullableContainer { - nullable_thing: std::result::Result::Err( - "Nullable types not supported in ANullableContainer".to_string(), - )?, - required_nullable_thing: std::result::Result::Err( - "Nullable types not supported in ANullableContainer".to_string(), - )?, + nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?, + required_nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?, }) } } @@ -119,16 +124,13 @@ impl std::str::FromStr for ANullableContainer { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ANullableContainer - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ANullableContainer - value: {} is invalid {}", + hdr_value, e)) } } } @@ -139,25 +141,24 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ANullableContainer - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ANullableContainer - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// An additionalPropertiesObject #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -211,24 +212,28 @@ impl ::std::str::FromStr for AdditionalPropertiesObject { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err( - "Parsing additionalProperties for AdditionalPropertiesObject is not supported", - ) + std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesObject is not supported") } } + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct AllOfObject { #[serde(rename = "sampleProperty")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub sample_property: Option, #[serde(rename = "sampleBaseProperty")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub sample_base_property: Option, + } + impl AllOfObject { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> AllOfObject { @@ -245,18 +250,22 @@ impl AllOfObject { impl std::string::ToString for AllOfObject { fn to_string(&self) -> String { let params: Vec> = vec![ + self.sample_property.as_ref().map(|sample_property| { - ["sampleProperty".to_string(), sample_property.to_string()].join(",") + [ + "sampleProperty".to_string(), + sample_property.to_string(), + ].join(",") }), - self.sample_base_property - .as_ref() - .map(|sample_base_property| { - [ - "sampleBaseProperty".to_string(), - sample_base_property.to_string(), - ] - .join(",") - }), + + + self.sample_base_property.as_ref().map(|sample_base_property| { + [ + "sampleBaseProperty".to_string(), + sample_base_property.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -287,29 +296,17 @@ impl std::str::FromStr for AllOfObject { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing AllOfObject".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing AllOfObject".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "sampleProperty" => intermediate_rep.sample_property.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "sampleProperty" => intermediate_rep.sample_property.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "sampleBaseProperty" => intermediate_rep.sample_base_property.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing AllOfObject".to_string(), - ) - } + "sampleBaseProperty" => intermediate_rep.sample_base_property.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string()) } } @@ -331,16 +328,13 @@ impl std::str::FromStr for AllOfObject { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for AllOfObject - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AllOfObject - value: {} is invalid {}", + hdr_value, e)) } } } @@ -351,33 +345,37 @@ impl std::convert::TryFrom for header::IntoHeaderValue fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AllOfObject - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into AllOfObject - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct BaseAllOf { #[serde(rename = "sampleBaseProperty")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub sample_base_property: Option, + } + impl BaseAllOf { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> BaseAllOf { @@ -392,17 +390,16 @@ impl BaseAllOf { /// Should be implemented in a serde serializer impl std::string::ToString for BaseAllOf { fn to_string(&self) -> String { - let params: Vec> = - vec![self - .sample_base_property - .as_ref() - .map(|sample_base_property| { - [ - "sampleBaseProperty".to_string(), - sample_base_property.to_string(), - ] - .join(",") - })]; + let params: Vec> = vec![ + + self.sample_base_property.as_ref().map(|sample_base_property| { + [ + "sampleBaseProperty".to_string(), + sample_base_property.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -431,25 +428,15 @@ impl std::str::FromStr for BaseAllOf { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing BaseAllOf".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing BaseAllOf".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "sampleBaseProperty" => intermediate_rep.sample_base_property.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing BaseAllOf".to_string(), - ) - } + "sampleBaseProperty" => intermediate_rep.sample_base_property.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string()) } } @@ -470,16 +457,13 @@ impl std::str::FromStr for BaseAllOf { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for BaseAllOf - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for BaseAllOf - value: {} is invalid {}", + hdr_value, e)) } } } @@ -490,25 +474,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue { fn try_from(hdr_value: HeaderValue) -> std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into BaseAllOf - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into BaseAllOf - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct DummyPutRequest { @@ -516,14 +502,19 @@ pub struct DummyPutRequest { pub id: String, #[serde(rename = "password")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub password: Option, + } + impl DummyPutRequest { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(id: String) -> DummyPutRequest { - DummyPutRequest { id, password: None } + pub fn new(id: String, ) -> DummyPutRequest { + DummyPutRequest { + id, + password: None, + } } } @@ -533,11 +524,18 @@ impl DummyPutRequest { impl std::string::ToString for DummyPutRequest { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("id".to_string()), Some(self.id.to_string()), - self.password - .as_ref() - .map(|password| ["password".to_string(), password.to_string()].join(",")), + + + self.password.as_ref().map(|password| { + [ + "password".to_string(), + password.to_string(), + ].join(",") + }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -568,29 +566,17 @@ impl std::str::FromStr for DummyPutRequest { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing DummyPutRequest".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing DummyPutRequest".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "id" => intermediate_rep.id.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "id" => intermediate_rep.id.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "password" => intermediate_rep.password.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing DummyPutRequest".to_string(), - ) - } + "password" => intermediate_rep.password.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string()) } } @@ -600,11 +586,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_else(|| "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(), }) } @@ -616,16 +598,13 @@ impl std::str::FromStr for DummyPutRequest { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for DummyPutRequest - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for DummyPutRequest - value: {} is invalid {}", + hdr_value, e)) } } } @@ -636,40 +615,45 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into DummyPutRequest - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into DummyPutRequest - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// structured response + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct GetYamlResponse { - /// Inner string +/// Inner string #[serde(rename = "value")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub value: Option, + } + impl GetYamlResponse { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> GetYamlResponse { - GetYamlResponse { value: None } + GetYamlResponse { + value: None, + } } } @@ -678,10 +662,16 @@ impl GetYamlResponse { /// Should be implemented in a serde serializer impl std::string::ToString for GetYamlResponse { fn to_string(&self) -> String { - let params: Vec> = vec![self - .value - .as_ref() - .map(|value| ["value".to_string(), value.to_string()].join(","))]; + let params: Vec> = vec![ + + self.value.as_ref().map(|value| { + [ + "value".to_string(), + value.to_string(), + ].join(",") + }), + + ]; params.into_iter().flatten().collect::>().join(",") } @@ -710,25 +700,15 @@ impl std::str::FromStr for GetYamlResponse { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing GetYamlResponse".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing GetYamlResponse".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "value" => intermediate_rep.value.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing GetYamlResponse".to_string(), - ) - } + "value" => intermediate_rep.value.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string()) } } @@ -749,16 +729,13 @@ impl std::str::FromStr for GetYamlResponse { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for GetYamlResponse - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for GetYamlResponse - value: {} is invalid {}", + hdr_value, e)) } } } @@ -769,39 +746,44 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into GetYamlResponse - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into GetYamlResponse - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + /// An object of objects + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjects { #[serde(rename = "inner")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub inner: Option, + } + impl ObjectOfObjects { #[allow(clippy::new_without_default, clippy::too_many_arguments)] pub fn new() -> ObjectOfObjects { - ObjectOfObjects { inner: None } + ObjectOfObjects { + inner: None, + } } } @@ -842,26 +824,15 @@ impl std::str::FromStr for ObjectOfObjects { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectOfObjects".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectOfObjects".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "inner" => intermediate_rep.inner.push( - ::from_str(val) - .map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ObjectOfObjects".to_string(), - ) - } + "inner" => intermediate_rep.inner.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string()) } } @@ -882,16 +853,13 @@ impl std::str::FromStr for ObjectOfObjects { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectOfObjects - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectOfObjects - value: {} is invalid {}", + hdr_value, e)) } } } @@ -902,25 +870,27 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectOfObjects - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectOfObjects - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + + + + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ObjectOfObjectsInner { @@ -928,13 +898,15 @@ pub struct ObjectOfObjectsInner { pub required_thing: String, #[serde(rename = "optional_thing")] - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if="Option::is_none")] pub optional_thing: Option, + } + impl ObjectOfObjectsInner { #[allow(clippy::new_without_default, clippy::too_many_arguments)] - pub fn new(required_thing: String) -> ObjectOfObjectsInner { + pub fn new(required_thing: String, ) -> ObjectOfObjectsInner { ObjectOfObjectsInner { required_thing, optional_thing: None, @@ -948,11 +920,18 @@ impl ObjectOfObjectsInner { impl std::string::ToString for ObjectOfObjectsInner { fn to_string(&self) -> String { let params: Vec> = vec![ + Some("required_thing".to_string()), Some(self.required_thing.to_string()), + + self.optional_thing.as_ref().map(|optional_thing| { - ["optional_thing".to_string(), optional_thing.to_string()].join(",") + [ + "optional_thing".to_string(), + optional_thing.to_string(), + ].join(",") }), + ]; params.into_iter().flatten().collect::>().join(",") @@ -983,29 +962,17 @@ impl std::str::FromStr for ObjectOfObjectsInner { while key_result.is_some() { let val = match string_iter.next() { Some(x) => x, - None => { - return std::result::Result::Err( - "Missing value while parsing ObjectOfObjectsInner".to_string(), - ) - } + None => return std::result::Result::Err("Missing value while parsing ObjectOfObjectsInner".to_string()) }; if let Some(key) = key_result { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "required_thing" => intermediate_rep.required_thing.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), + "required_thing" => intermediate_rep.required_thing.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "optional_thing" => intermediate_rep.optional_thing.push( - ::from_str(val).map_err(|x| x.to_string())?, - ), - _ => { - return std::result::Result::Err( - "Unexpected key while parsing ObjectOfObjectsInner".to_string(), - ) - } + "optional_thing" => intermediate_rep.optional_thing.push(::from_str(val).map_err(|x| x.to_string())?), + _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string()) } } @@ -1015,11 +982,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_else(|| "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(), }) } @@ -1031,16 +994,13 @@ impl std::str::FromStr for ObjectOfObjectsInner { impl std::convert::TryFrom> for HeaderValue { type Error = String; - fn try_from( - hdr_value: header::IntoHeaderValue, - ) -> std::result::Result { + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { let hdr_value = hdr_value.to_string(); match HeaderValue::from_str(&hdr_value) { - std::result::Result::Ok(value) => std::result::Result::Ok(value), - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}", - hdr_value, e - )), + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}", + hdr_value, e)) } } } @@ -1051,21 +1011,20 @@ impl std::convert::TryFrom for header::IntoHeaderValue std::result::Result { match hdr_value.to_str() { - std::result::Result::Ok(value) => { - match ::from_str(value) { - std::result::Result::Ok(value) => { - std::result::Result::Ok(header::IntoHeaderValue(value)) + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectOfObjectsInner - {}", + value, err)) } - std::result::Result::Err(err) => std::result::Result::Err(format!( - "Unable to convert header value '{}' into ObjectOfObjectsInner - {}", - value, err - )), - } - } - std::result::Result::Err(e) => std::result::Result::Err(format!( - "Unable to convert header: {:?} to string: {}", - hdr_value, e - )), + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) } } } + + + diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 7acb80ed7adb..b08d1c72d6a0 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -12,10 +12,16 @@ use crate::{header, types::*}; #[allow(unused_imports)] use crate::models; -use crate::{ - AllOfGetResponse, Api, DummyGetResponse, DummyPutResponse, FileResponseGetResponse, - GetStructuredYamlResponse, HtmlPostResponse, PostYamlResponse, RawJsonGetResponse, - SoloObjectPostResponse, +use crate::{Api, + AllOfGetResponse, + DummyGetResponse, + DummyPutResponse, + FileResponseGetResponse, + GetStructuredYamlResponse, + HtmlPostResponse, + PostYamlResponse, + RawJsonGetResponse, + SoloObjectPostResponse }; /// Setup API Server. @@ -26,628 +32,729 @@ where { // build our application with a route Router::new() - .route("/allOf", get(all_of_get::)) - .route("/dummy", get(dummy_get::).put(dummy_put::)) - .route("/file_response", get(file_response_get::)) - .route("/get-structured-yaml", get(get_structured_yaml::)) - .route("/html", post(html_post::)) - .route("/post-yaml", post(post_yaml::)) - .route("/raw_json", get(raw_json_get::)) - .route("/solo-object", post(solo_object_post::)) + .route("/allOf", + get(all_of_get::) + ) + .route("/dummy", + get(dummy_get::).put(dummy_put::) + ) + .route("/file_response", + get(file_response_get::) + ) + .route("/get-structured-yaml", + get(get_structured_yaml::) + ) + .route("/html", + post(html_post::) + ) + .route("/post-yaml", + post(post_yaml::) + ) + .route("/raw_json", + get(raw_json_get::) + ) + .route("/solo-object", + post(solo_object_post::) + ) .with_state(api_impl) } + #[tracing::instrument(skip_all)] -fn all_of_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn all_of_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// AllOfGet - GET /allOf #[tracing::instrument(skip_all)] async fn all_of_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || all_of_get_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + all_of_get_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().all_of_get(method, host, cookies).await; + let result = api_impl.as_ref().all_of_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - AllOfGetResponse::Status200_OK(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + AllOfGetResponse::Status200_OK + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn dummy_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn dummy_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// DummyGet - GET /dummy #[tracing::instrument(skip_all)] async fn dummy_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || dummy_get_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + dummy_get_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().dummy_get(method, host, cookies).await; + let result = api_impl.as_ref().dummy_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DummyGetResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DummyGetResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct DummyPutBodyValidator<'a> { - #[validate] - body: &'a models::DummyPutRequest, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct DummyPutBodyValidator<'a> { + #[validate] + body: &'a models::DummyPutRequest, + } + #[tracing::instrument(skip_all)] fn dummy_put_validation( - body: models::DummyPutRequest, -) -> std::result::Result<(models::DummyPutRequest,), ValidationErrors> { - let b = DummyPutBodyValidator { body: &body }; - b.validate()?; + body: models::DummyPutRequest, +) -> std::result::Result<( + models::DummyPutRequest, +), ValidationErrors> +{ + let b = DummyPutBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// DummyPut - PUT /dummy #[tracing::instrument(skip_all)] async fn dummy_put( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || dummy_put_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + dummy_put_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .dummy_put(method, host, cookies, body) - .await; + let result = api_impl.as_ref().dummy_put( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - DummyPutResponse::Status200_Success => { - let mut response = response.status(200); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + DummyPutResponse::Status200_Success + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(200); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn file_response_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn file_response_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// FileResponseGet - GET /file_response #[tracing::instrument(skip_all)] async fn file_response_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || file_response_get_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + file_response_get_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .file_response_get(method, host, cookies) - .await; + let result = api_impl.as_ref().file_response_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - FileResponseGetResponse::Status200_Success(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + FileResponseGetResponse::Status200_Success + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn get_structured_yaml_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn get_structured_yaml_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// GetStructuredYaml - GET /get-structured-yaml #[tracing::instrument(skip_all)] async fn get_structured_yaml( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || get_structured_yaml_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + get_structured_yaml_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .get_structured_yaml(method, host, cookies) - .await; + let result = api_impl.as_ref().get_structured_yaml( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - GetStructuredYamlResponse::Status200_OK(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/yaml").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + GetStructuredYamlResponse::Status200_OK + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("application/yaml").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct HtmlPostBodyValidator<'a> { - body: &'a String, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct HtmlPostBodyValidator<'a> { + body: &'a String, + } + #[tracing::instrument(skip_all)] -fn html_post_validation(body: String) -> std::result::Result<(String,), ValidationErrors> { - Ok((body,)) +fn html_post_validation( + body: String, +) -> std::result::Result<( + String, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// HtmlPost - POST /html #[tracing::instrument(skip_all)] async fn html_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: String, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: String, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || html_post_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + html_post_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .html_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().html_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - HtmlPostResponse::Status200_Success(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/html").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + HtmlPostResponse::Status200_Success + (body) + => { - let body_content = body; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("text/html").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = body; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct PostYamlBodyValidator<'a> { - body: &'a String, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct PostYamlBodyValidator<'a> { + body: &'a String, + } + #[tracing::instrument(skip_all)] -fn post_yaml_validation(body: String) -> std::result::Result<(String,), ValidationErrors> { - Ok((body,)) +fn post_yaml_validation( + body: String, +) -> std::result::Result<( + String, +), ValidationErrors> +{ + +Ok(( + body, +)) } /// PostYaml - POST /post-yaml #[tracing::instrument(skip_all)] async fn post_yaml( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - body: String, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + body: String, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || post_yaml_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + post_yaml_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .post_yaml(method, host, cookies, body) - .await; + let result = api_impl.as_ref().post_yaml( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - PostYamlResponse::Status204_OK => { - let mut response = response.status(204); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + PostYamlResponse::Status204_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(204); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } + #[tracing::instrument(skip_all)] -fn raw_json_get_validation() -> std::result::Result<(), ValidationErrors> { - Ok(()) +fn raw_json_get_validation( +) -> std::result::Result<( +), ValidationErrors> +{ + +Ok(( +)) } /// RawJsonGet - GET /raw_json #[tracing::instrument(skip_all)] async fn raw_json_get( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || raw_json_get_validation()) - .await - .unwrap(); - let Ok(()) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + raw_json_get_validation( + ) + ).await.unwrap(); + + let Ok(( + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl.as_ref().raw_json_get(method, host, cookies).await; + let result = api_impl.as_ref().raw_json_get( + method, + host, + cookies, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - RawJsonGetResponse::Status200_Success(body) => { - let mut response = response.status(200); - { - let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("*/*").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); - } + let resp = match result { + Ok(rsp) => match rsp { + RawJsonGetResponse::Status200_Success + (body) + => { - let body_content = tokio::task::spawn_blocking(move || { - serde_json::to_vec(&body).map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) - }) - .await - .unwrap()?; - response.body(Body::from(body_content)) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let mut response = response.status(200); + { + let mut response_headers = response.headers_mut().unwrap(); + response_headers.insert( + CONTENT_TYPE, + HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?); + } - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let body_content = tokio::task::spawn_blocking(move || + serde_json::to_vec(&body).map_err(|e| { + error!(error = ?e); + StatusCode::INTERNAL_SERVER_ERROR + })).await.unwrap()?; + response.body(Body::from(body_content)) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } -#[derive(validator::Validate)] -#[allow(dead_code)] -struct SoloObjectPostBodyValidator<'a> { - body: &'a crate::types::Object, -} + #[derive(validator::Validate)] + #[allow(dead_code)] + struct SoloObjectPostBodyValidator<'a> { + body: &'a crate::types::Object, + } + #[tracing::instrument(skip_all)] fn solo_object_post_validation( - body: crate::types::Object, -) -> std::result::Result<(crate::types::Object,), ValidationErrors> { - let b = SoloObjectPostBodyValidator { body: &body }; - b.validate()?; + body: crate::types::Object, +) -> std::result::Result<( + crate::types::Object, +), ValidationErrors> +{ + let b = SoloObjectPostBodyValidator { body: &body }; + b.validate()?; - Ok((body,)) +Ok(( + body, +)) } /// SoloObjectPost - POST /solo-object #[tracing::instrument(skip_all)] async fn solo_object_post( - method: Method, - host: Host, - cookies: CookieJar, - State(api_impl): State, - Json(body): Json, + method: Method, + host: Host, + cookies: CookieJar, + State(api_impl): State, + Json(body): Json, ) -> Result -where +where I: AsRef + Send + Sync, A: Api, { - #[allow(clippy::redundant_closure)] - let validation = tokio::task::spawn_blocking(move || solo_object_post_validation(body)) - .await - .unwrap(); - let Ok((body,)) = validation else { - return Response::builder() + #[allow(clippy::redundant_closure)] + let validation = tokio::task::spawn_blocking(move || + solo_object_post_validation( + body, + ) + ).await.unwrap(); + + let Ok(( + body, + )) = validation else { + return Response::builder() .status(StatusCode::BAD_REQUEST) .body(Body::from(validation.unwrap_err().to_string())) - .map_err(|_| StatusCode::BAD_REQUEST); - }; + .map_err(|_| StatusCode::BAD_REQUEST); + }; - let result = api_impl - .as_ref() - .solo_object_post(method, host, cookies, body) - .await; + let result = api_impl.as_ref().solo_object_post( + method, + host, + cookies, + body, + ).await; - let mut response = Response::builder(); + let mut response = Response::builder(); - let resp = match result { - Ok(rsp) => match rsp { - SoloObjectPostResponse::Status204_OK => { - let mut response = response.status(204); - response.body(Body::empty()) - } - }, - Err(_) => { - // Application code returned an error. This should not happen, as the implementation should - // return a valid response. - response.status(500).body(Body::empty()) - } - }; + let resp = match result { + Ok(rsp) => match rsp { + SoloObjectPostResponse::Status204_OK + => { - resp.map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - }) + let mut response = response.status(204); + response.body(Body::empty()) + }, + }, + Err(_) => { + // Application code returned an error. This should not happen, as the implementation should + // return a valid response. + response.status(500).body(Body::empty()) + }, + }; + + resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR }) } +