forked from loafle/openapi-generator-original
update samples
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
.openapi-generator-ignore
|
||||
README.md
|
||||
build.gradle.kts
|
||||
pom.xml
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.2.0-SNAPSHOT
|
||||
7.3.0-SNAPSHOT
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT).
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT).
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.2.0-SNAPSHOT).
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,7 +19,7 @@ pub const API_VERSION: &str = "1.0.7";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MultipartRelatedRequestPostResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -35,7 +27,7 @@ pub enum MultipartRelatedRequestPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MultipartRequestPostResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -43,13 +35,15 @@ pub enum MultipartRequestPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MultipleIdenticalMimeTypesPostResponse {
|
||||
/// OK
|
||||
Status200_OK,
|
||||
Status200_OK
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||
async fn multipart_related_request_post(
|
||||
&self,
|
||||
@@ -59,6 +53,7 @@ pub trait Api {
|
||||
body: axum::body::Body,
|
||||
) -> Result<MultipartRelatedRequestPostResponse, String>;
|
||||
|
||||
|
||||
/// MultipartRequestPost - POST /multipart_request
|
||||
async fn multipart_request_post(
|
||||
&self,
|
||||
@@ -68,6 +63,7 @@ pub trait Api {
|
||||
body: Multipart,
|
||||
) -> Result<MultipartRequestPostResponse, String>;
|
||||
|
||||
|
||||
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||
async fn multiple_identical_mime_types_post(
|
||||
&self,
|
||||
@@ -76,6 +72,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
body: axum::body::Body,
|
||||
) -> Result<MultipleIdenticalMimeTypesPostResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
@@ -7,6 +7,14 @@ use validator::Validate;
|
||||
use crate::header;
|
||||
use crate::{models, types::*};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct MultipartRelatedRequest {
|
||||
@@ -20,11 +28,13 @@ pub struct MultipartRelatedRequest {
|
||||
|
||||
#[serde(rename = "required_binary_field")]
|
||||
pub required_binary_field: ByteArray,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl MultipartRelatedRequest {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new(required_binary_field: ByteArray) -> MultipartRelatedRequest {
|
||||
pub fn new(required_binary_field: ByteArray, ) -> MultipartRelatedRequest {
|
||||
MultipartRelatedRequest {
|
||||
object_field: None,
|
||||
optional_binary_field: None,
|
||||
@@ -78,11 +88,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing MultipartRelatedRequest".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing MultipartRelatedRequest".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
@@ -104,13 +110,7 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
std::result::Result::Ok(MultipartRelatedRequest {
|
||||
object_field: intermediate_rep.object_field.into_iter().next(),
|
||||
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
|
||||
required_binary_field: intermediate_rep
|
||||
.required_binary_field
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| {
|
||||
"required_binary_field missing in MultipartRelatedRequest".to_string()
|
||||
})?,
|
||||
required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or_else(|| "required_binary_field missing in MultipartRelatedRequest".to_string())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -121,16 +121,13 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for MultipartRelatedRequest - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for MultipartRelatedRequest - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,23 +140,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartRel
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <MultipartRelatedRequest as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into MultipartRelatedRequest - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into MultipartRelatedRequest - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct MultipartRequestObjectField {
|
||||
@@ -169,11 +168,13 @@ pub struct MultipartRequestObjectField {
|
||||
#[serde(rename = "field_b")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub field_b: Option<Vec<String>>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl MultipartRequestObjectField {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new(field_a: String) -> MultipartRequestObjectField {
|
||||
pub fn new(field_a: String, ) -> MultipartRequestObjectField {
|
||||
MultipartRequestObjectField {
|
||||
field_a,
|
||||
field_b: None,
|
||||
@@ -187,19 +188,18 @@ impl MultipartRequestObjectField {
|
||||
impl std::string::ToString for MultipartRequestObjectField {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
Some("field_a".to_string()),
|
||||
Some(self.field_a.to_string()),
|
||||
|
||||
|
||||
self.field_b.as_ref().map(|field_b| {
|
||||
[
|
||||
"field_b".to_string(),
|
||||
field_b
|
||||
.iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(","),
|
||||
]
|
||||
.join(",")
|
||||
field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
@@ -230,11 +230,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing MultipartRequestObjectField".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing MultipartRequestObjectField".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
@@ -253,11 +249,7 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(MultipartRequestObjectField {
|
||||
field_a: intermediate_rep
|
||||
.field_a
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
|
||||
field_a: intermediate_rep.field_a.into_iter().next().ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
|
||||
field_b: intermediate_rep.field_b.into_iter().next(),
|
||||
})
|
||||
}
|
||||
@@ -269,16 +261,13 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRequestObjectField>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for MultipartRequestObjectField - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for MultipartRequestObjectField - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,23 +280,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartReq
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <MultipartRequestObjectField as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into MultipartRequestObjectField - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into MultipartRequestObjectField - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct MultipleIdenticalMimeTypesPostRequest {
|
||||
@@ -318,8 +309,10 @@ pub struct MultipleIdenticalMimeTypesPostRequest {
|
||||
#[serde(rename = "binary2")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub binary2: Option<ByteArray>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl MultipleIdenticalMimeTypesPostRequest {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
|
||||
@@ -372,12 +365,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing MultipleIdenticalMimeTypesPostRequest"
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing MultipleIdenticalMimeTypesPostRequest".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
@@ -404,14 +392,10 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
||||
// Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and HeaderValue
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>>
|
||||
for HeaderValue
|
||||
{
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
@@ -423,9 +407,7 @@ impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPos
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl std::convert::TryFrom<HeaderValue>
|
||||
for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>
|
||||
{
|
||||
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
|
||||
@@ -444,3 +426,6 @@ impl std::convert::TryFrom<HeaderValue>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ use crate::{header, types::*};
|
||||
#[allow(unused_imports)]
|
||||
use crate::models;
|
||||
|
||||
use crate::{
|
||||
Api, MultipartRelatedRequestPostResponse, MultipartRequestPostResponse,
|
||||
MultipleIdenticalMimeTypesPostResponse,
|
||||
use crate::{Api,
|
||||
MultipartRelatedRequestPostResponse,
|
||||
MultipartRequestPostResponse,
|
||||
MultipleIdenticalMimeTypesPostResponse
|
||||
};
|
||||
|
||||
/// Setup API Server.
|
||||
@@ -25,21 +26,27 @@ where
|
||||
{
|
||||
// build our application with a route
|
||||
Router::new()
|
||||
.route(
|
||||
"/multipart_related_request",
|
||||
post(multipart_related_request_post::<I, A>),
|
||||
.route("/multipart_related_request",
|
||||
post(multipart_related_request_post::<I, A>)
|
||||
)
|
||||
.route("/multipart_request", post(multipart_request_post::<I, A>))
|
||||
.route(
|
||||
"/multiple-identical-mime-types",
|
||||
post(multiple_identical_mime_types_post::<I, A>),
|
||||
.route("/multipart_request",
|
||||
post(multipart_request_post::<I, A>)
|
||||
)
|
||||
.route("/multiple-identical-mime-types",
|
||||
post(multiple_identical_mime_types_post::<I, A>)
|
||||
)
|
||||
.with_state(api_impl)
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn multipart_related_request_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn multipart_related_request_post_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||
@@ -55,49 +62,58 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation =
|
||||
tokio::task::spawn_blocking(move || multipart_related_request_post_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
multipart_related_request_post_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.multipart_related_request_post(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().multipart_related_request_post(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
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| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn multipart_request_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn multipart_request_post_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// MultipartRequestPost - POST /multipart_request
|
||||
@@ -113,48 +129,58 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || multipart_request_post_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
multipart_request_post_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.multipart_request_post(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().multipart_request_post(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
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| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn multiple_identical_mime_types_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn multiple_identical_mime_types_post_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||
@@ -170,42 +196,46 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation =
|
||||
tokio::task::spawn_blocking(move || multiple_identical_mime_types_post_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
multiple_identical_mime_types_post_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.multiple_identical_mime_types_post(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().multiple_identical_mime_types_post(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
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| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,11 +19,16 @@ pub const API_VERSION: &str = "1.0.7";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AnyOfGetResponse {
|
||||
/// Success
|
||||
Status200_Success(models::AnyOfObject),
|
||||
Status200_Success
|
||||
(models::AnyOfObject)
|
||||
,
|
||||
/// AlternateSuccess
|
||||
Status201_AlternateSuccess(models::Model12345AnyOfObject),
|
||||
Status201_AlternateSuccess
|
||||
(models::Model12345AnyOfObject)
|
||||
,
|
||||
/// AnyOfSuccess
|
||||
Status202_AnyOfSuccess(models::AnyOfGet202Response),
|
||||
Status202_AnyOfSuccess
|
||||
(models::AnyOfGet202Response)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -39,7 +36,7 @@ pub enum AnyOfGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CallbackWithHeaderPostResponse {
|
||||
/// OK
|
||||
Status204_OK,
|
||||
Status204_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -47,7 +44,7 @@ pub enum CallbackWithHeaderPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum ComplexQueryParamGetResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -55,7 +52,7 @@ pub enum ComplexQueryParamGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum EnumInPathPathParamGetResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -63,7 +60,7 @@ pub enum EnumInPathPathParamGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum JsonComplexQueryParamGetResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -71,7 +68,7 @@ pub enum JsonComplexQueryParamGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MandatoryRequestHeaderGetResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -79,7 +76,8 @@ pub enum MandatoryRequestHeaderGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MergePatchJsonGetResponse {
|
||||
/// merge-patch+json-encoded response
|
||||
Status200_Merge(models::AnotherXmlObject),
|
||||
Status200_Merge
|
||||
(models::AnotherXmlObject)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -87,19 +85,32 @@ pub enum MergePatchJsonGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MultigetGetResponse {
|
||||
/// JSON rsp
|
||||
Status200_JSONRsp(models::AnotherXmlObject),
|
||||
Status200_JSONRsp
|
||||
(models::AnotherXmlObject)
|
||||
,
|
||||
/// XML rsp
|
||||
Status201_XMLRsp(String),
|
||||
Status201_XMLRsp
|
||||
(String)
|
||||
,
|
||||
/// octet rsp
|
||||
Status202_OctetRsp(ByteArray),
|
||||
Status202_OctetRsp
|
||||
(ByteArray)
|
||||
,
|
||||
/// string rsp
|
||||
Status203_StringRsp(String),
|
||||
Status203_StringRsp
|
||||
(String)
|
||||
,
|
||||
/// Duplicate Response long text. One.
|
||||
Status204_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||
Status204_DuplicateResponseLongText
|
||||
(models::AnotherXmlObject)
|
||||
,
|
||||
/// Duplicate Response long text. Two.
|
||||
Status205_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||
Status205_DuplicateResponseLongText
|
||||
(models::AnotherXmlObject)
|
||||
,
|
||||
/// Duplicate Response long text. Three.
|
||||
Status206_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||
Status206_DuplicateResponseLongText
|
||||
(models::AnotherXmlObject)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -107,7 +118,7 @@ pub enum MultigetGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum MultipleAuthSchemeGetResponse {
|
||||
/// Check that limiting to multiple required auth schemes works
|
||||
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks,
|
||||
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -115,7 +126,8 @@ pub enum MultipleAuthSchemeGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum OneOfGetResponse {
|
||||
/// Success
|
||||
Status200_Success(models::OneOfGet200Response),
|
||||
Status200_Success
|
||||
(models::OneOfGet200Response)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -123,7 +135,7 @@ pub enum OneOfGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum OverrideServerGetResponse {
|
||||
/// Success.
|
||||
Status204_Success,
|
||||
Status204_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -131,7 +143,8 @@ pub enum OverrideServerGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum ParamgetGetResponse {
|
||||
/// JSON rsp
|
||||
Status200_JSONRsp(models::AnotherXmlObject),
|
||||
Status200_JSONRsp
|
||||
(models::AnotherXmlObject)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -139,7 +152,7 @@ pub enum ParamgetGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum ReadonlyAuthSchemeGetResponse {
|
||||
/// Check that limiting to a single required auth scheme works
|
||||
Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks,
|
||||
Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -147,7 +160,7 @@ pub enum ReadonlyAuthSchemeGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum RegisterCallbackPostResponse {
|
||||
/// OK
|
||||
Status204_OK,
|
||||
Status204_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -155,7 +168,7 @@ pub enum RegisterCallbackPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum RequiredOctetStreamPutResponse {
|
||||
/// OK
|
||||
Status200_OK,
|
||||
Status200_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -163,17 +176,36 @@ pub enum RequiredOctetStreamPutResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum ResponsesWithHeadersGetResponse {
|
||||
/// Success
|
||||
Status200_Success {
|
||||
Status200_Success
|
||||
{
|
||||
body: String,
|
||||
success_info: String,
|
||||
bool_header: Option<bool>,
|
||||
object_header: Option<models::ObjectHeader>,
|
||||
},
|
||||
success_info:
|
||||
String
|
||||
,
|
||||
bool_header:
|
||||
Option<
|
||||
bool
|
||||
>
|
||||
,
|
||||
object_header:
|
||||
Option<
|
||||
models::ObjectHeader
|
||||
>
|
||||
}
|
||||
,
|
||||
/// Precondition Failed
|
||||
Status412_PreconditionFailed {
|
||||
further_info: Option<String>,
|
||||
failure_info: Option<String>,
|
||||
},
|
||||
Status412_PreconditionFailed
|
||||
{
|
||||
further_info:
|
||||
Option<
|
||||
String
|
||||
>
|
||||
,
|
||||
failure_info:
|
||||
Option<
|
||||
String
|
||||
>
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -181,11 +213,16 @@ pub enum ResponsesWithHeadersGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Rfc7807GetResponse {
|
||||
/// OK
|
||||
Status204_OK(models::ObjectWithArrayOfObjects),
|
||||
Status204_OK
|
||||
(models::ObjectWithArrayOfObjects)
|
||||
,
|
||||
/// NotFound
|
||||
Status404_NotFound(models::ObjectWithArrayOfObjects),
|
||||
Status404_NotFound
|
||||
(models::ObjectWithArrayOfObjects)
|
||||
,
|
||||
/// NotAcceptable
|
||||
Status406_NotAcceptable(String),
|
||||
Status406_NotAcceptable
|
||||
(String)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -193,7 +230,7 @@ pub enum Rfc7807GetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UntypedPropertyGetResponse {
|
||||
/// Check that untyped properties works
|
||||
Status200_CheckThatUntypedPropertiesWorks,
|
||||
Status200_CheckThatUntypedPropertiesWorks
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -201,7 +238,8 @@ pub enum UntypedPropertyGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UuidGetResponse {
|
||||
/// Duplicate Response long text. One.
|
||||
Status200_DuplicateResponseLongText(uuid::Uuid),
|
||||
Status200_DuplicateResponseLongText
|
||||
(uuid::Uuid)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -209,9 +247,10 @@ pub enum UuidGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum XmlExtraPostResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
,
|
||||
/// Bad Request
|
||||
Status400_BadRequest,
|
||||
Status400_BadRequest
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -219,9 +258,11 @@ pub enum XmlExtraPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum XmlOtherPostResponse {
|
||||
/// OK
|
||||
Status201_OK(String),
|
||||
Status201_OK
|
||||
(String)
|
||||
,
|
||||
/// Bad Request
|
||||
Status400_BadRequest,
|
||||
Status400_BadRequest
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -229,9 +270,10 @@ pub enum XmlOtherPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum XmlOtherPutResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
,
|
||||
/// Bad Request
|
||||
Status400_BadRequest,
|
||||
Status400_BadRequest
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -239,9 +281,10 @@ pub enum XmlOtherPutResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum XmlPostResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
,
|
||||
/// Bad Request
|
||||
Status400_BadRequest,
|
||||
Status400_BadRequest
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -249,9 +292,10 @@ pub enum XmlPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum XmlPutResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
,
|
||||
/// Bad Request
|
||||
Status400_BadRequest,
|
||||
Status400_BadRequest
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -259,7 +303,7 @@ pub enum XmlPutResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateRepoResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -267,13 +311,16 @@ pub enum CreateRepoResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetRepoInfoResponse {
|
||||
/// OK
|
||||
Status200_OK(String),
|
||||
Status200_OK
|
||||
(String)
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// AnyOfGet - GET /any-of
|
||||
async fn any_of_get(
|
||||
&self,
|
||||
@@ -283,6 +330,7 @@ pub trait Api {
|
||||
query_params: models::AnyOfGetQueryParams,
|
||||
) -> Result<AnyOfGetResponse, String>;
|
||||
|
||||
|
||||
/// CallbackWithHeaderPost - POST /callback-with-header
|
||||
async fn callback_with_header_post(
|
||||
&self,
|
||||
@@ -292,6 +340,7 @@ pub trait Api {
|
||||
query_params: models::CallbackWithHeaderPostQueryParams,
|
||||
) -> Result<CallbackWithHeaderPostResponse, String>;
|
||||
|
||||
|
||||
/// ComplexQueryParamGet - GET /complex-query-param
|
||||
async fn complex_query_param_get(
|
||||
&self,
|
||||
@@ -301,6 +350,7 @@ pub trait Api {
|
||||
query_params: models::ComplexQueryParamGetQueryParams,
|
||||
) -> Result<ComplexQueryParamGetResponse, String>;
|
||||
|
||||
|
||||
/// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
|
||||
async fn enum_in_path_path_param_get(
|
||||
&self,
|
||||
@@ -310,6 +360,7 @@ pub trait Api {
|
||||
path_params: models::EnumInPathPathParamGetPathParams,
|
||||
) -> Result<EnumInPathPathParamGetResponse, String>;
|
||||
|
||||
|
||||
/// JsonComplexQueryParamGet - GET /json-complex-query-param
|
||||
async fn json_complex_query_param_get(
|
||||
&self,
|
||||
@@ -319,6 +370,7 @@ pub trait Api {
|
||||
query_params: models::JsonComplexQueryParamGetQueryParams,
|
||||
) -> Result<JsonComplexQueryParamGetResponse, String>;
|
||||
|
||||
|
||||
/// MandatoryRequestHeaderGet - GET /mandatory-request-header
|
||||
async fn mandatory_request_header_get(
|
||||
&self,
|
||||
@@ -328,6 +380,7 @@ pub trait Api {
|
||||
header_params: models::MandatoryRequestHeaderGetHeaderParams,
|
||||
) -> Result<MandatoryRequestHeaderGetResponse, String>;
|
||||
|
||||
|
||||
/// MergePatchJsonGet - GET /merge-patch-json
|
||||
async fn merge_patch_json_get(
|
||||
&self,
|
||||
@@ -336,6 +389,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<MergePatchJsonGetResponse, String>;
|
||||
|
||||
|
||||
/// Get some stuff..
|
||||
///
|
||||
/// MultigetGet - GET /multiget
|
||||
@@ -346,6 +400,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<MultigetGetResponse, String>;
|
||||
|
||||
|
||||
/// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||
async fn multiple_auth_scheme_get(
|
||||
&self,
|
||||
@@ -354,6 +409,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<MultipleAuthSchemeGetResponse, String>;
|
||||
|
||||
|
||||
/// OneOfGet - GET /one-of
|
||||
async fn one_of_get(
|
||||
&self,
|
||||
@@ -362,6 +418,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<OneOfGetResponse, String>;
|
||||
|
||||
|
||||
/// OverrideServerGet - GET /override-server
|
||||
async fn override_server_get(
|
||||
&self,
|
||||
@@ -370,6 +427,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<OverrideServerGetResponse, String>;
|
||||
|
||||
|
||||
/// Get some stuff with parameters..
|
||||
///
|
||||
/// ParamgetGet - GET /paramget
|
||||
@@ -381,6 +439,7 @@ pub trait Api {
|
||||
query_params: models::ParamgetGetQueryParams,
|
||||
) -> Result<ParamgetGetResponse, String>;
|
||||
|
||||
|
||||
/// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||
async fn readonly_auth_scheme_get(
|
||||
&self,
|
||||
@@ -389,6 +448,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<ReadonlyAuthSchemeGetResponse, String>;
|
||||
|
||||
|
||||
/// RegisterCallbackPost - POST /register-callback
|
||||
async fn register_callback_post(
|
||||
&self,
|
||||
@@ -398,6 +458,7 @@ pub trait Api {
|
||||
query_params: models::RegisterCallbackPostQueryParams,
|
||||
) -> Result<RegisterCallbackPostResponse, String>;
|
||||
|
||||
|
||||
/// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||
async fn required_octet_stream_put(
|
||||
&self,
|
||||
@@ -407,6 +468,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<RequiredOctetStreamPutResponse, String>;
|
||||
|
||||
|
||||
/// ResponsesWithHeadersGet - GET /responses_with_headers
|
||||
async fn responses_with_headers_get(
|
||||
&self,
|
||||
@@ -415,6 +477,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<ResponsesWithHeadersGetResponse, String>;
|
||||
|
||||
|
||||
/// Rfc7807Get - GET /rfc7807
|
||||
async fn rfc7807_get(
|
||||
&self,
|
||||
@@ -423,6 +486,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<Rfc7807GetResponse, String>;
|
||||
|
||||
|
||||
/// UntypedPropertyGet - GET /untyped_property
|
||||
async fn untyped_property_get(
|
||||
&self,
|
||||
@@ -432,6 +496,7 @@ pub trait Api {
|
||||
body: Option<models::ObjectUntypedProps>,
|
||||
) -> Result<UntypedPropertyGetResponse, String>;
|
||||
|
||||
|
||||
/// UuidGet - GET /uuid
|
||||
async fn uuid_get(
|
||||
&self,
|
||||
@@ -440,6 +505,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<UuidGetResponse, String>;
|
||||
|
||||
|
||||
/// XmlExtraPost - POST /xml_extra
|
||||
async fn xml_extra_post(
|
||||
&self,
|
||||
@@ -449,6 +515,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<XmlExtraPostResponse, String>;
|
||||
|
||||
|
||||
/// XmlOtherPost - POST /xml_other
|
||||
async fn xml_other_post(
|
||||
&self,
|
||||
@@ -458,6 +525,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<XmlOtherPostResponse, String>;
|
||||
|
||||
|
||||
/// XmlOtherPut - PUT /xml_other
|
||||
async fn xml_other_put(
|
||||
&self,
|
||||
@@ -467,6 +535,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<XmlOtherPutResponse, String>;
|
||||
|
||||
|
||||
/// Post an array.
|
||||
///
|
||||
/// XmlPost - POST /xml
|
||||
@@ -478,6 +547,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<XmlPostResponse, String>;
|
||||
|
||||
|
||||
/// XmlPut - PUT /xml
|
||||
async fn xml_put(
|
||||
&self,
|
||||
@@ -487,6 +557,7 @@ pub trait Api {
|
||||
body: Bytes,
|
||||
) -> Result<XmlPutResponse, String>;
|
||||
|
||||
|
||||
/// CreateRepo - POST /repos
|
||||
async fn create_repo(
|
||||
&self,
|
||||
@@ -496,6 +567,7 @@ pub trait Api {
|
||||
body: models::ObjectParam,
|
||||
) -> Result<CreateRepoResponse, String>;
|
||||
|
||||
|
||||
/// GetRepoInfo - GET /repos/{repoId}
|
||||
async fn get_repo_info(
|
||||
&self,
|
||||
@@ -504,6 +576,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
path_params: models::GetRepoInfoPathParams,
|
||||
) -> Result<GetRepoInfoResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,7 +19,8 @@ pub const API_VERSION: &str = "1.0.0";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestSpecialTagsResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(models::Client),
|
||||
Status200_SuccessfulOperation
|
||||
(models::Client)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -35,7 +28,7 @@ pub enum TestSpecialTagsResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Call123exampleResponse {
|
||||
/// success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -43,7 +36,8 @@ pub enum Call123exampleResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FakeOuterBooleanSerializeResponse {
|
||||
/// Output boolean
|
||||
Status200_OutputBoolean(bool),
|
||||
Status200_OutputBoolean
|
||||
(bool)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -51,7 +45,8 @@ pub enum FakeOuterBooleanSerializeResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FakeOuterCompositeSerializeResponse {
|
||||
/// Output composite
|
||||
Status200_OutputComposite(models::OuterComposite),
|
||||
Status200_OutputComposite
|
||||
(models::OuterComposite)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -59,7 +54,8 @@ pub enum FakeOuterCompositeSerializeResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FakeOuterNumberSerializeResponse {
|
||||
/// Output number
|
||||
Status200_OutputNumber(f64),
|
||||
Status200_OutputNumber
|
||||
(f64)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -67,7 +63,8 @@ pub enum FakeOuterNumberSerializeResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FakeOuterStringSerializeResponse {
|
||||
/// Output string
|
||||
Status200_OutputString(String),
|
||||
Status200_OutputString
|
||||
(String)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -75,7 +72,7 @@ pub enum FakeOuterStringSerializeResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FakeResponseWithNumericalDescriptionResponse {
|
||||
/// 1234
|
||||
Status200,
|
||||
Status200
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -83,7 +80,7 @@ pub enum FakeResponseWithNumericalDescriptionResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum HyphenParamResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -91,7 +88,7 @@ pub enum HyphenParamResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestBodyWithQueryParamsResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -99,7 +96,8 @@ pub enum TestBodyWithQueryParamsResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestClientModelResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(models::Client),
|
||||
Status200_SuccessfulOperation
|
||||
(models::Client)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -107,9 +105,10 @@ pub enum TestClientModelResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestEndpointParametersResponse {
|
||||
/// Invalid username supplied
|
||||
Status400_InvalidUsernameSupplied,
|
||||
Status400_InvalidUsernameSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -117,9 +116,10 @@ pub enum TestEndpointParametersResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestEnumParametersResponse {
|
||||
/// Invalid request
|
||||
Status400_InvalidRequest,
|
||||
Status400_InvalidRequest
|
||||
,
|
||||
/// Not found
|
||||
Status404_NotFound,
|
||||
Status404_NotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -127,7 +127,7 @@ pub enum TestEnumParametersResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestInlineAdditionalPropertiesResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation,
|
||||
Status200_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -135,7 +135,7 @@ pub enum TestInlineAdditionalPropertiesResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestJsonFormDataResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation,
|
||||
Status200_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -143,7 +143,8 @@ pub enum TestJsonFormDataResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TestClassnameResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(models::Client),
|
||||
Status200_SuccessfulOperation
|
||||
(models::Client)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -151,7 +152,7 @@ pub enum TestClassnameResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AddPetResponse {
|
||||
/// Invalid input
|
||||
Status405_InvalidInput,
|
||||
Status405_InvalidInput
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -159,7 +160,7 @@ pub enum AddPetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeletePetResponse {
|
||||
/// Invalid pet value
|
||||
Status400_InvalidPetValue,
|
||||
Status400_InvalidPetValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -167,9 +168,11 @@ pub enum DeletePetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FindPetsByStatusResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid status value
|
||||
Status400_InvalidStatusValue,
|
||||
Status400_InvalidStatusValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -177,9 +180,11 @@ pub enum FindPetsByStatusResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FindPetsByTagsResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid tag value
|
||||
Status400_InvalidTagValue,
|
||||
Status400_InvalidTagValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -187,11 +192,14 @@ pub enum FindPetsByTagsResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetPetByIdResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Pet not found
|
||||
Status404_PetNotFound,
|
||||
Status404_PetNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -199,11 +207,13 @@ pub enum GetPetByIdResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdatePetResponse {
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Pet not found
|
||||
Status404_PetNotFound,
|
||||
Status404_PetNotFound
|
||||
,
|
||||
/// Validation exception
|
||||
Status405_ValidationException,
|
||||
Status405_ValidationException
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -211,7 +221,7 @@ pub enum UpdatePetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdatePetWithFormResponse {
|
||||
/// Invalid input
|
||||
Status405_InvalidInput,
|
||||
Status405_InvalidInput
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -219,7 +229,8 @@ pub enum UpdatePetWithFormResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UploadFileResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(models::ApiResponse),
|
||||
Status200_SuccessfulOperation
|
||||
(models::ApiResponse)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -227,9 +238,10 @@ pub enum UploadFileResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeleteOrderResponse {
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Order not found
|
||||
Status404_OrderNotFound,
|
||||
Status404_OrderNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -237,7 +249,8 @@ pub enum DeleteOrderResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetInventoryResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(std::collections::HashMap<String, i32>),
|
||||
Status200_SuccessfulOperation
|
||||
(std::collections::HashMap<String, i32>)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -245,11 +258,14 @@ pub enum GetInventoryResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetOrderByIdResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Order not found
|
||||
Status404_OrderNotFound,
|
||||
Status404_OrderNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -257,9 +273,11 @@ pub enum GetOrderByIdResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum PlaceOrderResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid Order
|
||||
Status400_InvalidOrder,
|
||||
Status400_InvalidOrder
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -267,7 +285,7 @@ pub enum PlaceOrderResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUserResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -275,7 +293,7 @@ pub enum CreateUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUsersWithArrayInputResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -283,7 +301,7 @@ pub enum CreateUsersWithArrayInputResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUsersWithListInputResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -291,9 +309,10 @@ pub enum CreateUsersWithListInputResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeleteUserResponse {
|
||||
/// Invalid username supplied
|
||||
Status400_InvalidUsernameSupplied,
|
||||
Status400_InvalidUsernameSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -301,11 +320,14 @@ pub enum DeleteUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetUserByNameResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid username supplied
|
||||
Status400_InvalidUsernameSupplied,
|
||||
Status400_InvalidUsernameSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -313,13 +335,22 @@ pub enum GetUserByNameResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoginUserResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation {
|
||||
Status200_SuccessfulOperation
|
||||
{
|
||||
body: String,
|
||||
x_rate_limit: Option<i32>,
|
||||
x_expires_after: Option<chrono::DateTime<chrono::Utc>>,
|
||||
},
|
||||
x_rate_limit:
|
||||
Option<
|
||||
i32
|
||||
>
|
||||
,
|
||||
x_expires_after:
|
||||
Option<
|
||||
chrono::DateTime::<chrono::Utc>
|
||||
>
|
||||
}
|
||||
,
|
||||
/// Invalid username/password supplied
|
||||
Status400_InvalidUsername,
|
||||
Status400_InvalidUsername
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -327,7 +358,7 @@ pub enum LoginUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LogoutUserResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -335,15 +366,18 @@ pub enum LogoutUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdateUserResponse {
|
||||
/// Invalid user supplied
|
||||
Status400_InvalidUserSupplied,
|
||||
Status400_InvalidUserSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// To test special tags.
|
||||
///
|
||||
/// TestSpecialTags - PATCH /v2/another-fake/dummy
|
||||
@@ -355,6 +389,7 @@ pub trait Api {
|
||||
body: models::Client,
|
||||
) -> Result<TestSpecialTagsResponse, String>;
|
||||
|
||||
|
||||
/// Call123example - GET /v2/fake/operation-with-numeric-id
|
||||
async fn call123example(
|
||||
&self,
|
||||
@@ -363,6 +398,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<Call123exampleResponse, String>;
|
||||
|
||||
|
||||
/// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean
|
||||
async fn fake_outer_boolean_serialize(
|
||||
&self,
|
||||
@@ -372,6 +408,7 @@ pub trait Api {
|
||||
body: Option<models::OuterBoolean>,
|
||||
) -> Result<FakeOuterBooleanSerializeResponse, String>;
|
||||
|
||||
|
||||
/// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite
|
||||
async fn fake_outer_composite_serialize(
|
||||
&self,
|
||||
@@ -381,6 +418,7 @@ pub trait Api {
|
||||
body: Option<models::OuterComposite>,
|
||||
) -> Result<FakeOuterCompositeSerializeResponse, String>;
|
||||
|
||||
|
||||
/// FakeOuterNumberSerialize - POST /v2/fake/outer/number
|
||||
async fn fake_outer_number_serialize(
|
||||
&self,
|
||||
@@ -390,6 +428,7 @@ pub trait Api {
|
||||
body: Option<models::OuterNumber>,
|
||||
) -> Result<FakeOuterNumberSerializeResponse, String>;
|
||||
|
||||
|
||||
/// FakeOuterStringSerialize - POST /v2/fake/outer/string
|
||||
async fn fake_outer_string_serialize(
|
||||
&self,
|
||||
@@ -399,6 +438,7 @@ pub trait Api {
|
||||
body: Option<models::OuterString>,
|
||||
) -> Result<FakeOuterStringSerializeResponse, String>;
|
||||
|
||||
|
||||
/// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description
|
||||
async fn fake_response_with_numerical_description(
|
||||
&self,
|
||||
@@ -407,6 +447,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<FakeResponseWithNumericalDescriptionResponse, String>;
|
||||
|
||||
|
||||
/// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param}
|
||||
async fn hyphen_param(
|
||||
&self,
|
||||
@@ -416,6 +457,7 @@ pub trait Api {
|
||||
path_params: models::HyphenParamPathParams,
|
||||
) -> Result<HyphenParamResponse, String>;
|
||||
|
||||
|
||||
/// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params
|
||||
async fn test_body_with_query_params(
|
||||
&self,
|
||||
@@ -426,6 +468,7 @@ pub trait Api {
|
||||
body: models::User,
|
||||
) -> Result<TestBodyWithQueryParamsResponse, String>;
|
||||
|
||||
|
||||
/// To test \"client\" model.
|
||||
///
|
||||
/// TestClientModel - PATCH /v2/fake
|
||||
@@ -437,6 +480,7 @@ pub trait Api {
|
||||
body: models::Client,
|
||||
) -> Result<TestClientModelResponse, String>;
|
||||
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트.
|
||||
///
|
||||
/// TestEndpointParameters - POST /v2/fake
|
||||
@@ -447,6 +491,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<TestEndpointParametersResponse, String>;
|
||||
|
||||
|
||||
/// To test enum parameters.
|
||||
///
|
||||
/// TestEnumParameters - GET /v2/fake
|
||||
@@ -459,6 +504,7 @@ pub trait Api {
|
||||
query_params: models::TestEnumParametersQueryParams,
|
||||
) -> Result<TestEnumParametersResponse, String>;
|
||||
|
||||
|
||||
/// test inline additionalProperties.
|
||||
///
|
||||
/// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties
|
||||
@@ -470,6 +516,7 @@ pub trait Api {
|
||||
body: std::collections::HashMap<String, String>,
|
||||
) -> Result<TestInlineAdditionalPropertiesResponse, String>;
|
||||
|
||||
|
||||
/// test json serialization of form data.
|
||||
///
|
||||
/// TestJsonFormData - GET /v2/fake/jsonFormData
|
||||
@@ -480,6 +527,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<TestJsonFormDataResponse, String>;
|
||||
|
||||
|
||||
/// To test class name in snake case.
|
||||
///
|
||||
/// TestClassname - PATCH /v2/fake_classname_test
|
||||
@@ -491,6 +539,7 @@ pub trait Api {
|
||||
body: models::Client,
|
||||
) -> Result<TestClassnameResponse, String>;
|
||||
|
||||
|
||||
/// Add a new pet to the store.
|
||||
///
|
||||
/// AddPet - POST /v2/pet
|
||||
@@ -502,6 +551,7 @@ pub trait Api {
|
||||
body: models::Pet,
|
||||
) -> Result<AddPetResponse, String>;
|
||||
|
||||
|
||||
/// Deletes a pet.
|
||||
///
|
||||
/// DeletePet - DELETE /v2/pet/{petId}
|
||||
@@ -514,6 +564,7 @@ pub trait Api {
|
||||
path_params: models::DeletePetPathParams,
|
||||
) -> Result<DeletePetResponse, String>;
|
||||
|
||||
|
||||
/// Finds Pets by status.
|
||||
///
|
||||
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
||||
@@ -525,6 +576,7 @@ pub trait Api {
|
||||
query_params: models::FindPetsByStatusQueryParams,
|
||||
) -> Result<FindPetsByStatusResponse, String>;
|
||||
|
||||
|
||||
/// Finds Pets by tags.
|
||||
///
|
||||
/// FindPetsByTags - GET /v2/pet/findByTags
|
||||
@@ -536,6 +588,7 @@ pub trait Api {
|
||||
query_params: models::FindPetsByTagsQueryParams,
|
||||
) -> Result<FindPetsByTagsResponse, String>;
|
||||
|
||||
|
||||
/// Find pet by ID.
|
||||
///
|
||||
/// GetPetById - GET /v2/pet/{petId}
|
||||
@@ -547,6 +600,7 @@ pub trait Api {
|
||||
path_params: models::GetPetByIdPathParams,
|
||||
) -> Result<GetPetByIdResponse, String>;
|
||||
|
||||
|
||||
/// Update an existing pet.
|
||||
///
|
||||
/// UpdatePet - PUT /v2/pet
|
||||
@@ -558,6 +612,7 @@ pub trait Api {
|
||||
body: models::Pet,
|
||||
) -> Result<UpdatePetResponse, String>;
|
||||
|
||||
|
||||
/// Updates a pet in the store with form data.
|
||||
///
|
||||
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
||||
@@ -569,6 +624,7 @@ pub trait Api {
|
||||
path_params: models::UpdatePetWithFormPathParams,
|
||||
) -> Result<UpdatePetWithFormResponse, String>;
|
||||
|
||||
|
||||
/// uploads an image.
|
||||
///
|
||||
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
||||
@@ -581,6 +637,7 @@ pub trait Api {
|
||||
body: Multipart,
|
||||
) -> Result<UploadFileResponse, String>;
|
||||
|
||||
|
||||
/// Delete purchase order by ID.
|
||||
///
|
||||
/// DeleteOrder - DELETE /v2/store/order/{order_id}
|
||||
@@ -592,6 +649,7 @@ pub trait Api {
|
||||
path_params: models::DeleteOrderPathParams,
|
||||
) -> Result<DeleteOrderResponse, String>;
|
||||
|
||||
|
||||
/// Returns pet inventories by status.
|
||||
///
|
||||
/// GetInventory - GET /v2/store/inventory
|
||||
@@ -602,6 +660,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<GetInventoryResponse, String>;
|
||||
|
||||
|
||||
/// Find purchase order by ID.
|
||||
///
|
||||
/// GetOrderById - GET /v2/store/order/{order_id}
|
||||
@@ -613,6 +672,7 @@ pub trait Api {
|
||||
path_params: models::GetOrderByIdPathParams,
|
||||
) -> Result<GetOrderByIdResponse, String>;
|
||||
|
||||
|
||||
/// Place an order for a pet.
|
||||
///
|
||||
/// PlaceOrder - POST /v2/store/order
|
||||
@@ -624,6 +684,7 @@ pub trait Api {
|
||||
body: models::Order,
|
||||
) -> Result<PlaceOrderResponse, String>;
|
||||
|
||||
|
||||
/// Create user.
|
||||
///
|
||||
/// CreateUser - POST /v2/user
|
||||
@@ -635,6 +696,7 @@ pub trait Api {
|
||||
body: models::User,
|
||||
) -> Result<CreateUserResponse, String>;
|
||||
|
||||
|
||||
/// Creates list of users with given input array.
|
||||
///
|
||||
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
||||
@@ -646,6 +708,7 @@ pub trait Api {
|
||||
body: Vec<models::User>,
|
||||
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
||||
|
||||
|
||||
/// Creates list of users with given input array.
|
||||
///
|
||||
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
||||
@@ -657,6 +720,7 @@ pub trait Api {
|
||||
body: Vec<models::User>,
|
||||
) -> Result<CreateUsersWithListInputResponse, String>;
|
||||
|
||||
|
||||
/// Delete user.
|
||||
///
|
||||
/// DeleteUser - DELETE /v2/user/{username}
|
||||
@@ -668,6 +732,7 @@ pub trait Api {
|
||||
path_params: models::DeleteUserPathParams,
|
||||
) -> Result<DeleteUserResponse, String>;
|
||||
|
||||
|
||||
/// Get user by user name.
|
||||
///
|
||||
/// GetUserByName - GET /v2/user/{username}
|
||||
@@ -679,6 +744,7 @@ pub trait Api {
|
||||
path_params: models::GetUserByNamePathParams,
|
||||
) -> Result<GetUserByNameResponse, String>;
|
||||
|
||||
|
||||
/// Logs user into the system.
|
||||
///
|
||||
/// LoginUser - GET /v2/user/login
|
||||
@@ -690,6 +756,7 @@ pub trait Api {
|
||||
query_params: models::LoginUserQueryParams,
|
||||
) -> Result<LoginUserResponse, String>;
|
||||
|
||||
|
||||
/// Logs out current logged in user session.
|
||||
///
|
||||
/// LogoutUser - GET /v2/user/logout
|
||||
@@ -700,6 +767,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<LogoutUserResponse, String>;
|
||||
|
||||
|
||||
/// Updated user.
|
||||
///
|
||||
/// UpdateUser - PUT /v2/user/{username}
|
||||
@@ -711,6 +779,7 @@ pub trait Api {
|
||||
path_params: models::UpdateUserPathParams,
|
||||
body: models::User,
|
||||
) -> Result<UpdateUserResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,9 +19,11 @@ pub const API_VERSION: &str = "1.0.0";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AddPetResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid input
|
||||
Status405_InvalidInput,
|
||||
Status405_InvalidInput
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -37,7 +31,7 @@ pub enum AddPetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeletePetResponse {
|
||||
/// Invalid pet value
|
||||
Status400_InvalidPetValue,
|
||||
Status400_InvalidPetValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -45,9 +39,11 @@ pub enum DeletePetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FindPetsByStatusResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid status value
|
||||
Status400_InvalidStatusValue,
|
||||
Status400_InvalidStatusValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -55,9 +51,11 @@ pub enum FindPetsByStatusResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FindPetsByTagsResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid tag value
|
||||
Status400_InvalidTagValue,
|
||||
Status400_InvalidTagValue
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -65,11 +63,14 @@ pub enum FindPetsByTagsResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetPetByIdResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Pet not found
|
||||
Status404_PetNotFound,
|
||||
Status404_PetNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -77,13 +78,17 @@ pub enum GetPetByIdResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdatePetResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Pet not found
|
||||
Status404_PetNotFound,
|
||||
Status404_PetNotFound
|
||||
,
|
||||
/// Validation exception
|
||||
Status405_ValidationException,
|
||||
Status405_ValidationException
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -91,7 +96,7 @@ pub enum UpdatePetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdatePetWithFormResponse {
|
||||
/// Invalid input
|
||||
Status405_InvalidInput,
|
||||
Status405_InvalidInput
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -99,7 +104,8 @@ pub enum UpdatePetWithFormResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UploadFileResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(models::ApiResponse),
|
||||
Status200_SuccessfulOperation
|
||||
(models::ApiResponse)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -107,9 +113,10 @@ pub enum UploadFileResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeleteOrderResponse {
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Order not found
|
||||
Status404_OrderNotFound,
|
||||
Status404_OrderNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -117,7 +124,8 @@ pub enum DeleteOrderResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetInventoryResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(std::collections::HashMap<String, i32>),
|
||||
Status200_SuccessfulOperation
|
||||
(std::collections::HashMap<String, i32>)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -125,11 +133,14 @@ pub enum GetInventoryResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetOrderByIdResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid ID supplied
|
||||
Status400_InvalidIDSupplied,
|
||||
Status400_InvalidIDSupplied
|
||||
,
|
||||
/// Order not found
|
||||
Status404_OrderNotFound,
|
||||
Status404_OrderNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -137,9 +148,11 @@ pub enum GetOrderByIdResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum PlaceOrderResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid Order
|
||||
Status400_InvalidOrder,
|
||||
Status400_InvalidOrder
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -147,7 +160,7 @@ pub enum PlaceOrderResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUserResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -155,7 +168,7 @@ pub enum CreateUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUsersWithArrayInputResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -163,7 +176,7 @@ pub enum CreateUsersWithArrayInputResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum CreateUsersWithListInputResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -171,9 +184,10 @@ pub enum CreateUsersWithListInputResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DeleteUserResponse {
|
||||
/// Invalid username supplied
|
||||
Status400_InvalidUsernameSupplied,
|
||||
Status400_InvalidUsernameSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -181,11 +195,14 @@ pub enum DeleteUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetUserByNameResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation(String),
|
||||
Status200_SuccessfulOperation
|
||||
(String)
|
||||
,
|
||||
/// Invalid username supplied
|
||||
Status400_InvalidUsernameSupplied,
|
||||
Status400_InvalidUsernameSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -193,14 +210,27 @@ pub enum GetUserByNameResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoginUserResponse {
|
||||
/// successful operation
|
||||
Status200_SuccessfulOperation {
|
||||
Status200_SuccessfulOperation
|
||||
{
|
||||
body: String,
|
||||
set_cookie: Option<String>,
|
||||
x_rate_limit: Option<i32>,
|
||||
x_expires_after: Option<chrono::DateTime<chrono::Utc>>,
|
||||
},
|
||||
set_cookie:
|
||||
Option<
|
||||
String
|
||||
>
|
||||
,
|
||||
x_rate_limit:
|
||||
Option<
|
||||
i32
|
||||
>
|
||||
,
|
||||
x_expires_after:
|
||||
Option<
|
||||
chrono::DateTime::<chrono::Utc>
|
||||
>
|
||||
}
|
||||
,
|
||||
/// Invalid username/password supplied
|
||||
Status400_InvalidUsername,
|
||||
Status400_InvalidUsername
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -208,7 +238,7 @@ pub enum LoginUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LogoutUserResponse {
|
||||
/// successful operation
|
||||
Status0_SuccessfulOperation,
|
||||
Status0_SuccessfulOperation
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -216,15 +246,18 @@ pub enum LogoutUserResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum UpdateUserResponse {
|
||||
/// Invalid user supplied
|
||||
Status400_InvalidUserSupplied,
|
||||
Status400_InvalidUserSupplied
|
||||
,
|
||||
/// User not found
|
||||
Status404_UserNotFound,
|
||||
Status404_UserNotFound
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// Add a new pet to the store.
|
||||
///
|
||||
/// AddPet - POST /v2/pet
|
||||
@@ -236,6 +269,7 @@ pub trait Api {
|
||||
body: models::Pet,
|
||||
) -> Result<AddPetResponse, String>;
|
||||
|
||||
|
||||
/// Deletes a pet.
|
||||
///
|
||||
/// DeletePet - DELETE /v2/pet/{petId}
|
||||
@@ -248,6 +282,7 @@ pub trait Api {
|
||||
path_params: models::DeletePetPathParams,
|
||||
) -> Result<DeletePetResponse, String>;
|
||||
|
||||
|
||||
/// Finds Pets by status.
|
||||
///
|
||||
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
||||
@@ -259,6 +294,7 @@ pub trait Api {
|
||||
query_params: models::FindPetsByStatusQueryParams,
|
||||
) -> Result<FindPetsByStatusResponse, String>;
|
||||
|
||||
|
||||
/// Finds Pets by tags.
|
||||
///
|
||||
/// FindPetsByTags - GET /v2/pet/findByTags
|
||||
@@ -270,6 +306,7 @@ pub trait Api {
|
||||
query_params: models::FindPetsByTagsQueryParams,
|
||||
) -> Result<FindPetsByTagsResponse, String>;
|
||||
|
||||
|
||||
/// Find pet by ID.
|
||||
///
|
||||
/// GetPetById - GET /v2/pet/{petId}
|
||||
@@ -281,6 +318,7 @@ pub trait Api {
|
||||
path_params: models::GetPetByIdPathParams,
|
||||
) -> Result<GetPetByIdResponse, String>;
|
||||
|
||||
|
||||
/// Update an existing pet.
|
||||
///
|
||||
/// UpdatePet - PUT /v2/pet
|
||||
@@ -292,6 +330,7 @@ pub trait Api {
|
||||
body: models::Pet,
|
||||
) -> Result<UpdatePetResponse, String>;
|
||||
|
||||
|
||||
/// Updates a pet in the store with form data.
|
||||
///
|
||||
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
||||
@@ -303,6 +342,7 @@ pub trait Api {
|
||||
path_params: models::UpdatePetWithFormPathParams,
|
||||
) -> Result<UpdatePetWithFormResponse, String>;
|
||||
|
||||
|
||||
/// uploads an image.
|
||||
///
|
||||
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
||||
@@ -315,6 +355,7 @@ pub trait Api {
|
||||
body: Multipart,
|
||||
) -> Result<UploadFileResponse, String>;
|
||||
|
||||
|
||||
/// Delete purchase order by ID.
|
||||
///
|
||||
/// DeleteOrder - DELETE /v2/store/order/{orderId}
|
||||
@@ -326,6 +367,7 @@ pub trait Api {
|
||||
path_params: models::DeleteOrderPathParams,
|
||||
) -> Result<DeleteOrderResponse, String>;
|
||||
|
||||
|
||||
/// Returns pet inventories by status.
|
||||
///
|
||||
/// GetInventory - GET /v2/store/inventory
|
||||
@@ -336,6 +378,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<GetInventoryResponse, String>;
|
||||
|
||||
|
||||
/// Find purchase order by ID.
|
||||
///
|
||||
/// GetOrderById - GET /v2/store/order/{orderId}
|
||||
@@ -347,6 +390,7 @@ pub trait Api {
|
||||
path_params: models::GetOrderByIdPathParams,
|
||||
) -> Result<GetOrderByIdResponse, String>;
|
||||
|
||||
|
||||
/// Place an order for a pet.
|
||||
///
|
||||
/// PlaceOrder - POST /v2/store/order
|
||||
@@ -358,6 +402,7 @@ pub trait Api {
|
||||
body: models::Order,
|
||||
) -> Result<PlaceOrderResponse, String>;
|
||||
|
||||
|
||||
/// Create user.
|
||||
///
|
||||
/// CreateUser - POST /v2/user
|
||||
@@ -369,6 +414,7 @@ pub trait Api {
|
||||
body: models::User,
|
||||
) -> Result<CreateUserResponse, String>;
|
||||
|
||||
|
||||
/// Creates list of users with given input array.
|
||||
///
|
||||
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
||||
@@ -380,6 +426,7 @@ pub trait Api {
|
||||
body: Vec<models::User>,
|
||||
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
||||
|
||||
|
||||
/// Creates list of users with given input array.
|
||||
///
|
||||
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
||||
@@ -391,6 +438,7 @@ pub trait Api {
|
||||
body: Vec<models::User>,
|
||||
) -> Result<CreateUsersWithListInputResponse, String>;
|
||||
|
||||
|
||||
/// Delete user.
|
||||
///
|
||||
/// DeleteUser - DELETE /v2/user/{username}
|
||||
@@ -402,6 +450,7 @@ pub trait Api {
|
||||
path_params: models::DeleteUserPathParams,
|
||||
) -> Result<DeleteUserResponse, String>;
|
||||
|
||||
|
||||
/// Get user by user name.
|
||||
///
|
||||
/// GetUserByName - GET /v2/user/{username}
|
||||
@@ -413,6 +462,7 @@ pub trait Api {
|
||||
path_params: models::GetUserByNamePathParams,
|
||||
) -> Result<GetUserByNameResponse, String>;
|
||||
|
||||
|
||||
/// Logs user into the system.
|
||||
///
|
||||
/// LoginUser - GET /v2/user/login
|
||||
@@ -424,6 +474,7 @@ pub trait Api {
|
||||
query_params: models::LoginUserQueryParams,
|
||||
) -> Result<LoginUserResponse, String>;
|
||||
|
||||
|
||||
/// Logs out current logged in user session.
|
||||
///
|
||||
/// LogoutUser - GET /v2/user/logout
|
||||
@@ -434,6 +485,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<LogoutUserResponse, String>;
|
||||
|
||||
|
||||
/// Updated user.
|
||||
///
|
||||
/// UpdateUser - PUT /v2/user/{username}
|
||||
@@ -445,6 +497,7 @@ pub trait Api {
|
||||
path_params: models::UpdateUserPathParams,
|
||||
body: models::User,
|
||||
) -> Result<UpdateUserResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,13 +19,15 @@ pub const API_VERSION: &str = "1.0";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum PingGetResponse {
|
||||
/// OK
|
||||
Status201_OK,
|
||||
Status201_OK
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// PingGet - GET /ping
|
||||
async fn ping_get(
|
||||
&self,
|
||||
@@ -41,6 +35,7 @@ pub trait Api {
|
||||
host: Host,
|
||||
cookies: CookieJar,
|
||||
) -> Result<PingGetResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
@@ -6,3 +6,6 @@ use validator::Validate;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::header;
|
||||
use crate::{models, types::*};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ use crate::{header, types::*};
|
||||
#[allow(unused_imports)]
|
||||
use crate::models;
|
||||
|
||||
use crate::{Api, PingGetResponse};
|
||||
use crate::{Api,
|
||||
PingGetResponse
|
||||
};
|
||||
|
||||
/// Setup API Server.
|
||||
pub fn new<I, A>(api_impl: I) -> Router
|
||||
@@ -22,13 +24,21 @@ where
|
||||
{
|
||||
// build our application with a route
|
||||
Router::new()
|
||||
.route("/ping", get(ping_get::<I, A>))
|
||||
.route("/ping",
|
||||
get(ping_get::<I, A>)
|
||||
)
|
||||
.with_state(api_impl)
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn ping_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn ping_get_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// PingGet - GET /ping
|
||||
@@ -43,38 +53,45 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
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)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
ping_get_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
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 resp = match result {
|
||||
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| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
@@ -30,16 +30,11 @@ macro_rules! ihv_generate {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse {} as a string: {}",
|
||||
stringify!($t),
|
||||
e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
||||
stringify!($t), e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,12 +74,9 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
||||
"" => None,
|
||||
y => Some(y.to_string()),
|
||||
})
|
||||
.collect(),
|
||||
)),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
.collect())),
|
||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,10 +87,8 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +101,8 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +113,8 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,12 +128,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match hdr_value.parse() {
|
||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} from a header {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,10 +143,8 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,12 +158,11 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
||||
match hdr_value.to_str() {
|
||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
||||
hdr_value, e)),
|
||||
},
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert header {:?} to string {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,10 +173,8 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||
Ok(hdr_value) => Ok(hdr_value),
|
||||
Err(e) => Err(format!(
|
||||
"Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
||||
hdr_value, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#![allow(
|
||||
missing_docs,
|
||||
trivial_casts,
|
||||
unused_variables,
|
||||
unused_mut,
|
||||
unused_imports,
|
||||
unused_extern_crates,
|
||||
non_camel_case_types
|
||||
)]
|
||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
||||
#![allow(unused_imports, unused_attributes)]
|
||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||
|
||||
@@ -27,7 +19,8 @@ pub const API_VERSION: &str = "2.3.4";
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AllOfGetResponse {
|
||||
/// OK
|
||||
Status200_OK(models::AllOfObject),
|
||||
Status200_OK
|
||||
(models::AllOfObject)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -35,7 +28,7 @@ pub enum AllOfGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DummyGetResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -43,7 +36,7 @@ pub enum DummyGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum DummyPutResponse {
|
||||
/// Success
|
||||
Status200_Success,
|
||||
Status200_Success
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -51,7 +44,8 @@ pub enum DummyPutResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum FileResponseGetResponse {
|
||||
/// Success
|
||||
Status200_Success(ByteArray),
|
||||
Status200_Success
|
||||
(ByteArray)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -59,7 +53,8 @@ pub enum FileResponseGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum GetStructuredYamlResponse {
|
||||
/// OK
|
||||
Status200_OK(String),
|
||||
Status200_OK
|
||||
(String)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -67,7 +62,8 @@ pub enum GetStructuredYamlResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum HtmlPostResponse {
|
||||
/// Success
|
||||
Status200_Success(String),
|
||||
Status200_Success
|
||||
(String)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -75,7 +71,7 @@ pub enum HtmlPostResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum PostYamlResponse {
|
||||
/// OK
|
||||
Status204_OK,
|
||||
Status204_OK
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -83,7 +79,8 @@ pub enum PostYamlResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum RawJsonGetResponse {
|
||||
/// Success
|
||||
Status200_Success(crate::types::Object),
|
||||
Status200_Success
|
||||
(crate::types::Object)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -91,13 +88,15 @@ pub enum RawJsonGetResponse {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum SoloObjectPostResponse {
|
||||
/// OK
|
||||
Status204_OK,
|
||||
Status204_OK
|
||||
}
|
||||
|
||||
|
||||
/// API
|
||||
#[async_trait]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
pub trait Api {
|
||||
|
||||
/// AllOfGet - GET /allOf
|
||||
async fn all_of_get(
|
||||
&self,
|
||||
@@ -106,6 +105,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<AllOfGetResponse, String>;
|
||||
|
||||
|
||||
/// A dummy endpoint to make the spec valid..
|
||||
///
|
||||
/// DummyGet - GET /dummy
|
||||
@@ -116,6 +116,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<DummyGetResponse, String>;
|
||||
|
||||
|
||||
/// DummyPut - PUT /dummy
|
||||
async fn dummy_put(
|
||||
&self,
|
||||
@@ -125,6 +126,7 @@ pub trait Api {
|
||||
body: models::DummyPutRequest,
|
||||
) -> Result<DummyPutResponse, String>;
|
||||
|
||||
|
||||
/// Get a file.
|
||||
///
|
||||
/// FileResponseGet - GET /file_response
|
||||
@@ -135,6 +137,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<FileResponseGetResponse, String>;
|
||||
|
||||
|
||||
/// GetStructuredYaml - GET /get-structured-yaml
|
||||
async fn get_structured_yaml(
|
||||
&self,
|
||||
@@ -143,6 +146,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<GetStructuredYamlResponse, String>;
|
||||
|
||||
|
||||
/// Test HTML handling.
|
||||
///
|
||||
/// HtmlPost - POST /html
|
||||
@@ -154,6 +158,7 @@ pub trait Api {
|
||||
body: String,
|
||||
) -> Result<HtmlPostResponse, String>;
|
||||
|
||||
|
||||
/// PostYaml - POST /post-yaml
|
||||
async fn post_yaml(
|
||||
&self,
|
||||
@@ -163,6 +168,7 @@ pub trait Api {
|
||||
body: String,
|
||||
) -> Result<PostYamlResponse, String>;
|
||||
|
||||
|
||||
/// Get an arbitrary JSON blob..
|
||||
///
|
||||
/// RawJsonGet - GET /raw_json
|
||||
@@ -173,6 +179,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
) -> Result<RawJsonGetResponse, String>;
|
||||
|
||||
|
||||
/// Send an arbitrary JSON blob.
|
||||
///
|
||||
/// SoloObjectPost - POST /solo-object
|
||||
@@ -183,6 +190,7 @@ pub trait Api {
|
||||
cookies: CookieJar,
|
||||
body: crate::types::Object,
|
||||
) -> Result<SoloObjectPostResponse, String>;
|
||||
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
|
||||
@@ -7,6 +7,20 @@ use validator::Validate;
|
||||
use crate::header;
|
||||
use crate::{models, types::*};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct ANullableContainer {
|
||||
@@ -18,11 +32,13 @@ pub struct ANullableContainer {
|
||||
|
||||
#[serde(rename = "RequiredNullableThing")]
|
||||
pub required_nullable_thing: Nullable<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl ANullableContainer {
|
||||
#[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 {
|
||||
nullable_thing: None,
|
||||
required_nullable_thing,
|
||||
@@ -36,21 +52,18 @@ impl ANullableContainer {
|
||||
impl std::string::ToString for ANullableContainer {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
self.nullable_thing.as_ref().map(|nullable_thing| {
|
||||
[
|
||||
"NullableThing".to_string(),
|
||||
nullable_thing
|
||||
.as_ref()
|
||||
.map_or("null".to_string(), |x| x.to_string()),
|
||||
]
|
||||
.join(",")
|
||||
nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
|
||||
Some("RequiredNullableThing".to_string()),
|
||||
Some(
|
||||
self.required_nullable_thing
|
||||
.as_ref()
|
||||
.map_or("null".to_string(), |x| x.to_string()),
|
||||
),
|
||||
Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
@@ -81,11 +94,7 @@ impl std::str::FromStr for ANullableContainer {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing ANullableContainer".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing ANullableContainer".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
@@ -103,12 +112,8 @@ impl std::str::FromStr for ANullableContainer {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(ANullableContainer {
|
||||
nullable_thing: std::result::Result::Err(
|
||||
"Nullable types not supported in ANullableContainer".to_string(),
|
||||
)?,
|
||||
required_nullable_thing: std::result::Result::Err(
|
||||
"Nullable types not supported in ANullableContainer".to_string(),
|
||||
)?,
|
||||
nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?,
|
||||
required_nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -119,16 +124,13 @@ impl std::str::FromStr for ANullableContainer {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<ANullableContainer>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<ANullableContainer>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for ANullableContainer - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for ANullableContainer - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,23 +143,22 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ANullableCon
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <ANullableContainer as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into ANullableContainer - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into ANullableContainer - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// An additionalPropertiesObject
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
@@ -211,12 +212,14 @@ impl ::std::str::FromStr for AdditionalPropertiesObject {
|
||||
type Err = &'static str;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
std::result::Result::Err(
|
||||
"Parsing additionalProperties for AdditionalPropertiesObject is not supported",
|
||||
)
|
||||
std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesObject is not supported")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct AllOfObject {
|
||||
@@ -227,8 +230,10 @@ pub struct AllOfObject {
|
||||
#[serde(rename = "sampleBaseProperty")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub sample_base_property: Option<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl AllOfObject {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new() -> AllOfObject {
|
||||
@@ -245,18 +250,22 @@ impl AllOfObject {
|
||||
impl std::string::ToString for AllOfObject {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
self.sample_property.as_ref().map(|sample_property| {
|
||||
["sampleProperty".to_string(), sample_property.to_string()].join(",")
|
||||
[
|
||||
"sampleProperty".to_string(),
|
||||
sample_property.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
self.sample_base_property
|
||||
.as_ref()
|
||||
.map(|sample_base_property| {
|
||||
|
||||
|
||||
self.sample_base_property.as_ref().map(|sample_base_property| {
|
||||
[
|
||||
"sampleBaseProperty".to_string(),
|
||||
sample_base_property.to_string(),
|
||||
]
|
||||
.join(",")
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
@@ -287,29 +296,17 @@ impl std::str::FromStr for AllOfObject {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing AllOfObject".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing AllOfObject".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleProperty" => intermediate_rep.sample_property.push(
|
||||
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||
),
|
||||
"sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(
|
||||
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||
),
|
||||
_ => {
|
||||
return std::result::Result::Err(
|
||||
"Unexpected key while parsing AllOfObject".to_string(),
|
||||
)
|
||||
}
|
||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,16 +328,13 @@ impl std::str::FromStr for AllOfObject {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<AllOfObject>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<AllOfObject>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for AllOfObject - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for AllOfObject - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,31 +347,35 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<AllOfObject>
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <AllOfObject as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into AllOfObject - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into AllOfObject - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct BaseAllOf {
|
||||
#[serde(rename = "sampleBaseProperty")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub sample_base_property: Option<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl BaseAllOf {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new() -> BaseAllOf {
|
||||
@@ -392,17 +390,16 @@ impl BaseAllOf {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for BaseAllOf {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> =
|
||||
vec![self
|
||||
.sample_base_property
|
||||
.as_ref()
|
||||
.map(|sample_base_property| {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
self.sample_base_property.as_ref().map(|sample_base_property| {
|
||||
[
|
||||
"sampleBaseProperty".to_string(),
|
||||
sample_base_property.to_string(),
|
||||
]
|
||||
.join(",")
|
||||
})];
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
@@ -431,25 +428,15 @@ impl std::str::FromStr for BaseAllOf {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing BaseAllOf".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing BaseAllOf".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(
|
||||
<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(),
|
||||
)
|
||||
}
|
||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,16 +457,13 @@ impl std::str::FromStr for BaseAllOf {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<BaseAllOf>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<BaseAllOf>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for BaseAllOf - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for BaseAllOf - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,23 +476,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <BaseAllOf as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into BaseAllOf - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into BaseAllOf - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct DummyPutRequest {
|
||||
@@ -518,12 +504,17 @@ pub struct DummyPutRequest {
|
||||
#[serde(rename = "password")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub password: Option<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl DummyPutRequest {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new(id: String) -> DummyPutRequest {
|
||||
DummyPutRequest { id, password: None }
|
||||
pub fn new(id: String, ) -> DummyPutRequest {
|
||||
DummyPutRequest {
|
||||
id,
|
||||
password: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,11 +524,18 @@ impl DummyPutRequest {
|
||||
impl std::string::ToString for DummyPutRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
Some("id".to_string()),
|
||||
Some(self.id.to_string()),
|
||||
self.password
|
||||
.as_ref()
|
||||
.map(|password| ["password".to_string(), password.to_string()].join(",")),
|
||||
|
||||
|
||||
self.password.as_ref().map(|password| {
|
||||
[
|
||||
"password".to_string(),
|
||||
password.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
@@ -568,29 +566,17 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing DummyPutRequest".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing DummyPutRequest".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"id" => intermediate_rep.id.push(
|
||||
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||
),
|
||||
"id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"password" => intermediate_rep.password.push(
|
||||
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||
),
|
||||
_ => {
|
||||
return std::result::Result::Err(
|
||||
"Unexpected key while parsing DummyPutRequest".to_string(),
|
||||
)
|
||||
}
|
||||
"password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,11 +586,7 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(DummyPutRequest {
|
||||
id: intermediate_rep
|
||||
.id
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
|
||||
id: intermediate_rep.id.into_iter().next().ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
|
||||
password: intermediate_rep.password.into_iter().next(),
|
||||
})
|
||||
}
|
||||
@@ -616,16 +598,13 @@ impl std::str::FromStr for DummyPutRequest {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<DummyPutRequest>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<DummyPutRequest>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for DummyPutRequest - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for DummyPutRequest - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,25 +617,26 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<DummyPutRequ
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <DummyPutRequest as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into DummyPutRequest - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into DummyPutRequest - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// structured response
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct GetYamlResponse {
|
||||
@@ -664,12 +644,16 @@ pub struct GetYamlResponse {
|
||||
#[serde(rename = "value")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub value: Option<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl GetYamlResponse {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new() -> GetYamlResponse {
|
||||
GetYamlResponse { value: None }
|
||||
GetYamlResponse {
|
||||
value: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,10 +662,16 @@ impl GetYamlResponse {
|
||||
/// Should be implemented in a serde serializer
|
||||
impl std::string::ToString for GetYamlResponse {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![self
|
||||
.value
|
||||
.as_ref()
|
||||
.map(|value| ["value".to_string(), value.to_string()].join(","))];
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
self.value.as_ref().map(|value| {
|
||||
[
|
||||
"value".to_string(),
|
||||
value.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
}
|
||||
@@ -710,25 +700,15 @@ impl std::str::FromStr for GetYamlResponse {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing GetYamlResponse".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing GetYamlResponse".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"value" => intermediate_rep.value.push(
|
||||
<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(),
|
||||
)
|
||||
}
|
||||
"value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,16 +729,13 @@ impl std::str::FromStr for GetYamlResponse {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<GetYamlResponse>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<GetYamlResponse>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for GetYamlResponse - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for GetYamlResponse - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -771,37 +748,42 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<GetYamlRespo
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <GetYamlResponse as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into GetYamlResponse - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into GetYamlResponse - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// An object of objects
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct ObjectOfObjects {
|
||||
#[serde(rename = "inner")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub inner: Option<models::ObjectOfObjectsInner>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl ObjectOfObjects {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new() -> ObjectOfObjects {
|
||||
ObjectOfObjects { inner: None }
|
||||
ObjectOfObjects {
|
||||
inner: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -842,26 +824,15 @@ impl std::str::FromStr for ObjectOfObjects {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing ObjectOfObjects".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing ObjectOfObjects".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"inner" => intermediate_rep.inner.push(
|
||||
<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val)
|
||||
.map_err(|x| x.to_string())?,
|
||||
),
|
||||
_ => {
|
||||
return std::result::Result::Err(
|
||||
"Unexpected key while parsing ObjectOfObjects".to_string(),
|
||||
)
|
||||
}
|
||||
"inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
_ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,16 +853,13 @@ impl std::str::FromStr for ObjectOfObjects {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<ObjectOfObjects>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjects>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for ObjectOfObjects - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for ObjectOfObjects - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -904,23 +872,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <ObjectOfObjects as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into ObjectOfObjects - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into ObjectOfObjects - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||
pub struct ObjectOfObjectsInner {
|
||||
@@ -930,11 +900,13 @@ pub struct ObjectOfObjectsInner {
|
||||
#[serde(rename = "optional_thing")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub optional_thing: Option<i32>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl ObjectOfObjectsInner {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new(required_thing: String) -> ObjectOfObjectsInner {
|
||||
pub fn new(required_thing: String, ) -> ObjectOfObjectsInner {
|
||||
ObjectOfObjectsInner {
|
||||
required_thing,
|
||||
optional_thing: None,
|
||||
@@ -948,11 +920,18 @@ impl ObjectOfObjectsInner {
|
||||
impl std::string::ToString for ObjectOfObjectsInner {
|
||||
fn to_string(&self) -> String {
|
||||
let params: Vec<Option<String>> = vec![
|
||||
|
||||
Some("required_thing".to_string()),
|
||||
Some(self.required_thing.to_string()),
|
||||
|
||||
|
||||
self.optional_thing.as_ref().map(|optional_thing| {
|
||||
["optional_thing".to_string(), optional_thing.to_string()].join(",")
|
||||
[
|
||||
"optional_thing".to_string(),
|
||||
optional_thing.to_string(),
|
||||
].join(",")
|
||||
}),
|
||||
|
||||
];
|
||||
|
||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||
@@ -983,29 +962,17 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => {
|
||||
return std::result::Result::Err(
|
||||
"Missing value while parsing ObjectOfObjectsInner".to_string(),
|
||||
)
|
||||
}
|
||||
None => return std::result::Result::Err("Missing value while parsing ObjectOfObjectsInner".to_string())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
#[allow(clippy::match_single_binding)]
|
||||
match key {
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"required_thing" => intermediate_rep.required_thing.push(
|
||||
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||
),
|
||||
"required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
||||
#[allow(clippy::redundant_clone)]
|
||||
"optional_thing" => intermediate_rep.optional_thing.push(
|
||||
<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(),
|
||||
)
|
||||
}
|
||||
"optional_thing" => intermediate_rep.optional_thing.push(<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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,11 +982,7 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
std::result::Result::Ok(ObjectOfObjectsInner {
|
||||
required_thing: intermediate_rep
|
||||
.required_thing
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
|
||||
required_thing: intermediate_rep.required_thing.into_iter().next().ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
|
||||
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
|
||||
})
|
||||
}
|
||||
@@ -1031,16 +994,13 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
||||
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(
|
||||
hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>,
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>) -> std::result::Result<Self, Self::Error> {
|
||||
let hdr_value = hdr_value.to_string();
|
||||
match HeaderValue::from_str(&hdr_value) {
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1053,19 +1013,18 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
|
||||
match hdr_value.to_str() {
|
||||
std::result::Result::Ok(value) => {
|
||||
match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
|
||||
std::result::Result::Ok(value) => {
|
||||
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||
std::result::Result::Err(err) => std::result::Result::Err(
|
||||
format!("Unable to convert header value '{}' into ObjectOfObjectsInner - {}",
|
||||
value, err))
|
||||
}
|
||||
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||
"Unable to convert header value '{}' into ObjectOfObjectsInner - {}",
|
||||
value, err
|
||||
)),
|
||||
}
|
||||
}
|
||||
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||
"Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e
|
||||
)),
|
||||
},
|
||||
std::result::Result::Err(e) => std::result::Result::Err(
|
||||
format!("Unable to convert header: {:?} to string: {}",
|
||||
hdr_value, e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,10 +12,16 @@ use crate::{header, types::*};
|
||||
#[allow(unused_imports)]
|
||||
use crate::models;
|
||||
|
||||
use crate::{
|
||||
AllOfGetResponse, Api, DummyGetResponse, DummyPutResponse, FileResponseGetResponse,
|
||||
GetStructuredYamlResponse, HtmlPostResponse, PostYamlResponse, RawJsonGetResponse,
|
||||
SoloObjectPostResponse,
|
||||
use crate::{Api,
|
||||
AllOfGetResponse,
|
||||
DummyGetResponse,
|
||||
DummyPutResponse,
|
||||
FileResponseGetResponse,
|
||||
GetStructuredYamlResponse,
|
||||
HtmlPostResponse,
|
||||
PostYamlResponse,
|
||||
RawJsonGetResponse,
|
||||
SoloObjectPostResponse
|
||||
};
|
||||
|
||||
/// Setup API Server.
|
||||
@@ -26,20 +32,42 @@ where
|
||||
{
|
||||
// build our application with a route
|
||||
Router::new()
|
||||
.route("/allOf", get(all_of_get::<I, A>))
|
||||
.route("/dummy", get(dummy_get::<I, A>).put(dummy_put::<I, A>))
|
||||
.route("/file_response", get(file_response_get::<I, A>))
|
||||
.route("/get-structured-yaml", get(get_structured_yaml::<I, A>))
|
||||
.route("/html", post(html_post::<I, A>))
|
||||
.route("/post-yaml", post(post_yaml::<I, A>))
|
||||
.route("/raw_json", get(raw_json_get::<I, A>))
|
||||
.route("/solo-object", post(solo_object_post::<I, A>))
|
||||
.route("/allOf",
|
||||
get(all_of_get::<I, A>)
|
||||
)
|
||||
.route("/dummy",
|
||||
get(dummy_get::<I, A>).put(dummy_put::<I, A>)
|
||||
)
|
||||
.route("/file_response",
|
||||
get(file_response_get::<I, A>)
|
||||
)
|
||||
.route("/get-structured-yaml",
|
||||
get(get_structured_yaml::<I, A>)
|
||||
)
|
||||
.route("/html",
|
||||
post(html_post::<I, A>)
|
||||
)
|
||||
.route("/post-yaml",
|
||||
post(post_yaml::<I, A>)
|
||||
)
|
||||
.route("/raw_json",
|
||||
get(raw_json_get::<I, A>)
|
||||
)
|
||||
.route("/solo-object",
|
||||
post(solo_object_post::<I, A>)
|
||||
)
|
||||
.with_state(api_impl)
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn all_of_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn all_of_get_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// AllOfGet - GET /allOf
|
||||
@@ -54,64 +82,70 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || all_of_get_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
all_of_get_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl.as_ref().all_of_get(method, host, cookies).await;
|
||||
let result = api_impl.as_ref().all_of_get(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
AllOfGetResponse::Status200_OK(body) => {
|
||||
AllOfGetResponse::Status200_OK
|
||||
(body)
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
{
|
||||
let mut response_headers = response.headers_mut().unwrap();
|
||||
response_headers.insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("*/*").map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?,
|
||||
);
|
||||
HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
||||
}
|
||||
|
||||
let body_content = tokio::task::spawn_blocking(move || {
|
||||
let body_content = tokio::task::spawn_blocking(move ||
|
||||
serde_json::to_vec(&body).map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap()?;
|
||||
})).await.unwrap()?;
|
||||
response.body(Body::from(body_content))
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn dummy_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn dummy_get_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// DummyGet - GET /dummy
|
||||
@@ -126,40 +160,46 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || dummy_get_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
dummy_get_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl.as_ref().dummy_get(method, host, cookies).await;
|
||||
let result = api_impl.as_ref().dummy_get(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
DummyGetResponse::Status200_Success => {
|
||||
DummyGetResponse::Status200_Success
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
response.body(Body::empty())
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
#[derive(validator::Validate)]
|
||||
@@ -169,14 +209,20 @@ struct DummyPutBodyValidator<'a> {
|
||||
body: &'a models::DummyPutRequest,
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn dummy_put_validation(
|
||||
body: models::DummyPutRequest,
|
||||
) -> std::result::Result<(models::DummyPutRequest,), ValidationErrors> {
|
||||
) -> std::result::Result<(
|
||||
models::DummyPutRequest,
|
||||
), ValidationErrors>
|
||||
{
|
||||
let b = DummyPutBodyValidator { body: &body };
|
||||
b.validate()?;
|
||||
|
||||
Ok((body,))
|
||||
Ok((
|
||||
body,
|
||||
))
|
||||
}
|
||||
|
||||
/// DummyPut - PUT /dummy
|
||||
@@ -192,48 +238,60 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || dummy_put_validation(body))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok((body,)) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
dummy_put_validation(
|
||||
body,
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
body,
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.dummy_put(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().dummy_put(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
DummyPutResponse::Status200_Success => {
|
||||
DummyPutResponse::Status200_Success
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
response.body(Body::empty())
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn file_response_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn file_response_get_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// FileResponseGet - GET /file_response
|
||||
@@ -248,67 +306,70 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || file_response_get_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
file_response_get_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.file_response_get(method, host, cookies)
|
||||
.await;
|
||||
let result = api_impl.as_ref().file_response_get(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
FileResponseGetResponse::Status200_Success(body) => {
|
||||
FileResponseGetResponse::Status200_Success
|
||||
(body)
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
{
|
||||
let mut response_headers = response.headers_mut().unwrap();
|
||||
response_headers.insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("application/json").map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?,
|
||||
);
|
||||
HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
||||
}
|
||||
|
||||
let body_content = tokio::task::spawn_blocking(move || {
|
||||
let body_content = tokio::task::spawn_blocking(move ||
|
||||
serde_json::to_vec(&body).map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap()?;
|
||||
})).await.unwrap()?;
|
||||
response.body(Body::from(body_content))
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn get_structured_yaml_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn get_structured_yaml_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// GetStructuredYaml - GET /get-structured-yaml
|
||||
@@ -323,55 +384,55 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || get_structured_yaml_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
get_structured_yaml_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.get_structured_yaml(method, host, cookies)
|
||||
.await;
|
||||
let result = api_impl.as_ref().get_structured_yaml(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
GetStructuredYamlResponse::Status200_OK(body) => {
|
||||
GetStructuredYamlResponse::Status200_OK
|
||||
(body)
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
{
|
||||
let mut response_headers = response.headers_mut().unwrap();
|
||||
response_headers.insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("application/yaml").map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?,
|
||||
);
|
||||
HeaderValue::from_str("application/yaml").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
||||
}
|
||||
|
||||
let body_content = body;
|
||||
response.body(Body::from(body_content))
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
#[derive(validator::Validate)]
|
||||
@@ -380,9 +441,18 @@ struct HtmlPostBodyValidator<'a> {
|
||||
body: &'a String,
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn html_post_validation(body: String) -> std::result::Result<(String,), ValidationErrors> {
|
||||
Ok((body,))
|
||||
fn html_post_validation(
|
||||
body: String,
|
||||
) -> std::result::Result<(
|
||||
String,
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
body,
|
||||
))
|
||||
}
|
||||
|
||||
/// HtmlPost - POST /html
|
||||
@@ -398,55 +468,58 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || html_post_validation(body))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok((body,)) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
html_post_validation(
|
||||
body,
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
body,
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.html_post(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().html_post(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
HtmlPostResponse::Status200_Success(body) => {
|
||||
HtmlPostResponse::Status200_Success
|
||||
(body)
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
{
|
||||
let mut response_headers = response.headers_mut().unwrap();
|
||||
response_headers.insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("text/html").map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?,
|
||||
);
|
||||
HeaderValue::from_str("text/html").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
||||
}
|
||||
|
||||
let body_content = body;
|
||||
response.body(Body::from(body_content))
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
#[derive(validator::Validate)]
|
||||
@@ -455,9 +528,18 @@ struct PostYamlBodyValidator<'a> {
|
||||
body: &'a String,
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn post_yaml_validation(body: String) -> std::result::Result<(String,), ValidationErrors> {
|
||||
Ok((body,))
|
||||
fn post_yaml_validation(
|
||||
body: String,
|
||||
) -> std::result::Result<(
|
||||
String,
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
body,
|
||||
))
|
||||
}
|
||||
|
||||
/// PostYaml - POST /post-yaml
|
||||
@@ -473,48 +555,60 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || post_yaml_validation(body))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok((body,)) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
post_yaml_validation(
|
||||
body,
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
body,
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.post_yaml(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().post_yaml(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
PostYamlResponse::Status204_OK => {
|
||||
PostYamlResponse::Status204_OK
|
||||
=> {
|
||||
|
||||
let mut response = response.status(204);
|
||||
response.body(Body::empty())
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn raw_json_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||
Ok(())
|
||||
fn raw_json_get_validation(
|
||||
) -> std::result::Result<(
|
||||
), ValidationErrors>
|
||||
{
|
||||
|
||||
Ok((
|
||||
))
|
||||
}
|
||||
|
||||
/// RawJsonGet - GET /raw_json
|
||||
@@ -529,59 +623,59 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || raw_json_get_validation())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok(()) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
raw_json_get_validation(
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl.as_ref().raw_json_get(method, host, cookies).await;
|
||||
let result = api_impl.as_ref().raw_json_get(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
RawJsonGetResponse::Status200_Success(body) => {
|
||||
RawJsonGetResponse::Status200_Success
|
||||
(body)
|
||||
=> {
|
||||
|
||||
let mut response = response.status(200);
|
||||
{
|
||||
let mut response_headers = response.headers_mut().unwrap();
|
||||
response_headers.insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("*/*").map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?,
|
||||
);
|
||||
HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
||||
}
|
||||
|
||||
let body_content = tokio::task::spawn_blocking(move || {
|
||||
let body_content = tokio::task::spawn_blocking(move ||
|
||||
serde_json::to_vec(&body).map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap()?;
|
||||
})).await.unwrap()?;
|
||||
response.body(Body::from(body_content))
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
#[derive(validator::Validate)]
|
||||
@@ -590,14 +684,20 @@ struct SoloObjectPostBodyValidator<'a> {
|
||||
body: &'a crate::types::Object,
|
||||
}
|
||||
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
fn solo_object_post_validation(
|
||||
body: crate::types::Object,
|
||||
) -> std::result::Result<(crate::types::Object,), ValidationErrors> {
|
||||
) -> std::result::Result<(
|
||||
crate::types::Object,
|
||||
), ValidationErrors>
|
||||
{
|
||||
let b = SoloObjectPostBodyValidator { body: &body };
|
||||
b.validate()?;
|
||||
|
||||
Ok((body,))
|
||||
Ok((
|
||||
body,
|
||||
))
|
||||
}
|
||||
|
||||
/// SoloObjectPost - POST /solo-object
|
||||
@@ -613,41 +713,48 @@ where
|
||||
I: AsRef<A> + Send + Sync,
|
||||
A: Api,
|
||||
{
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move || solo_object_post_validation(body))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let Ok((body,)) = validation else {
|
||||
#[allow(clippy::redundant_closure)]
|
||||
let validation = tokio::task::spawn_blocking(move ||
|
||||
solo_object_post_validation(
|
||||
body,
|
||||
)
|
||||
).await.unwrap();
|
||||
|
||||
let Ok((
|
||||
body,
|
||||
)) = validation else {
|
||||
return Response::builder()
|
||||
.status(StatusCode::BAD_REQUEST)
|
||||
.body(Body::from(validation.unwrap_err().to_string()))
|
||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||
};
|
||||
|
||||
let result = api_impl
|
||||
.as_ref()
|
||||
.solo_object_post(method, host, cookies, body)
|
||||
.await;
|
||||
let result = api_impl.as_ref().solo_object_post(
|
||||
method,
|
||||
host,
|
||||
cookies,
|
||||
body,
|
||||
).await;
|
||||
|
||||
let mut response = Response::builder();
|
||||
|
||||
let resp = match result {
|
||||
Ok(rsp) => match rsp {
|
||||
SoloObjectPostResponse::Status204_OK => {
|
||||
SoloObjectPostResponse::Status204_OK
|
||||
=> {
|
||||
|
||||
let mut response = response.status(204);
|
||||
response.body(Body::empty())
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
response.status(500).body(Body::empty())
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
resp.map_err(|e| {
|
||||
error!(error = ?e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})
|
||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user