Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ let result = api_impl.as_ref().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendo
let mut response_headers = response.headers_mut().unwrap();
response_headers.insert(
CONTENT_TYPE,
HeaderValue::from_str("{{{x-mime-type}}}").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
HeaderValue::from_static("{{{x-mime-type}}}"));
}

{{/vendorExtensions}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@
*request.body_mut() = Body::from(body.into_bytes());

let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Err(ApiError(format!("Unable to create header: {header} - {e}")))
});
request.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static(header));
{{/-last}}
{{/formParams}}
{{/x-consumes-form}}
Expand Down Expand Up @@ -101,10 +98,7 @@
{{/required}}

let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Err(ApiError(format!("Unable to create header: {header} - {e}")))
});
request.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static(header));
{{/bodyParam}}
{{/x-consumes-basic}}
{{/vendorExtensions}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{{^x-produces-multipart-related}}
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("{{{x-mime-type}}}")
.expect("Unable to create Content-Type header for {{{x-mime-type}}}"));
HeaderValue::from_static("{{{x-mime-type}}}"));
{{/x-produces-multipart-related}}
{{#x-produces-xml}}
// XML Body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@
*request.body_mut() = body_from_string(body);

let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Err(ApiError(format!("Unable to create header: {header} - {e}")))
});
request.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static(header));
{{/-last}}
{{/formParams}}
{{/x-consumes-form}}
Expand Down Expand Up @@ -103,10 +100,7 @@
{{/required}}

let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Err(ApiError(format!("Unable to create header: {header} - {e}")))
});
request.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static(header));
{{/bodyParam}}
{{/x-consumes-basic}}
{{/vendorExtensions}}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{{^x-produces-multipart-related}}
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str("{{{x-mime-type}}}")
.expect("Unable to create Content-Type header for {{{x-mime-type}}}"));
HeaderValue::from_static("{{{x-mime-type}}}"));
{{/x-produces-multipart-related}}
{{#x-produces-xml}}
// XML Body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount {
None => {
return std::result::Result::Err(
"Missing value while parsing Amount".to_string(),
);
)
}
};

Expand All @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Amount".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError {
None => {
return std::result::Result::Err(
"Missing value while parsing CheckoutError".to_string(),
);
)
}
};

Expand All @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing CheckoutError".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment {
None => {
return std::result::Result::Err(
"Missing value while parsing Payment".to_string(),
);
)
}
};

Expand Down Expand Up @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Payment".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentMethod".to_string(),
);
)
}
};

Expand All @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentMethod".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentResult".to_string(),
);
)
}
};

Expand All @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentResult".to_string(),
);
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use axum::{body::Body, extract::*, response::Response, routing::*};
use axum_extra::extract::{CookieJar, Host, Query as QueryExtra};
use bytes::Bytes;
use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header::CONTENT_TYPE};
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
use tracing::error;
use validator::{Validate, ValidationErrors};

Expand Down Expand Up @@ -127,13 +127,8 @@ where
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
})?,
);
response_headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
}

let body_content = tokio::task::spawn_blocking(move || {
Expand All @@ -150,13 +145,8 @@ where
let mut response = response.status(422);
{
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
})?,
);
response_headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
}

let body_content = tokio::task::spawn_blocking(move || {
Expand Down Expand Up @@ -290,13 +280,8 @@ where
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
})?,
);
response_headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
}

let body_content = tokio::task::spawn_blocking(move || {
Expand Down Expand Up @@ -450,13 +435,8 @@ where
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
})?,
);
response_headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
}

let body_content = tokio::task::spawn_blocking(move || {
Expand All @@ -473,13 +453,8 @@ where
let mut response = response.status(422);
{
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
})?,
);
response_headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
}

let body_content = tokio::task::spawn_blocking(move || {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{mem, str::FromStr};

use base64::{Engine, engine::general_purpose};
use base64::{engine::general_purpose, Engine};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down
20 changes: 10 additions & 10 deletions samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount {
None => {
return std::result::Result::Err(
"Missing value while parsing Amount".to_string(),
);
)
}
};

Expand All @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Amount".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError {
None => {
return std::result::Result::Err(
"Missing value while parsing CheckoutError".to_string(),
);
)
}
};

Expand All @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing CheckoutError".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment {
None => {
return std::result::Result::Err(
"Missing value while parsing Payment".to_string(),
);
)
}
};

Expand Down Expand Up @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Payment".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentMethod".to_string(),
);
)
}
};

Expand All @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentMethod".to_string(),
);
)
}
}
}
Expand Down Expand Up @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentResult".to_string(),
);
)
}
};

Expand All @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentResult".to_string(),
);
)
}
}
}
Expand Down
Loading
Loading