forked from loafle/openapi-generator-original
update rust axum samples
This commit is contained in:
parent
d193050a35
commit
577483c2e2
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 1.0.7
|
- API version: 1.0.7
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use multipart_v3::types::Nullable;
|
/// # use multipart_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use multipart_v3::types::Nullable;
|
/// # use multipart_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 1.0.7
|
- API version: 1.0.7
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,6 +43,22 @@ pub enum EnumInPathPathParamGetResponse {
|
|||||||
Status200_Success,
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
pub enum FormTestResponse {
|
||||||
|
/// OK
|
||||||
|
Status200_OK,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
pub enum GetWithBooleanParameterResponse {
|
||||||
|
/// OK
|
||||||
|
Status200_OK,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
@ -95,6 +111,14 @@ pub enum MultipleAuthSchemeGetResponse {
|
|||||||
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks,
|
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
pub enum MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetResponse {
|
||||||
|
/// Success
|
||||||
|
Status200_Success,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
@ -173,6 +197,14 @@ pub enum Rfc7807GetResponse {
|
|||||||
Status406_NotAcceptable(String),
|
Status406_NotAcceptable(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
pub enum TwoFirstLetterHeadersResponse {
|
||||||
|
/// OK
|
||||||
|
Status200_OK,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
@ -279,6 +311,26 @@ pub trait Default {
|
|||||||
path_params: models::EnumInPathPathParamGetPathParams,
|
path_params: models::EnumInPathPathParamGetPathParams,
|
||||||
) -> Result<EnumInPathPathParamGetResponse, String>;
|
) -> Result<EnumInPathPathParamGetResponse, String>;
|
||||||
|
|
||||||
|
/// Test a Form Post.
|
||||||
|
///
|
||||||
|
/// FormTest - POST /form-test
|
||||||
|
async fn form_test(
|
||||||
|
&self,
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
body: models::FormTestRequest,
|
||||||
|
) -> Result<FormTestResponse, String>;
|
||||||
|
|
||||||
|
/// GetWithBooleanParameter - GET /get-with-bool
|
||||||
|
async fn get_with_boolean_parameter(
|
||||||
|
&self,
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
query_params: models::GetWithBooleanParameterQueryParams,
|
||||||
|
) -> Result<GetWithBooleanParameterResponse, String>;
|
||||||
|
|
||||||
/// JsonComplexQueryParamGet - GET /json-complex-query-param
|
/// JsonComplexQueryParamGet - GET /json-complex-query-param
|
||||||
async fn json_complex_query_param_get(
|
async fn json_complex_query_param_get(
|
||||||
&self,
|
&self,
|
||||||
@ -323,6 +375,18 @@ pub trait Default {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<MultipleAuthSchemeGetResponse, String>;
|
) -> Result<MultipleAuthSchemeGetResponse, String>;
|
||||||
|
|
||||||
|
/// MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}
|
||||||
|
async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get(
|
||||||
|
&self,
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
path_params: models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams,
|
||||||
|
) -> Result<
|
||||||
|
MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetResponse,
|
||||||
|
String,
|
||||||
|
>;
|
||||||
|
|
||||||
/// OneOfGet - GET /one-of
|
/// OneOfGet - GET /one-of
|
||||||
async fn one_of_get(
|
async fn one_of_get(
|
||||||
&self,
|
&self,
|
||||||
@ -392,6 +456,15 @@ pub trait Default {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<Rfc7807GetResponse, String>;
|
) -> Result<Rfc7807GetResponse, String>;
|
||||||
|
|
||||||
|
/// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers
|
||||||
|
async fn two_first_letter_headers(
|
||||||
|
&self,
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
header_params: models::TwoFirstLetterHeadersHeaderParams,
|
||||||
|
) -> Result<TwoFirstLetterHeadersResponse, String>;
|
||||||
|
|
||||||
/// UntypedPropertyGet - GET /untyped_property
|
/// UntypedPropertyGet - GET /untyped_property
|
||||||
async fn untyped_property_get(
|
async fn untyped_property_get(
|
||||||
&self,
|
&self,
|
||||||
@ -436,7 +509,7 @@ pub trait Default {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlOtherPutResponse, String>;
|
) -> Result<XmlOtherPutResponse, String>;
|
||||||
|
|
||||||
/// Post an array.
|
/// Post an array. It's important we test apostrophes, so include one here..
|
||||||
///
|
///
|
||||||
/// XmlPost - POST /xml
|
/// XmlPost - POST /xml
|
||||||
async fn xml_post(
|
async fn xml_post(
|
||||||
|
@ -38,6 +38,14 @@ pub struct EnumInPathPathParamGetPathParams {
|
|||||||
pub path_param: models::StringEnum,
|
pub path_param: models::StringEnum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct GetWithBooleanParameterQueryParams {
|
||||||
|
/// Let's check apostrophes get encoded properly!
|
||||||
|
#[serde(rename = "iambool")]
|
||||||
|
pub iambool: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct JsonComplexQueryParamGetQueryParams {
|
pub struct JsonComplexQueryParamGetQueryParams {
|
||||||
@ -52,6 +60,13 @@ pub struct MandatoryRequestHeaderGetHeaderParams {
|
|||||||
pub x_header: String,
|
pub x_header: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams {
|
||||||
|
pub path_param_a: String,
|
||||||
|
pub path_param_b: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct ParamgetGetQueryParams {
|
pub struct ParamgetGetQueryParams {
|
||||||
@ -76,12 +91,82 @@ pub struct RegisterCallbackPostQueryParams {
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct TwoFirstLetterHeadersHeaderParams {
|
||||||
|
pub x_header_one: Option<bool>,
|
||||||
|
pub x_header_two: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct GetRepoInfoPathParams {
|
pub struct GetRepoInfoPathParams {
|
||||||
pub repo_id: String,
|
pub repo_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check that an object with only additional properties that references another object (e.g. an anyOf object) isn't treated as freeForm
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct AdditionalPropertiesReferencedAnyOfObject(
|
||||||
|
std::collections::HashMap<String, models::AnyOfProperty>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl validator::Validate for AdditionalPropertiesReferencedAnyOfObject {
|
||||||
|
fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> {
|
||||||
|
std::result::Result::Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<std::collections::HashMap<String, models::AnyOfProperty>>
|
||||||
|
for AdditionalPropertiesReferencedAnyOfObject
|
||||||
|
{
|
||||||
|
fn from(x: std::collections::HashMap<String, models::AnyOfProperty>) -> Self {
|
||||||
|
AdditionalPropertiesReferencedAnyOfObject(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<AdditionalPropertiesReferencedAnyOfObject>
|
||||||
|
for std::collections::HashMap<String, models::AnyOfProperty>
|
||||||
|
{
|
||||||
|
fn from(x: AdditionalPropertiesReferencedAnyOfObject) -> Self {
|
||||||
|
x.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::ops::Deref for AdditionalPropertiesReferencedAnyOfObject {
|
||||||
|
type Target = std::collections::HashMap<String, models::AnyOfProperty>;
|
||||||
|
fn deref(&self) -> &std::collections::HashMap<String, models::AnyOfProperty> {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::ops::DerefMut for AdditionalPropertiesReferencedAnyOfObject {
|
||||||
|
fn deref_mut(&mut self) -> &mut std::collections::HashMap<String, models::AnyOfProperty> {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts the AdditionalPropertiesReferencedAnyOfObject value to the Query Parameters representation (style=form, explode=false)
|
||||||
|
/// specified in https://swagger.io/docs/specification/serialization/
|
||||||
|
/// Should be implemented in a serde serializer
|
||||||
|
impl std::fmt::Display for AdditionalPropertiesReferencedAnyOfObject {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
// Skipping additionalProperties in query parameter serialization
|
||||||
|
write!(f, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts Query Parameters representation (style=form, explode=false) to a AdditionalPropertiesReferencedAnyOfObject value
|
||||||
|
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||||
|
/// Should be implemented in a serde deserializer
|
||||||
|
impl ::std::str::FromStr for AdditionalPropertiesReferencedAnyOfObject {
|
||||||
|
type Err = &'static str;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesReferencedAnyOfObject is not supported")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct AdditionalPropertiesWithList(std::collections::HashMap<String, Vec<String>>);
|
pub struct AdditionalPropertiesWithList(std::collections::HashMap<String, Vec<String>>);
|
||||||
@ -144,6 +229,154 @@ impl ::std::str::FromStr for AdditionalPropertiesWithList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct AdditionalPropertiesWithNullable {
|
||||||
|
#[serde(rename = "nullableString")]
|
||||||
|
#[serde(deserialize_with = "deserialize_optional_nullable")]
|
||||||
|
#[serde(default = "default_optional_nullable")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub nullable_string: Option<Nullable<String>>,
|
||||||
|
|
||||||
|
#[serde(rename = "nullableMap")]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub nullable_map: Option<std::collections::HashMap<String, models::NullableObject>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AdditionalPropertiesWithNullable {
|
||||||
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
|
pub fn new() -> AdditionalPropertiesWithNullable {
|
||||||
|
AdditionalPropertiesWithNullable {
|
||||||
|
nullable_string: None,
|
||||||
|
nullable_map: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts the AdditionalPropertiesWithNullable value to the Query Parameters representation (style=form, explode=false)
|
||||||
|
/// specified in https://swagger.io/docs/specification/serialization/
|
||||||
|
/// Should be implemented in a serde serializer
|
||||||
|
impl std::fmt::Display for AdditionalPropertiesWithNullable {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
let params: Vec<Option<String>> = vec![
|
||||||
|
self.nullable_string.as_ref().map(|nullable_string| {
|
||||||
|
[
|
||||||
|
"nullableString".to_string(),
|
||||||
|
nullable_string
|
||||||
|
.as_ref()
|
||||||
|
.map_or("null".to_string(), |x| x.to_string()),
|
||||||
|
]
|
||||||
|
.join(",")
|
||||||
|
}),
|
||||||
|
// Skipping nullableMap in query parameter serialization
|
||||||
|
];
|
||||||
|
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}",
|
||||||
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts Query Parameters representation (style=form, explode=false) to a AdditionalPropertiesWithNullable value
|
||||||
|
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||||
|
/// Should be implemented in a serde deserializer
|
||||||
|
impl std::str::FromStr for AdditionalPropertiesWithNullable {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
/// An intermediate representation of the struct to use for parsing.
|
||||||
|
#[derive(Default)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct IntermediateRep {
|
||||||
|
pub nullable_string: Vec<String>,
|
||||||
|
pub nullable_map: Vec<std::collections::HashMap<String, models::NullableObject>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut intermediate_rep = IntermediateRep::default();
|
||||||
|
|
||||||
|
// Parse into intermediate representation
|
||||||
|
let mut string_iter = s.split(',');
|
||||||
|
let mut key_result = string_iter.next();
|
||||||
|
|
||||||
|
while key_result.is_some() {
|
||||||
|
let val = match string_iter.next() {
|
||||||
|
Some(x) => x,
|
||||||
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing AdditionalPropertiesWithNullable".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(key) = key_result {
|
||||||
|
#[allow(clippy::match_single_binding)]
|
||||||
|
match key {
|
||||||
|
"nullableString" => return std::result::Result::Err("Parsing a nullable type in this style is not supported in AdditionalPropertiesWithNullable".to_string()),
|
||||||
|
"nullableMap" => return std::result::Result::Err("Parsing a container in this style is not supported in AdditionalPropertiesWithNullable".to_string()),
|
||||||
|
_ => return std::result::Result::Err("Unexpected key while parsing AdditionalPropertiesWithNullable".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the next key
|
||||||
|
key_result = string_iter.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the intermediate representation to return the struct
|
||||||
|
std::result::Result::Ok(AdditionalPropertiesWithNullable {
|
||||||
|
nullable_string: std::result::Result::Err(
|
||||||
|
"Nullable types not supported in AdditionalPropertiesWithNullable".to_string(),
|
||||||
|
)?,
|
||||||
|
nullable_map: intermediate_rep.nullable_map.into_iter().next(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods for converting between header::IntoHeaderValue<AdditionalPropertiesWithNullable> and HeaderValue
|
||||||
|
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
impl std::convert::TryFrom<header::IntoHeaderValue<AdditionalPropertiesWithNullable>>
|
||||||
|
for HeaderValue
|
||||||
|
{
|
||||||
|
type Error = String;
|
||||||
|
|
||||||
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<AdditionalPropertiesWithNullable>,
|
||||||
|
) -> 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 AdditionalPropertiesWithNullable - value: {} is invalid {}",
|
||||||
|
hdr_value, e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
impl std::convert::TryFrom<HeaderValue>
|
||||||
|
for header::IntoHeaderValue<AdditionalPropertiesWithNullable>
|
||||||
|
{
|
||||||
|
type Error = String;
|
||||||
|
|
||||||
|
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
|
||||||
|
match hdr_value.to_str() {
|
||||||
|
std::result::Result::Ok(value) => {
|
||||||
|
match <AdditionalPropertiesWithNullable as std::str::FromStr>::from_str(value) {
|
||||||
|
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
||||||
|
std::result::Result::Err(err) => std::result::Result::Err(
|
||||||
|
format!("Unable to convert header value '{}' into AdditionalPropertiesWithNullable - {}",
|
||||||
|
value, err))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(
|
||||||
|
format!("Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct AnotherXmlArray(Vec<String>);
|
pub struct AnotherXmlArray(Vec<String>);
|
||||||
@ -501,6 +734,37 @@ impl PartialEq for AnyOfGet202Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test a model containing an anyOf of a hash map
|
||||||
|
|
||||||
|
/// Any of:
|
||||||
|
/// - String
|
||||||
|
/// - std::collections::HashMap<String, String>
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct AnyOfHashMapObject(Box<serde_json::value::RawValue>);
|
||||||
|
|
||||||
|
impl validator::Validate for AnyOfHashMapObject {
|
||||||
|
fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> {
|
||||||
|
std::result::Result::Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Converts Query Parameters representation (style=form, explode=false) to a AnyOfHashMapObject value
|
||||||
|
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||||
|
/// Should be implemented in a serde deserializer
|
||||||
|
impl std::str::FromStr for AnyOfHashMapObject {
|
||||||
|
type Err = serde_json::Error;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
serde_json::from_str(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for AnyOfHashMapObject {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.0.get() == other.0.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Test a model containing an anyOf
|
/// Test a model containing an anyOf
|
||||||
|
|
||||||
/// Any of:
|
/// Any of:
|
||||||
@ -1323,6 +1587,54 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MyIdList> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
|
pub struct NullableObject(String);
|
||||||
|
|
||||||
|
impl validator::Validate for NullableObject {
|
||||||
|
fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> {
|
||||||
|
std::result::Result::Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<String> for NullableObject {
|
||||||
|
fn from(x: String) -> Self {
|
||||||
|
NullableObject(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for NullableObject {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for NullableObject {
|
||||||
|
type Err = std::string::ParseError;
|
||||||
|
fn from_str(x: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
std::result::Result::Ok(NullableObject(x.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::convert::From<NullableObject> for String {
|
||||||
|
fn from(x: NullableObject) -> Self {
|
||||||
|
x.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::ops::Deref for NullableObject {
|
||||||
|
type Target = String;
|
||||||
|
fn deref(&self) -> &String {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::ops::DerefMut for NullableObject {
|
||||||
|
fn deref_mut(&mut self) -> &mut String {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct NullableTest {
|
pub struct NullableTest {
|
||||||
|
@ -20,59 +20,89 @@ where
|
|||||||
{
|
{
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/any-of", get(any_of_get::<I, A>))
|
.route("/any-of",
|
||||||
.route(
|
get(any_of_get::<I, A>)
|
||||||
"/callback-with-header",
|
|
||||||
post(callback_with_header_post::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route("/complex-query-param", get(complex_query_param_get::<I, A>))
|
.route("/callback-with-header",
|
||||||
.route(
|
post(callback_with_header_post::<I, A>)
|
||||||
"/enum_in_path/:path_param",
|
|
||||||
get(enum_in_path_path_param_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route(
|
.route("/complex-query-param",
|
||||||
"/json-complex-query-param",
|
get(complex_query_param_get::<I, A>)
|
||||||
get(json_complex_query_param_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route(
|
.route("/enum_in_path/:path_param",
|
||||||
"/mandatory-request-header",
|
get(enum_in_path_path_param_get::<I, A>)
|
||||||
get(mandatory_request_header_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route("/merge-patch-json", get(merge_patch_json_get::<I, A>))
|
.route("/form-test",
|
||||||
.route("/multiget", get(multiget_get::<I, A>))
|
post(form_test::<I, A>)
|
||||||
.route(
|
|
||||||
"/multiple_auth_scheme",
|
|
||||||
get(multiple_auth_scheme_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route("/one-of", get(one_of_get::<I, A>))
|
.route("/get-with-bool",
|
||||||
.route("/override-server", get(override_server_get::<I, A>))
|
get(get_with_boolean_parameter::<I, A>)
|
||||||
.route("/paramget", get(paramget_get::<I, A>))
|
|
||||||
.route(
|
|
||||||
"/readonly_auth_scheme",
|
|
||||||
get(readonly_auth_scheme_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route("/register-callback", post(register_callback_post::<I, A>))
|
.route("/json-complex-query-param",
|
||||||
.route("/repos", post(create_repo::<I, A>))
|
get(json_complex_query_param_get::<I, A>)
|
||||||
.route(
|
|
||||||
"/repos/:repo_id",
|
|
||||||
get(get_repo_info::<I, A>).get(get_repo_info::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route(
|
.route("/mandatory-request-header",
|
||||||
"/required_octet_stream",
|
get(mandatory_request_header_get::<I, A>)
|
||||||
put(required_octet_stream_put::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route(
|
.route("/merge-patch-json",
|
||||||
"/responses_with_headers",
|
get(merge_patch_json_get::<I, A>)
|
||||||
get(responses_with_headers_get::<I, A>),
|
|
||||||
)
|
)
|
||||||
.route("/rfc7807", get(rfc7807_get::<I, A>))
|
.route("/multiget",
|
||||||
.route("/untyped_property", get(untyped_property_get::<I, A>))
|
get(multiget_get::<I, A>)
|
||||||
.route("/uuid", get(uuid_get::<I, A>))
|
)
|
||||||
.route("/xml", post(xml_post::<I, A>).put(xml_put::<I, A>))
|
.route("/multiple-path-params-with-very-long-path-to-test-formatting/:path_param_a/:path_param_b",
|
||||||
.route("/xml_extra", post(xml_extra_post::<I, A>))
|
get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::<I, A>)
|
||||||
.route(
|
)
|
||||||
"/xml_other",
|
.route("/multiple_auth_scheme",
|
||||||
post(xml_other_post::<I, A>).put(xml_other_put::<I, A>),
|
get(multiple_auth_scheme_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/one-of",
|
||||||
|
get(one_of_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/operation-two-first-letter-headers",
|
||||||
|
post(two_first_letter_headers::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/override-server",
|
||||||
|
get(override_server_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/paramget",
|
||||||
|
get(paramget_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/readonly_auth_scheme",
|
||||||
|
get(readonly_auth_scheme_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/register-callback",
|
||||||
|
post(register_callback_post::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/repos",
|
||||||
|
post(create_repo::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/repos/:repo_id",
|
||||||
|
get(get_repo_info::<I, A>).get(get_repo_info::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/required_octet_stream",
|
||||||
|
put(required_octet_stream_put::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/responses_with_headers",
|
||||||
|
get(responses_with_headers_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/rfc7807",
|
||||||
|
get(rfc7807_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/untyped_property",
|
||||||
|
get(untyped_property_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/uuid",
|
||||||
|
get(uuid_get::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/xml",
|
||||||
|
post(xml_post::<I, A>).put(xml_put::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/xml_extra",
|
||||||
|
post(xml_extra_post::<I, A>)
|
||||||
|
)
|
||||||
|
.route("/xml_other",
|
||||||
|
post(xml_other_post::<I, A>).put(xml_other_put::<I, A>)
|
||||||
)
|
)
|
||||||
.with_state(api_impl)
|
.with_state(api_impl)
|
||||||
}
|
}
|
||||||
@ -370,6 +400,128 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(validator::Validate)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct FormTestBodyValidator<'a> {
|
||||||
|
#[validate(nested)]
|
||||||
|
body: &'a models::FormTestRequest,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
fn form_test_validation(
|
||||||
|
body: models::FormTestRequest,
|
||||||
|
) -> std::result::Result<(models::FormTestRequest,), ValidationErrors> {
|
||||||
|
let b = FormTestBodyValidator { body: &body };
|
||||||
|
b.validate()?;
|
||||||
|
|
||||||
|
Ok((body,))
|
||||||
|
}
|
||||||
|
/// FormTest - POST /form-test
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
async fn form_test<I, A>(
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
State(api_impl): State<I>,
|
||||||
|
Form(body): Form<models::FormTestRequest>,
|
||||||
|
) -> Result<Response, StatusCode>
|
||||||
|
where
|
||||||
|
I: AsRef<A> + Send + Sync,
|
||||||
|
A: apis::default::Default,
|
||||||
|
{
|
||||||
|
let validation = form_test_validation(body);
|
||||||
|
|
||||||
|
let Ok((body,)) = validation else {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = api_impl
|
||||||
|
.as_ref()
|
||||||
|
.form_test(method, host, cookies, body)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let mut response = Response::builder();
|
||||||
|
|
||||||
|
let resp = match result {
|
||||||
|
Ok(rsp) => match rsp {
|
||||||
|
apis::default::FormTestResponse::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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
fn get_with_boolean_parameter_validation(
|
||||||
|
query_params: models::GetWithBooleanParameterQueryParams,
|
||||||
|
) -> std::result::Result<(models::GetWithBooleanParameterQueryParams,), ValidationErrors> {
|
||||||
|
query_params.validate()?;
|
||||||
|
|
||||||
|
Ok((query_params,))
|
||||||
|
}
|
||||||
|
/// GetWithBooleanParameter - GET /get-with-bool
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
async fn get_with_boolean_parameter<I, A>(
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
Query(query_params): Query<models::GetWithBooleanParameterQueryParams>,
|
||||||
|
State(api_impl): State<I>,
|
||||||
|
) -> Result<Response, StatusCode>
|
||||||
|
where
|
||||||
|
I: AsRef<A> + Send + Sync,
|
||||||
|
A: apis::default::Default,
|
||||||
|
{
|
||||||
|
let validation = get_with_boolean_parameter_validation(query_params);
|
||||||
|
|
||||||
|
let Ok((query_params,)) = validation else {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = api_impl
|
||||||
|
.as_ref()
|
||||||
|
.get_with_boolean_parameter(method, host, cookies, query_params)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let mut response = Response::builder();
|
||||||
|
|
||||||
|
let resp = match result {
|
||||||
|
Ok(rsp) => match rsp {
|
||||||
|
apis::default::GetWithBooleanParameterResponse::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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn json_complex_query_param_get_validation(
|
fn json_complex_query_param_get_validation(
|
||||||
query_params: models::JsonComplexQueryParamGetQueryParams,
|
query_params: models::JsonComplexQueryParamGetQueryParams,
|
||||||
@ -826,6 +978,81 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get_validation(
|
||||||
|
path_params: models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams,
|
||||||
|
) -> std::result::Result<
|
||||||
|
(models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams,),
|
||||||
|
ValidationErrors,
|
||||||
|
> {
|
||||||
|
path_params.validate()?;
|
||||||
|
|
||||||
|
Ok((path_params,))
|
||||||
|
}
|
||||||
|
/// MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGet - GET /multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
async fn multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get<
|
||||||
|
I,
|
||||||
|
A,
|
||||||
|
>(
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
Path(path_params): Path<
|
||||||
|
models::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetPathParams,
|
||||||
|
>,
|
||||||
|
State(api_impl): State<I>,
|
||||||
|
) -> Result<Response, StatusCode>
|
||||||
|
where
|
||||||
|
I: AsRef<A> + Send + Sync,
|
||||||
|
A: apis::default::Default,
|
||||||
|
{
|
||||||
|
let validation =
|
||||||
|
multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get_validation(
|
||||||
|
path_params,
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
let Ok((path_params,)) = validation else {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = api_impl
|
||||||
|
.as_ref()
|
||||||
|
.multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get(
|
||||||
|
method,
|
||||||
|
host,
|
||||||
|
cookies,
|
||||||
|
path_params,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let mut response = Response::builder();
|
||||||
|
|
||||||
|
let resp = match result {
|
||||||
|
Ok(rsp) => match rsp {
|
||||||
|
apis::default::MultiplePathParamsWithVeryLongPathToTestFormattingPathParamAPathParamBGetResponse::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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn one_of_get_validation() -> std::result::Result<(), ValidationErrors> {
|
fn one_of_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1456,6 +1683,106 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
fn two_first_letter_headers_validation(
|
||||||
|
header_params: models::TwoFirstLetterHeadersHeaderParams,
|
||||||
|
) -> std::result::Result<(models::TwoFirstLetterHeadersHeaderParams,), ValidationErrors> {
|
||||||
|
header_params.validate()?;
|
||||||
|
|
||||||
|
Ok((header_params,))
|
||||||
|
}
|
||||||
|
/// TwoFirstLetterHeaders - POST /operation-two-first-letter-headers
|
||||||
|
#[tracing::instrument(skip_all)]
|
||||||
|
async fn two_first_letter_headers<I, A>(
|
||||||
|
method: Method,
|
||||||
|
host: Host,
|
||||||
|
cookies: CookieJar,
|
||||||
|
headers: HeaderMap,
|
||||||
|
State(api_impl): State<I>,
|
||||||
|
) -> Result<Response, StatusCode>
|
||||||
|
where
|
||||||
|
I: AsRef<A> + Send + Sync,
|
||||||
|
A: apis::default::Default,
|
||||||
|
{
|
||||||
|
// Header parameters
|
||||||
|
let header_params = {
|
||||||
|
let header_x_header_one = headers.get(HeaderName::from_static("x_header_one"));
|
||||||
|
|
||||||
|
let header_x_header_one = match header_x_header_one {
|
||||||
|
Some(v) => match header::IntoHeaderValue::<bool>::try_from((*v).clone()) {
|
||||||
|
Ok(result) => Some(result.0),
|
||||||
|
Err(err) => {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(format!("Invalid header x-header-one - {}", err)))
|
||||||
|
.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let header_x_header_two = headers.get(HeaderName::from_static("x_header_two"));
|
||||||
|
|
||||||
|
let header_x_header_two = match header_x_header_two {
|
||||||
|
Some(v) => match header::IntoHeaderValue::<bool>::try_from((*v).clone()) {
|
||||||
|
Ok(result) => Some(result.0),
|
||||||
|
Err(err) => {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(format!("Invalid header x-header-two - {}", err)))
|
||||||
|
.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
models::TwoFirstLetterHeadersHeaderParams {
|
||||||
|
x_header_one: header_x_header_one,
|
||||||
|
x_header_two: header_x_header_two,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let validation = two_first_letter_headers_validation(header_params);
|
||||||
|
|
||||||
|
let Ok((header_params,)) = validation else {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = api_impl
|
||||||
|
.as_ref()
|
||||||
|
.two_first_letter_headers(method, host, cookies, header_params)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let mut response = Response::builder();
|
||||||
|
|
||||||
|
let resp = match result {
|
||||||
|
Ok(rsp) => match rsp {
|
||||||
|
apis::default::TwoFirstLetterHeadersResponse::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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(validator::Validate)]
|
#[derive(validator::Validate)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct UntypedPropertyGetBodyValidator<'a> {
|
struct UntypedPropertyGetBodyValidator<'a> {
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use openapi_v3::types::Nullable;
|
/// # use openapi_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use openapi_v3::types::Nullable;
|
/// # use openapi_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 0.0.1
|
- API version: 0.0.1
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use ops_v3::types::Nullable;
|
/// # use ops_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use ops_v3::types::Nullable;
|
/// # use ops_v3::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use petstore_with_fake_endpoints_models_for_testing::types::Nullable;
|
/// # use petstore_with_fake_endpoints_models_for_testing::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use petstore_with_fake_endpoints_models_for_testing::types::Nullable;
|
/// # use petstore_with_fake_endpoints_models_for_testing::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use petstore::types::Nullable;
|
/// # use petstore::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use petstore::types::Nullable;
|
/// # use petstore::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 1.0
|
- API version: 1.0
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use ping_bearer_auth::types::Nullable;
|
/// # use ping_bearer_auth::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use ping_bearer_auth::types::Nullable;
|
/// # use ping_bearer_auth::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 0.1.9
|
- API version: 0.1.9
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_axum_header_uui::types::Nullable;
|
/// # use rust_axum_header_uui::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_axum_header_uui::types::Nullable;
|
/// # use rust_axum_header_uui::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 2.3.4
|
- API version: 2.3.4
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_server_test::types::Nullable;
|
/// # use rust_server_test::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_server_test::types::Nullable;
|
/// # use rust_server_test::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
@ -1 +1 @@
|
|||||||
7.7.0-SNAPSHOT
|
7.9.0-SNAPSHOT
|
||||||
|
@ -12,7 +12,7 @@ server, you can easily generate a server stub.
|
|||||||
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
To see how to make this your own, look here: [README]((https://openapi-generator.tech))
|
||||||
|
|
||||||
- API version: 0.0.1
|
- API version: 0.0.1
|
||||||
- Generator version: 7.7.0-SNAPSHOT
|
- Generator version: 7.9.0-SNAPSHOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.expect("the world is ending"), "value");
|
/// assert_eq!(x.expect("the world is ending"), "value");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_axum_validation_test::types::Nullable;
|
/// # use rust_axum_validation_test::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
@ -210,7 +210,7 @@ impl<T> Nullable<T> {
|
|||||||
/// assert_eq!(x.unwrap(), "air");
|
/// assert_eq!(x.unwrap(), "air");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```{.should_panic}
|
/// ```should_panic
|
||||||
/// # use rust_axum_validation_test::types::Nullable;
|
/// # use rust_axum_validation_test::types::Nullable;
|
||||||
///
|
///
|
||||||
/// let x: Nullable<&str> = Nullable::Null;
|
/// let x: Nullable<&str> = Nullable::Null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user