update samples

This commit is contained in:
William Cheng
2024-01-10 11:19:38 +08:00
parent 1e0e8fe0eb
commit 7ddcb9a8cb
29 changed files with 11223 additions and 10118 deletions

View File

@@ -1,4 +1,3 @@
.openapi-generator-ignore
README.md README.md
build.gradle.kts build.gradle.kts
pom.xml pom.xml

View File

@@ -1 +1 @@
7.2.0-SNAPSHOT 7.3.0-SNAPSHOT

View File

@@ -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 * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */

View File

@@ -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 * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */

View File

@@ -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 * https://openapi-generator.tech
* Do not edit the class manually. * Do not edit the class manually.
*/ */

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -1,12 +1,4 @@
#![allow( #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_imports,
unused_extern_crates,
non_camel_case_types
)]
#![allow(unused_imports, unused_attributes)] #![allow(unused_imports, unused_attributes)]
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
@@ -22,60 +14,65 @@ use types::*;
pub const BASE_PATH: &str = ""; pub const BASE_PATH: &str = "";
pub const API_VERSION: &str = "1.0.7"; pub const API_VERSION: &str = "1.0.7";
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MultipartRelatedRequestPostResponse { pub enum MultipartRelatedRequestPostResponse {
/// OK /// OK
Status201_OK, Status201_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MultipartRequestPostResponse { pub enum MultipartRequestPostResponse {
/// OK /// OK
Status201_OK, Status201_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MultipleIdenticalMimeTypesPostResponse { pub enum MultipleIdenticalMimeTypesPostResponse {
/// OK /// OK
Status200_OK, Status200_OK
} }
/// API /// API
#[async_trait] #[async_trait]
#[allow(clippy::ptr_arg)] #[allow(clippy::ptr_arg)]
pub trait Api { 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<MultipartRelatedRequestPostResponse, String>;
/// MultipartRequestPost - POST /multipart_request /// MultipartRelatedRequestPost - POST /multipart_related_request
async fn multipart_request_post( async fn multipart_related_request_post(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: Multipart, body: axum::body::Body,
) -> Result<MultipartRequestPostResponse, String>; ) -> Result<MultipartRelatedRequestPostResponse, String>;
/// MultipartRequestPost - POST /multipart_request
async fn multipart_request_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Multipart,
) -> Result<MultipartRequestPostResponse, String>;
/// 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<MultipleIdenticalMimeTypesPostResponse, String>;
/// 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<MultipleIdenticalMimeTypesPostResponse, String>;
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@@ -7,24 +7,34 @@ use validator::Validate;
use crate::header; use crate::header;
use crate::{models, types::*}; use crate::{models, types::*};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRelatedRequest { pub struct MultipartRelatedRequest {
#[serde(rename = "object_field")] #[serde(rename = "object_field")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub object_field: Option<models::MultipartRequestObjectField>, pub object_field: Option<models::MultipartRequestObjectField>,
#[serde(rename = "optional_binary_field")] #[serde(rename = "optional_binary_field")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub optional_binary_field: Option<ByteArray>, pub optional_binary_field: Option<ByteArray>,
#[serde(rename = "required_binary_field")] #[serde(rename = "required_binary_field")]
pub required_binary_field: ByteArray, pub required_binary_field: ByteArray,
} }
impl MultipartRelatedRequest { impl MultipartRelatedRequest {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[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 { MultipartRelatedRequest {
object_field: None, object_field: None,
optional_binary_field: None, optional_binary_field: None,
@@ -78,11 +88,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing MultipartRelatedRequest".to_string())
return std::result::Result::Err(
"Missing value while parsing MultipartRelatedRequest".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
@@ -104,13 +110,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
std::result::Result::Ok(MultipartRelatedRequest { std::result::Result::Ok(MultipartRelatedRequest {
object_field: intermediate_rep.object_field.into_iter().next(), object_field: intermediate_rep.object_field.into_iter().next(),
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(), optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
required_binary_field: intermediate_rep 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
.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<header::IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for MultipartRelatedRequest - value: {} is invalid {}", format!("Invalid header value for MultipartRelatedRequest - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -141,25 +138,27 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartRel
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <MultipartRelatedRequest as std::str::FromStr>::from_str(value) { match <MultipartRelatedRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRequestObjectField { pub struct MultipartRequestObjectField {
@@ -167,13 +166,15 @@ pub struct MultipartRequestObjectField {
pub field_a: String, pub field_a: String,
#[serde(rename = "field_b")] #[serde(rename = "field_b")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub field_b: Option<Vec<String>>, pub field_b: Option<Vec<String>>,
} }
impl MultipartRequestObjectField { impl MultipartRequestObjectField {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(field_a: String) -> MultipartRequestObjectField { pub fn new(field_a: String, ) -> MultipartRequestObjectField {
MultipartRequestObjectField { MultipartRequestObjectField {
field_a, field_a,
field_b: None, field_b: None,
@@ -187,19 +188,18 @@ impl MultipartRequestObjectField {
impl std::string::ToString for MultipartRequestObjectField { impl std::string::ToString for MultipartRequestObjectField {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![ let params: Vec<Option<String>> = vec![
Some("field_a".to_string()), Some("field_a".to_string()),
Some(self.field_a.to_string()), Some(self.field_a.to_string()),
self.field_b.as_ref().map(|field_b| { self.field_b.as_ref().map(|field_b| {
[ [
"field_b".to_string(), "field_b".to_string(),
field_b field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
.iter() ].join(",")
.map(|x| x.to_string())
.collect::<Vec<_>>()
.join(","),
]
.join(",")
}), }),
]; ];
params.into_iter().flatten().collect::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
@@ -230,11 +230,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing MultipartRequestObjectField".to_string())
return std::result::Result::Err(
"Missing value while parsing MultipartRequestObjectField".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
@@ -253,11 +249,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
// Use the intermediate representation to return the struct // Use the intermediate representation to return the struct
std::result::Result::Ok(MultipartRequestObjectField { std::result::Result::Ok(MultipartRequestObjectField {
field_a: intermediate_rep field_a: intermediate_rep.field_a.into_iter().next().ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
.field_a
.into_iter()
.next()
.ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
field_b: intermediate_rep.field_b.into_iter().next(), field_b: intermediate_rep.field_b.into_iter().next(),
}) })
} }
@@ -269,16 +261,13 @@ impl std::str::FromStr for MultipartRequestObjectField {
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRequestObjectField>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRequestObjectField>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for MultipartRequestObjectField - value: {} is invalid {}", format!("Invalid header value for MultipartRequestObjectField - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -289,37 +278,41 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartReq
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <MultipartRequestObjectField as std::str::FromStr>::from_str(value) { match <MultipartRequestObjectField as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipleIdenticalMimeTypesPostRequest { pub struct MultipleIdenticalMimeTypesPostRequest {
#[serde(rename = "binary1")] #[serde(rename = "binary1")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub binary1: Option<ByteArray>, pub binary1: Option<ByteArray>,
#[serde(rename = "binary2")] #[serde(rename = "binary2")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub binary2: Option<ByteArray>, pub binary2: Option<ByteArray>,
} }
impl MultipleIdenticalMimeTypesPostRequest { impl MultipleIdenticalMimeTypesPostRequest {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> MultipleIdenticalMimeTypesPostRequest { pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
@@ -372,12 +365,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing MultipleIdenticalMimeTypesPostRequest".to_string())
return std::result::Result::Err(
"Missing value while parsing MultipleIdenticalMimeTypesPostRequest"
.to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
@@ -404,14 +392,10 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
// Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and HeaderValue // Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and HeaderValue
#[cfg(feature = "server")] #[cfg(feature = "server")]
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>> impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>> for HeaderValue {
for HeaderValue
{
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
@@ -423,9 +407,7 @@ impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPos
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]
impl std::convert::TryFrom<HeaderValue> impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> {
for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>
{
type Error = String; type Error = String;
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
@@ -444,3 +426,6 @@ impl std::convert::TryFrom<HeaderValue>
} }
} }
} }

View File

@@ -12,9 +12,10 @@ use crate::{header, types::*};
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::models; use crate::models;
use crate::{ use crate::{Api,
Api, MultipartRelatedRequestPostResponse, MultipartRequestPostResponse, MultipartRelatedRequestPostResponse,
MultipleIdenticalMimeTypesPostResponse, MultipartRequestPostResponse,
MultipleIdenticalMimeTypesPostResponse
}; };
/// Setup API Server. /// Setup API Server.
@@ -25,187 +26,216 @@ where
{ {
// build our application with a route // build our application with a route
Router::new() Router::new()
.route( .route("/multipart_related_request",
"/multipart_related_request", post(multipart_related_request_post::<I, A>)
post(multipart_related_request_post::<I, A>),
) )
.route("/multipart_request", post(multipart_request_post::<I, A>)) .route("/multipart_request",
.route( post(multipart_request_post::<I, A>)
"/multiple-identical-mime-types", )
post(multiple_identical_mime_types_post::<I, A>), .route("/multiple-identical-mime-types",
post(multiple_identical_mime_types_post::<I, A>)
) )
.with_state(api_impl) .with_state(api_impl)
} }
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
fn multipart_related_request_post_validation() -> std::result::Result<(), ValidationErrors> { fn multipart_related_request_post_validation(
Ok(()) ) -> std::result::Result<(
), ValidationErrors>
{
Ok((
))
} }
/// MultipartRelatedRequestPost - POST /multipart_related_request /// MultipartRelatedRequestPost - POST /multipart_related_request
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn multipart_related_request_post<I, A>( async fn multipart_related_request_post<I, A>(
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
State(api_impl): State<I>, State(api_impl): State<I>,
body: axum::body::Body, body: axum::body::Body,
) -> Result<Response, StatusCode> ) -> Result<Response, StatusCode>
where where
I: AsRef<A> + Send + Sync, I: AsRef<A> + Send + Sync,
A: Api, A: Api,
{ {
#[allow(clippy::redundant_closure)]
let validation =
tokio::task::spawn_blocking(move || multipart_related_request_post_validation())
.await
.unwrap();
let Ok(()) = validation else { #[allow(clippy::redundant_closure)]
return Response::builder() 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) .status(StatusCode::BAD_REQUEST)
.body(Body::from(validation.unwrap_err().to_string())) .body(Body::from(validation.unwrap_err().to_string()))
.map_err(|_| StatusCode::BAD_REQUEST); .map_err(|_| StatusCode::BAD_REQUEST);
}; };
let result = api_impl let result = api_impl.as_ref().multipart_related_request_post(
.as_ref() method,
.multipart_related_request_post(method, host, cookies, body) host,
.await; cookies,
body,
).await;
let mut response = Response::builder(); let mut response = Response::builder();
let resp = match result { let resp = match result {
Ok(rsp) => match rsp { Ok(rsp) => match rsp {
MultipartRelatedRequestPostResponse::Status201_OK => { 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())
}
};
resp.map_err(|e| { let mut response = response.status(201);
error!(error = ?e); response.body(Body::empty())
StatusCode::INTERNAL_SERVER_ERROR },
}) },
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)] #[tracing::instrument(skip_all)]
fn multipart_request_post_validation() -> std::result::Result<(), ValidationErrors> { fn multipart_request_post_validation(
Ok(()) ) -> std::result::Result<(
), ValidationErrors>
{
Ok((
))
} }
/// MultipartRequestPost - POST /multipart_request /// MultipartRequestPost - POST /multipart_request
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn multipart_request_post<I, A>( async fn multipart_request_post<I, A>(
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
State(api_impl): State<I>, State(api_impl): State<I>,
body: Multipart, body: Multipart,
) -> Result<Response, StatusCode> ) -> Result<Response, StatusCode>
where where
I: AsRef<A> + Send + Sync, I: AsRef<A> + Send + Sync,
A: Api, A: Api,
{ {
#[allow(clippy::redundant_closure)]
let validation = tokio::task::spawn_blocking(move || multipart_request_post_validation())
.await
.unwrap();
let Ok(()) = validation else { #[allow(clippy::redundant_closure)]
return Response::builder() let validation = tokio::task::spawn_blocking(move ||
multipart_request_post_validation(
)
).await.unwrap();
let Ok((
)) = validation else {
return Response::builder()
.status(StatusCode::BAD_REQUEST) .status(StatusCode::BAD_REQUEST)
.body(Body::from(validation.unwrap_err().to_string())) .body(Body::from(validation.unwrap_err().to_string()))
.map_err(|_| StatusCode::BAD_REQUEST); .map_err(|_| StatusCode::BAD_REQUEST);
}; };
let result = api_impl let result = api_impl.as_ref().multipart_request_post(
.as_ref() method,
.multipart_request_post(method, host, cookies, body) host,
.await; cookies,
body,
).await;
let mut response = Response::builder(); let mut response = Response::builder();
let resp = match result { let resp = match result {
Ok(rsp) => match rsp { Ok(rsp) => match rsp {
MultipartRequestPostResponse::Status201_OK => { 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())
}
};
resp.map_err(|e| { let mut response = response.status(201);
error!(error = ?e); response.body(Body::empty())
StatusCode::INTERNAL_SERVER_ERROR },
}) },
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)] #[tracing::instrument(skip_all)]
fn multiple_identical_mime_types_post_validation() -> std::result::Result<(), ValidationErrors> { fn multiple_identical_mime_types_post_validation(
Ok(()) ) -> std::result::Result<(
), ValidationErrors>
{
Ok((
))
} }
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types /// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn multiple_identical_mime_types_post<I, A>( async fn multiple_identical_mime_types_post<I, A>(
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
State(api_impl): State<I>, State(api_impl): State<I>,
body: axum::body::Body, body: axum::body::Body,
) -> Result<Response, StatusCode> ) -> Result<Response, StatusCode>
where where
I: AsRef<A> + Send + Sync, I: AsRef<A> + Send + Sync,
A: Api, 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 { #[allow(clippy::redundant_closure)]
return Response::builder() 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) .status(StatusCode::BAD_REQUEST)
.body(Body::from(validation.unwrap_err().to_string())) .body(Body::from(validation.unwrap_err().to_string()))
.map_err(|_| StatusCode::BAD_REQUEST); .map_err(|_| StatusCode::BAD_REQUEST);
}; };
let result = api_impl let result = api_impl.as_ref().multiple_identical_mime_types_post(
.as_ref() method,
.multiple_identical_mime_types_post(method, host, cookies, body) host,
.await; cookies,
body,
).await;
let mut response = Response::builder(); let mut response = Response::builder();
let resp = match result { let resp = match result {
Ok(rsp) => match rsp { Ok(rsp) => match rsp {
MultipleIdenticalMimeTypesPostResponse::Status200_OK => { 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())
}
};
resp.map_err(|e| { let mut response = response.status(200);
error!(error = ?e); response.body(Body::empty())
StatusCode::INTERNAL_SERVER_ERROR },
}) },
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 })
} }

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -1,12 +1,4 @@
#![allow( #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_imports,
unused_extern_crates,
non_camel_case_types
)]
#![allow(unused_imports, unused_attributes)] #![allow(unused_imports, unused_attributes)]
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
@@ -22,488 +14,569 @@ use types::*;
pub const BASE_PATH: &str = ""; pub const BASE_PATH: &str = "";
pub const API_VERSION: &str = "1.0.7"; pub const API_VERSION: &str = "1.0.7";
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum AnyOfGetResponse { pub enum AnyOfGetResponse {
/// Success /// Success
Status200_Success(models::AnyOfObject), Status200_Success
(models::AnyOfObject)
,
/// AlternateSuccess /// AlternateSuccess
Status201_AlternateSuccess(models::Model12345AnyOfObject), Status201_AlternateSuccess
(models::Model12345AnyOfObject)
,
/// AnyOfSuccess /// AnyOfSuccess
Status202_AnyOfSuccess(models::AnyOfGet202Response), Status202_AnyOfSuccess
(models::AnyOfGet202Response)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum CallbackWithHeaderPostResponse { pub enum CallbackWithHeaderPostResponse {
/// OK /// OK
Status204_OK, Status204_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum ComplexQueryParamGetResponse { pub enum ComplexQueryParamGetResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum EnumInPathPathParamGetResponse { pub enum EnumInPathPathParamGetResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum JsonComplexQueryParamGetResponse { pub enum JsonComplexQueryParamGetResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MandatoryRequestHeaderGetResponse { pub enum MandatoryRequestHeaderGetResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MergePatchJsonGetResponse { pub enum MergePatchJsonGetResponse {
/// merge-patch+json-encoded response /// 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] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MultigetGetResponse { pub enum MultigetGetResponse {
/// JSON rsp /// JSON rsp
Status200_JSONRsp(models::AnotherXmlObject), Status200_JSONRsp
(models::AnotherXmlObject)
,
/// XML rsp /// XML rsp
Status201_XMLRsp(String), Status201_XMLRsp
(String)
,
/// octet rsp /// octet rsp
Status202_OctetRsp(ByteArray), Status202_OctetRsp
(ByteArray)
,
/// string rsp /// string rsp
Status203_StringRsp(String), Status203_StringRsp
(String)
,
/// Duplicate Response long text. One. /// Duplicate Response long text. One.
Status204_DuplicateResponseLongText(models::AnotherXmlObject), Status204_DuplicateResponseLongText
(models::AnotherXmlObject)
,
/// Duplicate Response long text. Two. /// Duplicate Response long text. Two.
Status205_DuplicateResponseLongText(models::AnotherXmlObject), Status205_DuplicateResponseLongText
(models::AnotherXmlObject)
,
/// Duplicate Response long text. Three. /// 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] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum MultipleAuthSchemeGetResponse { pub enum MultipleAuthSchemeGetResponse {
/// Check that limiting to multiple required auth schemes works /// 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] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum OneOfGetResponse { pub enum OneOfGetResponse {
/// Success /// Success
Status200_Success(models::OneOfGet200Response), Status200_Success
(models::OneOfGet200Response)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum OverrideServerGetResponse { pub enum OverrideServerGetResponse {
/// Success. /// Success.
Status204_Success, Status204_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum ParamgetGetResponse { pub enum ParamgetGetResponse {
/// JSON rsp /// JSON rsp
Status200_JSONRsp(models::AnotherXmlObject), Status200_JSONRsp
(models::AnotherXmlObject)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum ReadonlyAuthSchemeGetResponse { pub enum ReadonlyAuthSchemeGetResponse {
/// Check that limiting to a single required auth scheme works /// 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] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum RegisterCallbackPostResponse { pub enum RegisterCallbackPostResponse {
/// OK /// OK
Status204_OK, Status204_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum RequiredOctetStreamPutResponse { pub enum RequiredOctetStreamPutResponse {
/// OK /// OK
Status200_OK, Status200_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum ResponsesWithHeadersGetResponse { pub enum ResponsesWithHeadersGetResponse {
/// Success /// Success
Status200_Success { Status200_Success
{
body: String, body: String,
success_info: String, success_info:
bool_header: Option<bool>, String
object_header: Option<models::ObjectHeader>, ,
}, bool_header:
Option<
bool
>
,
object_header:
Option<
models::ObjectHeader
>
}
,
/// Precondition Failed /// Precondition Failed
Status412_PreconditionFailed { Status412_PreconditionFailed
further_info: Option<String>, {
failure_info: Option<String>, further_info:
}, Option<
String
>
,
failure_info:
Option<
String
>
}
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum Rfc7807GetResponse { pub enum Rfc7807GetResponse {
/// OK /// OK
Status204_OK(models::ObjectWithArrayOfObjects), Status204_OK
(models::ObjectWithArrayOfObjects)
,
/// NotFound /// NotFound
Status404_NotFound(models::ObjectWithArrayOfObjects), Status404_NotFound
(models::ObjectWithArrayOfObjects)
,
/// NotAcceptable /// NotAcceptable
Status406_NotAcceptable(String), Status406_NotAcceptable
(String)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UntypedPropertyGetResponse { pub enum UntypedPropertyGetResponse {
/// Check that untyped properties works /// Check that untyped properties works
Status200_CheckThatUntypedPropertiesWorks, Status200_CheckThatUntypedPropertiesWorks
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UuidGetResponse { pub enum UuidGetResponse {
/// Duplicate Response long text. One. /// 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] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum XmlExtraPostResponse { pub enum XmlExtraPostResponse {
/// OK /// OK
Status201_OK, Status201_OK
,
/// Bad Request /// Bad Request
Status400_BadRequest, Status400_BadRequest
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum XmlOtherPostResponse { pub enum XmlOtherPostResponse {
/// OK /// OK
Status201_OK(String), Status201_OK
(String)
,
/// Bad Request /// Bad Request
Status400_BadRequest, Status400_BadRequest
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum XmlOtherPutResponse { pub enum XmlOtherPutResponse {
/// OK /// OK
Status201_OK, Status201_OK
,
/// Bad Request /// Bad Request
Status400_BadRequest, Status400_BadRequest
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum XmlPostResponse { pub enum XmlPostResponse {
/// OK /// OK
Status201_OK, Status201_OK
,
/// Bad Request /// Bad Request
Status400_BadRequest, Status400_BadRequest
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum XmlPutResponse { pub enum XmlPutResponse {
/// OK /// OK
Status201_OK, Status201_OK
,
/// Bad Request /// Bad Request
Status400_BadRequest, Status400_BadRequest
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum CreateRepoResponse { pub enum CreateRepoResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetRepoInfoResponse { pub enum GetRepoInfoResponse {
/// OK /// OK
Status200_OK(String), Status200_OK
(String)
} }
/// API /// API
#[async_trait] #[async_trait]
#[allow(clippy::ptr_arg)] #[allow(clippy::ptr_arg)]
pub trait Api { pub trait Api {
/// AnyOfGet - GET /any-of
async fn any_of_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
query_params: models::AnyOfGetQueryParams,
) -> Result<AnyOfGetResponse, String>;
/// CallbackWithHeaderPost - POST /callback-with-header /// AnyOfGet - GET /any-of
async fn callback_with_header_post( async fn any_of_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
query_params: models::CallbackWithHeaderPostQueryParams, query_params: models::AnyOfGetQueryParams,
) -> Result<CallbackWithHeaderPostResponse, String>; ) -> Result<AnyOfGetResponse, String>;
/// ComplexQueryParamGet - GET /complex-query-param
async fn complex_query_param_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
query_params: models::ComplexQueryParamGetQueryParams,
) -> Result<ComplexQueryParamGetResponse, String>;
/// EnumInPathPathParamGet - GET /enum_in_path/{path_param} /// CallbackWithHeaderPost - POST /callback-with-header
async fn enum_in_path_path_param_get( async fn callback_with_header_post(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
path_params: models::EnumInPathPathParamGetPathParams, query_params: models::CallbackWithHeaderPostQueryParams,
) -> Result<EnumInPathPathParamGetResponse, String>; ) -> Result<CallbackWithHeaderPostResponse, String>;
/// 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<JsonComplexQueryParamGetResponse, String>;
/// MandatoryRequestHeaderGet - GET /mandatory-request-header /// ComplexQueryParamGet - GET /complex-query-param
async fn mandatory_request_header_get( async fn complex_query_param_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
header_params: models::MandatoryRequestHeaderGetHeaderParams, query_params: models::ComplexQueryParamGetQueryParams,
) -> Result<MandatoryRequestHeaderGetResponse, String>; ) -> Result<ComplexQueryParamGetResponse, String>;
/// MergePatchJsonGet - GET /merge-patch-json
async fn merge_patch_json_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<MergePatchJsonGetResponse, String>;
/// Get some stuff.. /// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
/// async fn enum_in_path_path_param_get(
/// MultigetGet - GET /multiget &self,
async fn multiget_get( method: Method,
&self, host: Host,
method: Method, cookies: CookieJar,
host: Host, path_params: models::EnumInPathPathParamGetPathParams,
cookies: CookieJar, ) -> Result<EnumInPathPathParamGetResponse, String>;
) -> Result<MultigetGetResponse, String>;
/// MultipleAuthSchemeGet - GET /multiple_auth_scheme
async fn multiple_auth_scheme_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<MultipleAuthSchemeGetResponse, String>;
/// OneOfGet - GET /one-of /// JsonComplexQueryParamGet - GET /json-complex-query-param
async fn one_of_get( async fn json_complex_query_param_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
) -> Result<OneOfGetResponse, String>; query_params: models::JsonComplexQueryParamGetQueryParams,
) -> Result<JsonComplexQueryParamGetResponse, String>;
/// OverrideServerGet - GET /override-server
async fn override_server_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<OverrideServerGetResponse, String>;
/// Get some stuff with parameters.. /// MandatoryRequestHeaderGet - GET /mandatory-request-header
/// async fn mandatory_request_header_get(
/// ParamgetGet - GET /paramget &self,
async fn paramget_get( method: Method,
&self, host: Host,
method: Method, cookies: CookieJar,
host: Host, header_params: models::MandatoryRequestHeaderGetHeaderParams,
cookies: CookieJar, ) -> Result<MandatoryRequestHeaderGetResponse, String>;
query_params: models::ParamgetGetQueryParams,
) -> Result<ParamgetGetResponse, String>;
/// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
async fn readonly_auth_scheme_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<ReadonlyAuthSchemeGetResponse, String>;
/// RegisterCallbackPost - POST /register-callback /// MergePatchJsonGet - GET /merge-patch-json
async fn register_callback_post( async fn merge_patch_json_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
query_params: models::RegisterCallbackPostQueryParams, ) -> Result<MergePatchJsonGetResponse, String>;
) -> Result<RegisterCallbackPostResponse, String>;
/// RequiredOctetStreamPut - PUT /required_octet_stream
async fn required_octet_stream_put(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<RequiredOctetStreamPutResponse, String>;
/// ResponsesWithHeadersGet - GET /responses_with_headers /// Get some stuff..
async fn responses_with_headers_get( ///
&self, /// MultigetGet - GET /multiget
method: Method, async fn multiget_get(
host: Host, &self,
cookies: CookieJar, method: Method,
) -> Result<ResponsesWithHeadersGetResponse, String>; host: Host,
cookies: CookieJar,
) -> Result<MultigetGetResponse, String>;
/// Rfc7807Get - GET /rfc7807
async fn rfc7807_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<Rfc7807GetResponse, String>;
/// UntypedPropertyGet - GET /untyped_property /// MultipleAuthSchemeGet - GET /multiple_auth_scheme
async fn untyped_property_get( async fn multiple_auth_scheme_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: Option<models::ObjectUntypedProps>, ) -> Result<MultipleAuthSchemeGetResponse, String>;
) -> Result<UntypedPropertyGetResponse, String>;
/// UuidGet - GET /uuid
async fn uuid_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<UuidGetResponse, String>;
/// XmlExtraPost - POST /xml_extra /// OneOfGet - GET /one-of
async fn xml_extra_post( async fn one_of_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: Bytes, ) -> Result<OneOfGetResponse, String>;
) -> Result<XmlExtraPostResponse, String>;
/// XmlOtherPost - POST /xml_other
async fn xml_other_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlOtherPostResponse, String>;
/// XmlOtherPut - PUT /xml_other /// OverrideServerGet - GET /override-server
async fn xml_other_put( async fn override_server_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: Bytes, ) -> Result<OverrideServerGetResponse, String>;
) -> Result<XmlOtherPutResponse, String>;
/// Post an array.
///
/// XmlPost - POST /xml
async fn xml_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlPostResponse, String>;
/// XmlPut - PUT /xml /// Get some stuff with parameters..
async fn xml_put( ///
&self, /// ParamgetGet - GET /paramget
method: Method, async fn paramget_get(
host: Host, &self,
cookies: CookieJar, method: Method,
body: Bytes, host: Host,
) -> Result<XmlPutResponse, String>; cookies: CookieJar,
query_params: models::ParamgetGetQueryParams,
) -> Result<ParamgetGetResponse, String>;
/// CreateRepo - POST /repos
async fn create_repo(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: models::ObjectParam,
) -> Result<CreateRepoResponse, String>;
/// GetRepoInfo - GET /repos/{repoId} /// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
async fn get_repo_info( async fn readonly_auth_scheme_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
path_params: models::GetRepoInfoPathParams, ) -> Result<ReadonlyAuthSchemeGetResponse, String>;
) -> Result<GetRepoInfoResponse, String>;
/// RegisterCallbackPost - POST /register-callback
async fn register_callback_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
query_params: models::RegisterCallbackPostQueryParams,
) -> Result<RegisterCallbackPostResponse, String>;
/// RequiredOctetStreamPut - PUT /required_octet_stream
async fn required_octet_stream_put(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<RequiredOctetStreamPutResponse, String>;
/// ResponsesWithHeadersGet - GET /responses_with_headers
async fn responses_with_headers_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<ResponsesWithHeadersGetResponse, String>;
/// Rfc7807Get - GET /rfc7807
async fn rfc7807_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<Rfc7807GetResponse, String>;
/// UntypedPropertyGet - GET /untyped_property
async fn untyped_property_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Option<models::ObjectUntypedProps>,
) -> Result<UntypedPropertyGetResponse, String>;
/// UuidGet - GET /uuid
async fn uuid_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<UuidGetResponse, String>;
/// XmlExtraPost - POST /xml_extra
async fn xml_extra_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlExtraPostResponse, String>;
/// XmlOtherPost - POST /xml_other
async fn xml_other_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlOtherPostResponse, String>;
/// XmlOtherPut - PUT /xml_other
async fn xml_other_put(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlOtherPutResponse, String>;
/// Post an array.
///
/// XmlPost - POST /xml
async fn xml_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlPostResponse, String>;
/// XmlPut - PUT /xml
async fn xml_put(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: Bytes,
) -> Result<XmlPutResponse, String>;
/// CreateRepo - POST /repos
async fn create_repo(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: models::ObjectParam,
) -> Result<CreateRepoResponse, String>;
/// GetRepoInfo - GET /repos/{repoId}
async fn get_repo_info(
&self,
method: Method,
host: Host,
cookies: CookieJar,
path_params: models::GetRepoInfoPathParams,
) -> Result<GetRepoInfoResponse, String>;
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -1,12 +1,4 @@
#![allow( #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_imports,
unused_extern_crates,
non_camel_case_types
)]
#![allow(unused_imports, unused_attributes)] #![allow(unused_imports, unused_attributes)]
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
@@ -22,429 +14,490 @@ use types::*;
pub const BASE_PATH: &str = "/v2"; pub const BASE_PATH: &str = "/v2";
pub const API_VERSION: &str = "1.0.0"; pub const API_VERSION: &str = "1.0.0";
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum AddPetResponse { pub enum AddPetResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid input /// Invalid input
Status405_InvalidInput, Status405_InvalidInput
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum DeletePetResponse { pub enum DeletePetResponse {
/// Invalid pet value /// Invalid pet value
Status400_InvalidPetValue, Status400_InvalidPetValue
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum FindPetsByStatusResponse { pub enum FindPetsByStatusResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid status value /// Invalid status value
Status400_InvalidStatusValue, Status400_InvalidStatusValue
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum FindPetsByTagsResponse { pub enum FindPetsByTagsResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid tag value /// Invalid tag value
Status400_InvalidTagValue, Status400_InvalidTagValue
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetPetByIdResponse { pub enum GetPetByIdResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid ID supplied /// Invalid ID supplied
Status400_InvalidIDSupplied, Status400_InvalidIDSupplied
,
/// Pet not found /// Pet not found
Status404_PetNotFound, Status404_PetNotFound
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UpdatePetResponse { pub enum UpdatePetResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid ID supplied /// Invalid ID supplied
Status400_InvalidIDSupplied, Status400_InvalidIDSupplied
,
/// Pet not found /// Pet not found
Status404_PetNotFound, Status404_PetNotFound
,
/// Validation exception /// Validation exception
Status405_ValidationException, Status405_ValidationException
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UpdatePetWithFormResponse { pub enum UpdatePetWithFormResponse {
/// Invalid input /// Invalid input
Status405_InvalidInput, Status405_InvalidInput
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UploadFileResponse { pub enum UploadFileResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(models::ApiResponse), Status200_SuccessfulOperation
(models::ApiResponse)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum DeleteOrderResponse { pub enum DeleteOrderResponse {
/// Invalid ID supplied /// Invalid ID supplied
Status400_InvalidIDSupplied, Status400_InvalidIDSupplied
,
/// Order not found /// Order not found
Status404_OrderNotFound, Status404_OrderNotFound
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetInventoryResponse { pub enum GetInventoryResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(std::collections::HashMap<String, i32>), Status200_SuccessfulOperation
(std::collections::HashMap<String, i32>)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetOrderByIdResponse { pub enum GetOrderByIdResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid ID supplied /// Invalid ID supplied
Status400_InvalidIDSupplied, Status400_InvalidIDSupplied
,
/// Order not found /// Order not found
Status404_OrderNotFound, Status404_OrderNotFound
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum PlaceOrderResponse { pub enum PlaceOrderResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid Order /// Invalid Order
Status400_InvalidOrder, Status400_InvalidOrder
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum CreateUserResponse { pub enum CreateUserResponse {
/// successful operation /// successful operation
Status0_SuccessfulOperation, Status0_SuccessfulOperation
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum CreateUsersWithArrayInputResponse { pub enum CreateUsersWithArrayInputResponse {
/// successful operation /// successful operation
Status0_SuccessfulOperation, Status0_SuccessfulOperation
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum CreateUsersWithListInputResponse { pub enum CreateUsersWithListInputResponse {
/// successful operation /// successful operation
Status0_SuccessfulOperation, Status0_SuccessfulOperation
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum DeleteUserResponse { pub enum DeleteUserResponse {
/// Invalid username supplied /// Invalid username supplied
Status400_InvalidUsernameSupplied, Status400_InvalidUsernameSupplied
,
/// User not found /// User not found
Status404_UserNotFound, Status404_UserNotFound
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetUserByNameResponse { pub enum GetUserByNameResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation(String), Status200_SuccessfulOperation
(String)
,
/// Invalid username supplied /// Invalid username supplied
Status400_InvalidUsernameSupplied, Status400_InvalidUsernameSupplied
,
/// User not found /// User not found
Status404_UserNotFound, Status404_UserNotFound
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum LoginUserResponse { pub enum LoginUserResponse {
/// successful operation /// successful operation
Status200_SuccessfulOperation { Status200_SuccessfulOperation
{
body: String, body: String,
set_cookie: Option<String>, set_cookie:
x_rate_limit: Option<i32>, Option<
x_expires_after: Option<chrono::DateTime<chrono::Utc>>, String
}, >
,
x_rate_limit:
Option<
i32
>
,
x_expires_after:
Option<
chrono::DateTime::<chrono::Utc>
>
}
,
/// Invalid username/password supplied /// Invalid username/password supplied
Status400_InvalidUsername, Status400_InvalidUsername
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum LogoutUserResponse { pub enum LogoutUserResponse {
/// successful operation /// successful operation
Status0_SuccessfulOperation, Status0_SuccessfulOperation
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum UpdateUserResponse { pub enum UpdateUserResponse {
/// Invalid user supplied /// Invalid user supplied
Status400_InvalidUserSupplied, Status400_InvalidUserSupplied
,
/// User not found /// User not found
Status404_UserNotFound, Status404_UserNotFound
} }
/// API /// API
#[async_trait] #[async_trait]
#[allow(clippy::ptr_arg)] #[allow(clippy::ptr_arg)]
pub trait Api { 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<AddPetResponse, String>;
/// Deletes a pet. /// Add a new pet to the store.
/// ///
/// DeletePet - DELETE /v2/pet/{petId} /// AddPet - POST /v2/pet
async fn delete_pet( async fn add_pet(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
header_params: models::DeletePetHeaderParams, body: models::Pet,
path_params: models::DeletePetPathParams, ) -> Result<AddPetResponse, String>;
) -> Result<DeletePetResponse, String>;
/// 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<FindPetsByStatusResponse, String>;
/// Finds Pets by tags. /// Deletes a pet.
/// ///
/// FindPetsByTags - GET /v2/pet/findByTags /// DeletePet - DELETE /v2/pet/{petId}
async fn find_pets_by_tags( async fn delete_pet(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
query_params: models::FindPetsByTagsQueryParams, header_params: models::DeletePetHeaderParams,
) -> Result<FindPetsByTagsResponse, String>; path_params: models::DeletePetPathParams,
) -> Result<DeletePetResponse, String>;
/// 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<GetPetByIdResponse, String>;
/// Update an existing pet. /// Finds Pets by status.
/// ///
/// UpdatePet - PUT /v2/pet /// FindPetsByStatus - GET /v2/pet/findByStatus
async fn update_pet( async fn find_pets_by_status(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: models::Pet, query_params: models::FindPetsByStatusQueryParams,
) -> Result<UpdatePetResponse, String>; ) -> Result<FindPetsByStatusResponse, String>;
/// 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<UpdatePetWithFormResponse, String>;
/// uploads an image. /// Finds Pets by tags.
/// ///
/// UploadFile - POST /v2/pet/{petId}/uploadImage /// FindPetsByTags - GET /v2/pet/findByTags
async fn upload_file( async fn find_pets_by_tags(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
path_params: models::UploadFilePathParams, query_params: models::FindPetsByTagsQueryParams,
body: Multipart, ) -> Result<FindPetsByTagsResponse, String>;
) -> Result<UploadFileResponse, String>;
/// 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<DeleteOrderResponse, String>;
/// Returns pet inventories by status. /// Find pet by ID.
/// ///
/// GetInventory - GET /v2/store/inventory /// GetPetById - GET /v2/pet/{petId}
async fn get_inventory( async fn get_pet_by_id(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
) -> Result<GetInventoryResponse, String>; path_params: models::GetPetByIdPathParams,
) -> Result<GetPetByIdResponse, String>;
/// 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<GetOrderByIdResponse, String>;
/// Place an order for a pet. /// Update an existing pet.
/// ///
/// PlaceOrder - POST /v2/store/order /// UpdatePet - PUT /v2/pet
async fn place_order( async fn update_pet(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: models::Order, body: models::Pet,
) -> Result<PlaceOrderResponse, String>; ) -> Result<UpdatePetResponse, String>;
/// Create user.
///
/// CreateUser - POST /v2/user
async fn create_user(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: models::User,
) -> Result<CreateUserResponse, String>;
/// Creates list of users with given input array. /// Updates a pet in the store with form data.
/// ///
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray /// UpdatePetWithForm - POST /v2/pet/{petId}
async fn create_users_with_array_input( async fn update_pet_with_form(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
body: Vec<models::User>, path_params: models::UpdatePetWithFormPathParams,
) -> Result<CreateUsersWithArrayInputResponse, String>; ) -> Result<UpdatePetWithFormResponse, String>;
/// 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<models::User>,
) -> Result<CreateUsersWithListInputResponse, String>;
/// Delete user. /// uploads an image.
/// ///
/// DeleteUser - DELETE /v2/user/{username} /// UploadFile - POST /v2/pet/{petId}/uploadImage
async fn delete_user( async fn upload_file(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
path_params: models::DeleteUserPathParams, path_params: models::UploadFilePathParams,
) -> Result<DeleteUserResponse, String>; body: Multipart,
) -> Result<UploadFileResponse, String>;
/// 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<GetUserByNameResponse, String>;
/// Logs user into the system. /// Delete purchase order by ID.
/// ///
/// LoginUser - GET /v2/user/login /// DeleteOrder - DELETE /v2/store/order/{orderId}
async fn login_user( async fn delete_order(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
query_params: models::LoginUserQueryParams, path_params: models::DeleteOrderPathParams,
) -> Result<LoginUserResponse, String>; ) -> Result<DeleteOrderResponse, String>;
/// Logs out current logged in user session.
///
/// LogoutUser - GET /v2/user/logout
async fn logout_user(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<LogoutUserResponse, String>;
/// Updated user. /// Returns pet inventories by status.
/// ///
/// UpdateUser - PUT /v2/user/{username} /// GetInventory - GET /v2/store/inventory
async fn update_user( async fn get_inventory(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
path_params: models::UpdateUserPathParams, ) -> Result<GetInventoryResponse, String>;
body: models::User,
) -> Result<UpdateUserResponse, String>;
/// 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<GetOrderByIdResponse, String>;
/// 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<PlaceOrderResponse, String>;
/// Create user.
///
/// CreateUser - POST /v2/user
async fn create_user(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: models::User,
) -> Result<CreateUserResponse, String>;
/// 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<models::User>,
) -> Result<CreateUsersWithArrayInputResponse, String>;
/// 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<models::User>,
) -> Result<CreateUsersWithListInputResponse, String>;
/// Delete user.
///
/// DeleteUser - DELETE /v2/user/{username}
async fn delete_user(
&self,
method: Method,
host: Host,
cookies: CookieJar,
path_params: models::DeleteUserPathParams,
) -> Result<DeleteUserResponse, String>;
/// 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<GetUserByNameResponse, String>;
/// 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<LoginUserResponse, String>;
/// Logs out current logged in user session.
///
/// LogoutUser - GET /v2/user/logout
async fn logout_user(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<LogoutUserResponse, String>;
/// 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<UpdateUserResponse, String>;
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -1,12 +1,4 @@
#![allow( #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_imports,
unused_extern_crates,
non_camel_case_types
)]
#![allow(unused_imports, unused_attributes)] #![allow(unused_imports, unused_attributes)]
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
@@ -22,25 +14,28 @@ use types::*;
pub const BASE_PATH: &str = ""; pub const BASE_PATH: &str = "";
pub const API_VERSION: &str = "1.0"; pub const API_VERSION: &str = "1.0";
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum PingGetResponse { pub enum PingGetResponse {
/// OK /// OK
Status201_OK, Status201_OK
} }
/// API /// API
#[async_trait] #[async_trait]
#[allow(clippy::ptr_arg)] #[allow(clippy::ptr_arg)]
pub trait Api { pub trait Api {
/// PingGet - GET /ping
async fn ping_get( /// PingGet - GET /ping
&self, async fn ping_get(
method: Method, &self,
host: Host, method: Method,
cookies: CookieJar, host: Host,
) -> Result<PingGetResponse, String>; cookies: CookieJar,
) -> Result<PingGetResponse, String>;
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@@ -6,3 +6,6 @@ use validator::Validate;
#[cfg(feature = "server")] #[cfg(feature = "server")]
use crate::header; use crate::header;
use crate::{models, types::*}; use crate::{models, types::*};

View File

@@ -12,7 +12,9 @@ use crate::{header, types::*};
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::models; use crate::models;
use crate::{Api, PingGetResponse}; use crate::{Api,
PingGetResponse
};
/// Setup API Server. /// Setup API Server.
pub fn new<I, A>(api_impl: I) -> Router pub fn new<I, A>(api_impl: I) -> Router
@@ -22,59 +24,74 @@ where
{ {
// build our application with a route // build our application with a route
Router::new() Router::new()
.route("/ping", get(ping_get::<I, A>)) .route("/ping",
get(ping_get::<I, A>)
)
.with_state(api_impl) .with_state(api_impl)
} }
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
fn ping_get_validation() -> std::result::Result<(), ValidationErrors> { fn ping_get_validation(
Ok(()) ) -> std::result::Result<(
), ValidationErrors>
{
Ok((
))
} }
/// PingGet - GET /ping /// PingGet - GET /ping
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
async fn ping_get<I, A>( async fn ping_get<I, A>(
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
State(api_impl): State<I>, State(api_impl): State<I>,
) -> Result<Response, StatusCode> ) -> Result<Response, StatusCode>
where where
I: AsRef<A> + Send + Sync, I: AsRef<A> + Send + Sync,
A: Api, A: Api,
{ {
#[allow(clippy::redundant_closure)]
let validation = tokio::task::spawn_blocking(move || ping_get_validation())
.await
.unwrap();
let Ok(()) = validation else { #[allow(clippy::redundant_closure)]
return Response::builder() let validation = tokio::task::spawn_blocking(move ||
ping_get_validation(
)
).await.unwrap();
let Ok((
)) = validation else {
return Response::builder()
.status(StatusCode::BAD_REQUEST) .status(StatusCode::BAD_REQUEST)
.body(Body::from(validation.unwrap_err().to_string())) .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 { let resp = match result {
Ok(rsp) => match rsp { Ok(rsp) => match rsp {
PingGetResponse::Status201_OK => { 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())
}
};
resp.map_err(|e| { let mut response = response.status(201);
error!(error = ?e); response.body(Body::empty())
StatusCode::INTERNAL_SERVER_ERROR },
}) },
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 })
} }

View File

@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse::<$t>() { Ok(hdr_value) => match hdr_value.parse::<$t>() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse {} as a string: {}",
"Unable to parse {} as a string: {}", stringify!($t), e)),
stringify!($t),
e
)),
}, },
Err(e) => Err(format!( Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
"Unable to parse header {:?} as a string - {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -74,17 +69,14 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue( Ok(hdr_value) => Ok(IntoHeaderValue(
hdr_value hdr_value
.split(',') .split(',')
.filter_map(|x| match x.trim() { .filter_map(|x| match x.trim() {
"" => None, "" => None,
y => Some(y.to_string()), y => Some(y.to_string()),
}) })
.collect(), .collect())),
)), Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
Err(e) => Err(format!( hdr_value, e)),
"Unable to parse header: {:?} as a string - {}",
hdr_value, e
)),
} }
} }
} }
@@ -93,13 +85,11 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
type Error = String; type Error = String;
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.join(", ")) { match HeaderValue::from_str(&hdr_value.0.join(", ")) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
"Unable to convert {:?} into a header - {}", hdr_value, e))
hdr_value, e }
)),
}
} }
} }
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())), 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<IntoHeaderValue<String>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0) { match HeaderValue::from_str(&hdr_value.0) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match hdr_value.parse() { Ok(hdr_value) => match hdr_value.parse() {
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)), 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!( Err(e) => Err(format!("Unable to convert {:?} from a header {}",
"Unable to convert {:?} from a header {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(&hdr_value.0.to_string()) { match HeaderValue::from_str(&hdr_value.0.to_string()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
"Unable to convert: {:?} into a header: {}", hdr_value, e))
hdr_value, e
)),
} }
} }
} }
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
match hdr_value.to_str() { match hdr_value.to_str() {
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) { Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))), 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!( Err(e) => Err(format!("Unable to convert header {:?} to string {}",
"Unable to convert header {:?} to string {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> { fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) { match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
Ok(hdr_value) => Ok(hdr_value), Ok(hdr_value) => Ok(hdr_value),
Err(e) => Err(format!( Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
"Unable to convert {:?} to a header: {}", hdr_value, e)),
hdr_value, e
)),
} }
} }
} }

View File

@@ -1,12 +1,4 @@
#![allow( #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_imports,
unused_extern_crates,
non_camel_case_types
)]
#![allow(unused_imports, unused_attributes)] #![allow(unused_imports, unused_attributes)]
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)] #![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
@@ -22,167 +14,183 @@ use types::*;
pub const BASE_PATH: &str = ""; pub const BASE_PATH: &str = "";
pub const API_VERSION: &str = "2.3.4"; pub const API_VERSION: &str = "2.3.4";
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum AllOfGetResponse { pub enum AllOfGetResponse {
/// OK /// OK
Status200_OK(models::AllOfObject), Status200_OK
(models::AllOfObject)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum DummyGetResponse { pub enum DummyGetResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum DummyPutResponse { pub enum DummyPutResponse {
/// Success /// Success
Status200_Success, Status200_Success
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum FileResponseGetResponse { pub enum FileResponseGetResponse {
/// Success /// Success
Status200_Success(ByteArray), Status200_Success
(ByteArray)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum GetStructuredYamlResponse { pub enum GetStructuredYamlResponse {
/// OK /// OK
Status200_OK(String), Status200_OK
(String)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum HtmlPostResponse { pub enum HtmlPostResponse {
/// Success /// Success
Status200_Success(String), Status200_Success
(String)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum PostYamlResponse { pub enum PostYamlResponse {
/// OK /// OK
Status204_OK, Status204_OK
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum RawJsonGetResponse { pub enum RawJsonGetResponse {
/// Success /// Success
Status200_Success(crate::types::Object), Status200_Success
(crate::types::Object)
} }
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[must_use] #[must_use]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum SoloObjectPostResponse { pub enum SoloObjectPostResponse {
/// OK /// OK
Status204_OK, Status204_OK
} }
/// API /// API
#[async_trait] #[async_trait]
#[allow(clippy::ptr_arg)] #[allow(clippy::ptr_arg)]
pub trait Api { pub trait Api {
/// AllOfGet - GET /allOf
async fn all_of_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<AllOfGetResponse, String>;
/// A dummy endpoint to make the spec valid.. /// AllOfGet - GET /allOf
/// async fn all_of_get(
/// DummyGet - GET /dummy &self,
async fn dummy_get( method: Method,
&self, host: Host,
method: Method, cookies: CookieJar,
host: Host, ) -> Result<AllOfGetResponse, String>;
cookies: CookieJar,
) -> Result<DummyGetResponse, String>;
/// DummyPut - PUT /dummy
async fn dummy_put(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: models::DummyPutRequest,
) -> Result<DummyPutResponse, String>;
/// Get a file. /// A dummy endpoint to make the spec valid..
/// ///
/// FileResponseGet - GET /file_response /// DummyGet - GET /dummy
async fn file_response_get( async fn dummy_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
) -> Result<FileResponseGetResponse, String>; ) -> Result<DummyGetResponse, String>;
/// GetStructuredYaml - GET /get-structured-yaml
async fn get_structured_yaml(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<GetStructuredYamlResponse, String>;
/// Test HTML handling. /// DummyPut - PUT /dummy
/// async fn dummy_put(
/// HtmlPost - POST /html &self,
async fn html_post( method: Method,
&self, host: Host,
method: Method, cookies: CookieJar,
host: Host, body: models::DummyPutRequest,
cookies: CookieJar, ) -> Result<DummyPutResponse, String>;
body: String,
) -> Result<HtmlPostResponse, String>;
/// PostYaml - POST /post-yaml
async fn post_yaml(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: String,
) -> Result<PostYamlResponse, String>;
/// Get an arbitrary JSON blob.. /// Get a file.
/// ///
/// RawJsonGet - GET /raw_json /// FileResponseGet - GET /file_response
async fn raw_json_get( async fn file_response_get(
&self, &self,
method: Method, method: Method,
host: Host, host: Host,
cookies: CookieJar, cookies: CookieJar,
) -> Result<RawJsonGetResponse, String>; ) -> Result<FileResponseGetResponse, String>;
/// GetStructuredYaml - GET /get-structured-yaml
async fn get_structured_yaml(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<GetStructuredYamlResponse, String>;
/// Test HTML handling.
///
/// HtmlPost - POST /html
async fn html_post(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: String,
) -> Result<HtmlPostResponse, String>;
/// PostYaml - POST /post-yaml
async fn post_yaml(
&self,
method: Method,
host: Host,
cookies: CookieJar,
body: String,
) -> Result<PostYamlResponse, String>;
/// Get an arbitrary JSON blob..
///
/// RawJsonGet - GET /raw_json
async fn raw_json_get(
&self,
method: Method,
host: Host,
cookies: CookieJar,
) -> Result<RawJsonGetResponse, String>;
/// 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<SoloObjectPostResponse, String>;
/// 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<SoloObjectPostResponse, String>;
} }
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@@ -7,22 +7,38 @@ use validator::Validate;
use crate::header; use crate::header;
use crate::{models, types::*}; use crate::{models, types::*};
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ANullableContainer { pub struct ANullableContainer {
#[serde(rename = "NullableThing")] #[serde(rename = "NullableThing")]
#[serde(deserialize_with = "deserialize_optional_nullable")] #[serde(deserialize_with = "deserialize_optional_nullable")]
#[serde(default = "default_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<Nullable<String>>, pub nullable_thing: Option<Nullable<String>>,
#[serde(rename = "RequiredNullableThing")] #[serde(rename = "RequiredNullableThing")]
pub required_nullable_thing: Nullable<String>, pub required_nullable_thing: Nullable<String>,
} }
impl ANullableContainer { impl ANullableContainer {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(required_nullable_thing: Nullable<String>) -> ANullableContainer { pub fn new(required_nullable_thing: Nullable<String>, ) -> ANullableContainer {
ANullableContainer { ANullableContainer {
nullable_thing: None, nullable_thing: None,
required_nullable_thing, required_nullable_thing,
@@ -36,21 +52,18 @@ impl ANullableContainer {
impl std::string::ToString for ANullableContainer { impl std::string::ToString for ANullableContainer {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![ let params: Vec<Option<String>> = vec![
self.nullable_thing.as_ref().map(|nullable_thing| { self.nullable_thing.as_ref().map(|nullable_thing| {
[ [
"NullableThing".to_string(), "NullableThing".to_string(),
nullable_thing nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()),
.as_ref() ].join(",")
.map_or("null".to_string(), |x| x.to_string()),
]
.join(",")
}), }),
Some("RequiredNullableThing".to_string()), Some("RequiredNullableThing".to_string()),
Some( Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())),
self.required_nullable_thing
.as_ref()
.map_or("null".to_string(), |x| x.to_string()),
),
]; ];
params.into_iter().flatten().collect::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
@@ -81,11 +94,7 @@ impl std::str::FromStr for ANullableContainer {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing ANullableContainer".to_string())
return std::result::Result::Err(
"Missing value while parsing ANullableContainer".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
@@ -103,12 +112,8 @@ impl std::str::FromStr for ANullableContainer {
// Use the intermediate representation to return the struct // Use the intermediate representation to return the struct
std::result::Result::Ok(ANullableContainer { std::result::Result::Ok(ANullableContainer {
nullable_thing: std::result::Result::Err( nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?,
"Nullable types not supported in ANullableContainer".to_string(), required_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<header::IntoHeaderValue<ANullableContainer>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<ANullableContainer>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<ANullableContainer>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for ANullableContainer - value: {} is invalid {}", format!("Invalid header value for ANullableContainer - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -139,25 +141,24 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ANullableCon
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <ANullableContainer as std::str::FromStr>::from_str(value) { match <ANullableContainer as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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 /// An additionalPropertiesObject
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
@@ -211,24 +212,28 @@ impl ::std::str::FromStr for AdditionalPropertiesObject {
type Err = &'static str; type Err = &'static str;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
std::result::Result::Err( std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesObject is not supported")
"Parsing additionalProperties for AdditionalPropertiesObject is not supported",
)
} }
} }
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AllOfObject { pub struct AllOfObject {
#[serde(rename = "sampleProperty")] #[serde(rename = "sampleProperty")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub sample_property: Option<String>, pub sample_property: Option<String>,
#[serde(rename = "sampleBaseProperty")] #[serde(rename = "sampleBaseProperty")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub sample_base_property: Option<String>, pub sample_base_property: Option<String>,
} }
impl AllOfObject { impl AllOfObject {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> AllOfObject { pub fn new() -> AllOfObject {
@@ -245,18 +250,22 @@ impl AllOfObject {
impl std::string::ToString for AllOfObject { impl std::string::ToString for AllOfObject {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![ let params: Vec<Option<String>> = vec![
self.sample_property.as_ref().map(|sample_property| { 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| { self.sample_base_property.as_ref().map(|sample_base_property| {
[ [
"sampleBaseProperty".to_string(), "sampleBaseProperty".to_string(),
sample_base_property.to_string(), sample_base_property.to_string(),
] ].join(",")
.join(",") }),
}),
]; ];
params.into_iter().flatten().collect::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
@@ -287,29 +296,17 @@ impl std::str::FromStr for AllOfObject {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing AllOfObject".to_string())
return std::result::Result::Err(
"Missing value while parsing AllOfObject".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"sampleProperty" => intermediate_rep.sample_property.push( "sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
),
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"sampleBaseProperty" => intermediate_rep.sample_base_property.push( "sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?, _ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string())
),
_ => {
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<header::IntoHeaderValue<AllOfObject>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<AllOfObject>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<AllOfObject>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for AllOfObject - value: {} is invalid {}", format!("Invalid header value for AllOfObject - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -351,33 +345,37 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<AllOfObject>
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <AllOfObject as std::str::FromStr>::from_str(value) { match <AllOfObject as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct BaseAllOf { pub struct BaseAllOf {
#[serde(rename = "sampleBaseProperty")] #[serde(rename = "sampleBaseProperty")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub sample_base_property: Option<String>, pub sample_base_property: Option<String>,
} }
impl BaseAllOf { impl BaseAllOf {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> BaseAllOf { pub fn new() -> BaseAllOf {
@@ -392,17 +390,16 @@ impl BaseAllOf {
/// Should be implemented in a serde serializer /// Should be implemented in a serde serializer
impl std::string::ToString for BaseAllOf { impl std::string::ToString for BaseAllOf {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = let params: Vec<Option<String>> = vec![
vec![self
.sample_base_property self.sample_base_property.as_ref().map(|sample_base_property| {
.as_ref() [
.map(|sample_base_property| { "sampleBaseProperty".to_string(),
[ sample_base_property.to_string(),
"sampleBaseProperty".to_string(), ].join(",")
sample_base_property.to_string(), }),
]
.join(",") ];
})];
params.into_iter().flatten().collect::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
} }
@@ -431,25 +428,15 @@ impl std::str::FromStr for BaseAllOf {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing BaseAllOf".to_string())
return std::result::Result::Err(
"Missing value while parsing BaseAllOf".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"sampleBaseProperty" => intermediate_rep.sample_base_property.push( "sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?, _ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string())
),
_ => {
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<header::IntoHeaderValue<BaseAllOf>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<BaseAllOf>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<BaseAllOf>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for BaseAllOf - value: {} is invalid {}", format!("Invalid header value for BaseAllOf - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -490,25 +474,27 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <BaseAllOf as std::str::FromStr>::from_str(value) { match <BaseAllOf as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct DummyPutRequest { pub struct DummyPutRequest {
@@ -516,14 +502,19 @@ pub struct DummyPutRequest {
pub id: String, pub id: String,
#[serde(rename = "password")] #[serde(rename = "password")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub password: Option<String>, pub password: Option<String>,
} }
impl DummyPutRequest { impl DummyPutRequest {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(id: String) -> DummyPutRequest { pub fn new(id: String, ) -> DummyPutRequest {
DummyPutRequest { id, password: None } DummyPutRequest {
id,
password: None,
}
} }
} }
@@ -533,11 +524,18 @@ impl DummyPutRequest {
impl std::string::ToString for DummyPutRequest { impl std::string::ToString for DummyPutRequest {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![ let params: Vec<Option<String>> = vec![
Some("id".to_string()), Some("id".to_string()),
Some(self.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::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
@@ -568,29 +566,17 @@ impl std::str::FromStr for DummyPutRequest {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing DummyPutRequest".to_string())
return std::result::Result::Err(
"Missing value while parsing DummyPutRequest".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"id" => intermediate_rep.id.push( "id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
),
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"password" => intermediate_rep.password.push( "password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?, _ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string())
),
_ => {
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 // Use the intermediate representation to return the struct
std::result::Result::Ok(DummyPutRequest { std::result::Result::Ok(DummyPutRequest {
id: intermediate_rep id: intermediate_rep.id.into_iter().next().ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
.id
.into_iter()
.next()
.ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
password: intermediate_rep.password.into_iter().next(), password: intermediate_rep.password.into_iter().next(),
}) })
} }
@@ -616,16 +598,13 @@ impl std::str::FromStr for DummyPutRequest {
impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<DummyPutRequest>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<DummyPutRequest>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for DummyPutRequest - value: {} is invalid {}", format!("Invalid header value for DummyPutRequest - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -636,40 +615,45 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<DummyPutRequ
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <DummyPutRequest as std::str::FromStr>::from_str(value) { match <DummyPutRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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 /// structured response
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct GetYamlResponse { pub struct GetYamlResponse {
/// Inner string /// Inner string
#[serde(rename = "value")] #[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub value: Option<String>, pub value: Option<String>,
} }
impl GetYamlResponse { impl GetYamlResponse {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> GetYamlResponse { pub fn new() -> GetYamlResponse {
GetYamlResponse { value: None } GetYamlResponse {
value: None,
}
} }
} }
@@ -678,10 +662,16 @@ impl GetYamlResponse {
/// Should be implemented in a serde serializer /// Should be implemented in a serde serializer
impl std::string::ToString for GetYamlResponse { impl std::string::ToString for GetYamlResponse {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![self let params: Vec<Option<String>> = vec![
.value
.as_ref() self.value.as_ref().map(|value| {
.map(|value| ["value".to_string(), value.to_string()].join(","))]; [
"value".to_string(),
value.to_string(),
].join(",")
}),
];
params.into_iter().flatten().collect::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
} }
@@ -710,25 +700,15 @@ impl std::str::FromStr for GetYamlResponse {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing GetYamlResponse".to_string())
return std::result::Result::Err(
"Missing value while parsing GetYamlResponse".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"value" => intermediate_rep.value.push( "value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?, _ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string())
),
_ => {
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<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<GetYamlResponse>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<GetYamlResponse>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for GetYamlResponse - value: {} is invalid {}", format!("Invalid header value for GetYamlResponse - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -769,39 +746,44 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<GetYamlRespo
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <GetYamlResponse as std::str::FromStr>::from_str(value) { match <GetYamlResponse as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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 /// An object of objects
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjects { pub struct ObjectOfObjects {
#[serde(rename = "inner")] #[serde(rename = "inner")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub inner: Option<models::ObjectOfObjectsInner>, pub inner: Option<models::ObjectOfObjectsInner>,
} }
impl ObjectOfObjects { impl ObjectOfObjects {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new() -> ObjectOfObjects { 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() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing ObjectOfObjects".to_string())
return std::result::Result::Err(
"Missing value while parsing ObjectOfObjects".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"inner" => intermediate_rep.inner.push( "inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val) _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string())
.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<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjects>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<ObjectOfObjects>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for ObjectOfObjects - value: {} is invalid {}", format!("Invalid header value for ObjectOfObjects - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -902,25 +870,27 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <ObjectOfObjects as std::str::FromStr>::from_str(value) { match <ObjectOfObjects as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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)] #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjectsInner { pub struct ObjectOfObjectsInner {
@@ -928,13 +898,15 @@ pub struct ObjectOfObjectsInner {
pub required_thing: String, pub required_thing: String,
#[serde(rename = "optional_thing")] #[serde(rename = "optional_thing")]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub optional_thing: Option<i32>, pub optional_thing: Option<i32>,
} }
impl ObjectOfObjectsInner { impl ObjectOfObjectsInner {
#[allow(clippy::new_without_default, clippy::too_many_arguments)] #[allow(clippy::new_without_default, clippy::too_many_arguments)]
pub fn new(required_thing: String) -> ObjectOfObjectsInner { pub fn new(required_thing: String, ) -> ObjectOfObjectsInner {
ObjectOfObjectsInner { ObjectOfObjectsInner {
required_thing, required_thing,
optional_thing: None, optional_thing: None,
@@ -948,11 +920,18 @@ impl ObjectOfObjectsInner {
impl std::string::ToString for ObjectOfObjectsInner { impl std::string::ToString for ObjectOfObjectsInner {
fn to_string(&self) -> String { fn to_string(&self) -> String {
let params: Vec<Option<String>> = vec![ let params: Vec<Option<String>> = vec![
Some("required_thing".to_string()), Some("required_thing".to_string()),
Some(self.required_thing.to_string()), Some(self.required_thing.to_string()),
self.optional_thing.as_ref().map(|optional_thing| { 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::<Vec<_>>().join(",") params.into_iter().flatten().collect::<Vec<_>>().join(",")
@@ -983,29 +962,17 @@ impl std::str::FromStr for ObjectOfObjectsInner {
while key_result.is_some() { while key_result.is_some() {
let val = match string_iter.next() { let val = match string_iter.next() {
Some(x) => x, Some(x) => x,
None => { None => return std::result::Result::Err("Missing value while parsing ObjectOfObjectsInner".to_string())
return std::result::Result::Err(
"Missing value while parsing ObjectOfObjectsInner".to_string(),
)
}
}; };
if let Some(key) = key_result { if let Some(key) = key_result {
#[allow(clippy::match_single_binding)] #[allow(clippy::match_single_binding)]
match key { match key {
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"required_thing" => intermediate_rep.required_thing.push( "required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
),
#[allow(clippy::redundant_clone)] #[allow(clippy::redundant_clone)]
"optional_thing" => intermediate_rep.optional_thing.push( "optional_thing" => intermediate_rep.optional_thing.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?, _ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string())
),
_ => {
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 // Use the intermediate representation to return the struct
std::result::Result::Ok(ObjectOfObjectsInner { std::result::Result::Ok(ObjectOfObjectsInner {
required_thing: intermediate_rep required_thing: intermediate_rep.required_thing.into_iter().next().ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
.required_thing
.into_iter()
.next()
.ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
optional_thing: intermediate_rep.optional_thing.into_iter().next(), optional_thing: intermediate_rep.optional_thing.into_iter().next(),
}) })
} }
@@ -1031,16 +994,13 @@ impl std::str::FromStr for ObjectOfObjectsInner {
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue { impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue {
type Error = String; type Error = String;
fn try_from( fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>) -> std::result::Result<Self, Self::Error> {
hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>,
) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string(); let hdr_value = hdr_value.to_string();
match HeaderValue::from_str(&hdr_value) { match HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value), std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(format!( std::result::Result::Err(e) => std::result::Result::Err(
"Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}", format!("Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
hdr_value, e hdr_value, e))
)),
} }
} }
} }
@@ -1051,21 +1011,20 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> { fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() { match hdr_value.to_str() {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => {
match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) { match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => { std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(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 - {}", std::result::Result::Err(e) => std::result::Result::Err(
value, 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
)),
} }
} }
} }