diff --git a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache index 610786a37b0c..c6d463f21791 100644 --- a/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache @@ -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}} diff --git a/modules/openapi-generator/src/main/resources/rust-server-deprecated/client-request-body-instance.mustache b/modules/openapi-generator/src/main/resources/rust-server-deprecated/client-request-body-instance.mustache index 7fb50831700b..d74ba35ec75e 100644 --- a/modules/openapi-generator/src/main/resources/rust-server-deprecated/client-request-body-instance.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server-deprecated/client-request-body-instance.mustache @@ -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}} @@ -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}} diff --git a/modules/openapi-generator/src/main/resources/rust-server-deprecated/server-response-body-instance.mustache b/modules/openapi-generator/src/main/resources/rust-server-deprecated/server-response-body-instance.mustache index 710e65b8b5bb..d5ec83af6999 100644 --- a/modules/openapi-generator/src/main/resources/rust-server-deprecated/server-response-body-instance.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server-deprecated/server-response-body-instance.mustache @@ -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 diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-request-body-instance.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-request-body-instance.mustache index d74d73e0abe4..baa228fb0ca6 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-request-body-instance.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-request-body-instance.mustache @@ -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}} @@ -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}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-response-body-instance.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-response-body-instance.mustache index 27e9f30b1234..164d28311570 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-response-body-instance.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-response-body-instance.mustache @@ -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 diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs index b20237912cd0..356f5bccce00 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/models.rs @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount { None => { return std::result::Result::Err( "Missing value while parsing Amount".to_string(), - ); + ) } }; @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount { _ => { return std::result::Result::Err( "Unexpected key while parsing Amount".to_string(), - ); + ) } } } @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError { None => { return std::result::Result::Err( "Missing value while parsing CheckoutError".to_string(), - ); + ) } }; @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError { _ => { return std::result::Result::Err( "Unexpected key while parsing CheckoutError".to_string(), - ); + ) } } } @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment { None => { return std::result::Result::Err( "Missing value while parsing Payment".to_string(), - ); + ) } }; @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment { _ => { return std::result::Result::Err( "Unexpected key while parsing Payment".to_string(), - ); + ) } } } @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod { None => { return std::result::Result::Err( "Missing value while parsing PaymentMethod".to_string(), - ); + ) } }; @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod { _ => { return std::result::Result::Err( "Unexpected key while parsing PaymentMethod".to_string(), - ); + ) } } } @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult { None => { return std::result::Result::Err( "Missing value while parsing PaymentResult".to_string(), - ); + ) } }; @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult { _ => { return std::result::Result::Err( "Unexpected key while parsing PaymentResult".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/server/mod.rs index 9e6e975a0967..2ddf51af68c1 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/server/mod.rs @@ -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}; @@ -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 || { @@ -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 || { @@ -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 || { @@ -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 || { @@ -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 || { diff --git a/samples/server/petstore/rust-axum/output/apikey-authorization/src/types.rs b/samples/server/petstore/rust-axum/output/apikey-authorization/src/types.rs index d99febd86d5e..a20401ceb704 100644 --- a/samples/server/petstore/rust-axum/output/apikey-authorization/src/types.rs +++ b/samples/server/petstore/rust-axum/output/apikey-authorization/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs index b20237912cd0..356f5bccce00 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount { None => { return std::result::Result::Err( "Missing value while parsing Amount".to_string(), - ); + ) } }; @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount { _ => { return std::result::Result::Err( "Unexpected key while parsing Amount".to_string(), - ); + ) } } } @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError { None => { return std::result::Result::Err( "Missing value while parsing CheckoutError".to_string(), - ); + ) } }; @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError { _ => { return std::result::Result::Err( "Unexpected key while parsing CheckoutError".to_string(), - ); + ) } } } @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment { None => { return std::result::Result::Err( "Missing value while parsing Payment".to_string(), - ); + ) } }; @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment { _ => { return std::result::Result::Err( "Unexpected key while parsing Payment".to_string(), - ); + ) } } } @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod { None => { return std::result::Result::Err( "Missing value while parsing PaymentMethod".to_string(), - ); + ) } }; @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod { _ => { return std::result::Result::Err( "Unexpected key while parsing PaymentMethod".to_string(), - ); + ) } } } @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult { None => { return std::result::Result::Err( "Missing value while parsing PaymentResult".to_string(), - ); + ) } }; @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult { _ => { return std::result::Result::Err( "Unexpected key while parsing PaymentResult".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs index f7808f3567b9..7b22799d030a 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/server/mod.rs @@ -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}; @@ -100,13 +100,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 || { @@ -123,13 +118,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 || { @@ -212,13 +202,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 || { @@ -324,13 +309,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 || { @@ -347,13 +327,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 || { diff --git a/samples/server/petstore/rust-axum/output/apikey-auths/src/types.rs b/samples/server/petstore/rust-axum/output/apikey-auths/src/types.rs index fd55b5e9a0f7..2b5504414374 100644 --- a/samples/server/petstore/rust-axum/output/apikey-auths/src/types.rs +++ b/samples/server/petstore/rust-axum/output/apikey-auths/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs index 7b10d2066db3..be65a54e3828 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/models.rs @@ -140,7 +140,7 @@ impl std::str::FromStr for MultipartRelatedRequest { None => { return std::result::Result::Err( "Missing value while parsing MultipartRelatedRequest".to_string(), - ); + ) } }; @@ -309,7 +309,7 @@ impl std::str::FromStr for MultipartRequest { None => { return std::result::Result::Err( "Missing value while parsing MultipartRequest".to_string(), - ); + ) } }; @@ -336,7 +336,7 @@ impl std::str::FromStr for MultipartRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing MultipartRequest".to_string(), - ); + ) } } } @@ -484,7 +484,7 @@ impl std::str::FromStr for MultipartRequestObjectField { None => { return std::result::Result::Err( "Missing value while parsing MultipartRequestObjectField".to_string(), - ); + ) } }; @@ -628,7 +628,7 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest { return std::result::Result::Err( "Missing value while parsing MultipleIdenticalMimeTypesPostRequest" .to_string(), - ); + ) } }; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs index c052383f748e..cf0b6039f2a5 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/server/mod.rs @@ -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}; diff --git a/samples/server/petstore/rust-axum/output/multipart-v3/src/types.rs b/samples/server/petstore/rust-axum/output/multipart-v3/src/types.rs index 63ebd9d68333..286e650eeb0c 100644 --- a/samples/server/petstore/rust-axum/output/multipart-v3/src/types.rs +++ b/samples/server/petstore/rust-axum/output/multipart-v3/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs index 4d2fb31b5ab6..2f8bced20eb9 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs @@ -226,9 +226,7 @@ impl ::std::str::FromStr for AdditionalPropertiesReferencedAnyOfObject { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err( - "Parsing additionalProperties for AdditionalPropertiesReferencedAnyOfObject is not supported", - ) + std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesReferencedAnyOfObject is not supported") } } @@ -372,7 +370,7 @@ impl std::str::FromStr for AdditionalPropertiesWithNullable { None => { return std::result::Result::Err( "Missing value while parsing AdditionalPropertiesWithNullable".to_string(), - ); + ) } }; @@ -656,10 +654,10 @@ impl AnotherXmlObject { /// Should be implemented in a serde serializer impl std::fmt::Display for AnotherXmlObject { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = - vec![self.inner_string.as_ref().map(|inner_string| { - ["inner_string".to_string(), inner_string.to_string()].join(",") - })]; + let params: Vec> = vec![self + .inner_string + .as_ref() + .map(|inner_string| ["inner_string".to_string(), inner_string.to_string()].join(","))]; write!( f, @@ -695,7 +693,7 @@ impl std::str::FromStr for AnotherXmlObject { None => { return std::result::Result::Err( "Missing value while parsing AnotherXmlObject".to_string(), - ); + ) } }; @@ -709,7 +707,7 @@ impl std::str::FromStr for AnotherXmlObject { _ => { return std::result::Result::Err( "Unexpected key while parsing AnotherXmlObject".to_string(), - ); + ) } } } @@ -926,7 +924,7 @@ impl std::str::FromStr for AnyOfProperty { None => { return std::result::Result::Err( "Missing value while parsing AnyOfProperty".to_string(), - ); + ) } }; @@ -946,7 +944,7 @@ impl std::str::FromStr for AnyOfProperty { _ => { return std::result::Result::Err( "Unexpected key while parsing AnyOfProperty".to_string(), - ); + ) } } } @@ -1080,7 +1078,7 @@ impl std::str::FromStr for DuplicateXmlObject { None => { return std::result::Result::Err( "Missing value while parsing DuplicateXmlObject".to_string(), - ); + ) } }; @@ -1099,7 +1097,7 @@ impl std::str::FromStr for DuplicateXmlObject { _ => { return std::result::Result::Err( "Unexpected key while parsing DuplicateXmlObject".to_string(), - ); + ) } } } @@ -1376,7 +1374,7 @@ impl std::str::FromStr for FormTestRequest { None => { return std::result::Result::Err( "Missing value while parsing FormTestRequest".to_string(), - ); + ) } }; @@ -1387,12 +1385,12 @@ impl std::str::FromStr for FormTestRequest { return std::result::Result::Err( "Parsing a container in this style is not supported in FormTestRequest" .to_string(), - ); + ) } _ => { return std::result::Result::Err( "Unexpected key while parsing FormTestRequest".to_string(), - ); + ) } } } @@ -1500,11 +1498,10 @@ impl MultigetGet201Response { /// Should be implemented in a serde serializer impl std::fmt::Display for MultigetGet201Response { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.foo - .as_ref() - .map(|foo| ["foo".to_string(), foo.to_string()].join(",")), - ]; + let params: Vec> = vec![self + .foo + .as_ref() + .map(|foo| ["foo".to_string(), foo.to_string()].join(","))]; write!( f, @@ -1540,7 +1537,7 @@ impl std::str::FromStr for MultigetGet201Response { None => { return std::result::Result::Err( "Missing value while parsing MultigetGet201Response".to_string(), - ); + ) } }; @@ -1554,7 +1551,7 @@ impl std::str::FromStr for MultigetGet201Response { _ => { return std::result::Result::Err( "Unexpected key while parsing MultigetGet201Response".to_string(), - ); + ) } } } @@ -2031,7 +2028,7 @@ impl std::str::FromStr for NullableTest { None => { return std::result::Result::Err( "Missing value while parsing NullableTest".to_string(), - ); + ) } }; @@ -2058,30 +2055,30 @@ impl std::str::FromStr for NullableTest { return std::result::Result::Err( "Parsing a container in this style is not supported in NullableTest" .to_string(), - ); + ) } "min_item_test" => { return std::result::Result::Err( "Parsing a container in this style is not supported in NullableTest" .to_string(), - ); + ) } "max_item_test" => { return std::result::Result::Err( "Parsing a container in this style is not supported in NullableTest" .to_string(), - ); + ) } "min_max_item_test" => { return std::result::Result::Err( "Parsing a container in this style is not supported in NullableTest" .to_string(), - ); + ) } _ => { return std::result::Result::Err( "Unexpected key while parsing NullableTest".to_string(), - ); + ) } } } @@ -2231,7 +2228,7 @@ impl std::str::FromStr for ObjectHeader { None => { return std::result::Result::Err( "Missing value while parsing ObjectHeader".to_string(), - ); + ) } }; @@ -2249,7 +2246,7 @@ impl std::str::FromStr for ObjectHeader { _ => { return std::result::Result::Err( "Unexpected key while parsing ObjectHeader".to_string(), - ); + ) } } } @@ -2381,7 +2378,7 @@ impl std::str::FromStr for ObjectParam { None => { return std::result::Result::Err( "Missing value while parsing ObjectParam".to_string(), - ); + ) } }; @@ -2399,7 +2396,7 @@ impl std::str::FromStr for ObjectParam { _ => { return std::result::Result::Err( "Unexpected key while parsing ObjectParam".to_string(), - ); + ) } } } @@ -2548,7 +2545,7 @@ impl std::str::FromStr for ObjectUntypedProps { None => { return std::result::Result::Err( "Missing value while parsing ObjectUntypedProps".to_string(), - ); + ) } }; @@ -2698,7 +2695,7 @@ impl std::str::FromStr for ObjectWithArrayOfObjects { None => { return std::result::Result::Err( "Missing value while parsing ObjectWithArrayOfObjects".to_string(), - ); + ) } }; @@ -3361,7 +3358,7 @@ impl std::str::FromStr for XmlObject { None => { return std::result::Result::Err( "Missing value while parsing XmlObject".to_string(), - ); + ) } }; @@ -3379,7 +3376,7 @@ impl std::str::FromStr for XmlObject { _ => { return std::result::Result::Err( "Unexpected key while parsing XmlObject".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs index 728444c54142..b153a34993d0 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/server/mod.rs @@ -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}; @@ -160,13 +160,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 || { @@ -183,13 +178,8 @@ where let mut response = response.status(201); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -206,13 +196,8 @@ where let mut response = response.status(202); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -469,13 +454,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 || { @@ -831,10 +811,7 @@ where let mut response_headers = response.headers_mut().unwrap(); response_headers.insert( CONTENT_TYPE, - HeaderValue::from_str("application/merge-patch+json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, + HeaderValue::from_static("application/merge-patch+json"), ); } @@ -904,13 +881,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 || { @@ -927,13 +899,7 @@ where let mut response = response.status(201); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -945,10 +911,7 @@ where let mut response_headers = response.headers_mut().unwrap(); response_headers.insert( CONTENT_TYPE, - HeaderValue::from_str("application/octet-stream").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, + HeaderValue::from_static("application/octet-stream"), ); } @@ -959,13 +922,7 @@ where let mut response = response.status(203); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -975,13 +932,8 @@ where let mut response = response.status(204); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -998,13 +950,8 @@ where let mut response = response.status(205); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -1021,13 +968,8 @@ where let mut response = response.status(206); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -1224,13 +1166,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 || { @@ -1360,13 +1297,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 || { @@ -1665,13 +1597,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 || { @@ -1779,13 +1706,8 @@ where let mut response = response.status(204); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { @@ -1804,10 +1726,7 @@ where let mut response_headers = response.headers_mut().unwrap(); response_headers.insert( CONTENT_TYPE, - HeaderValue::from_str("application/problem+json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, + HeaderValue::from_static("application/problem+json"), ); } @@ -1825,13 +1744,7 @@ where let mut response = response.status(406); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2063,13 +1976,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 || { @@ -2212,13 +2120,7 @@ where let mut response = response.status(201); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2490,13 +2392,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 || { diff --git a/samples/server/petstore/rust-axum/output/openapi-v3/src/types.rs b/samples/server/petstore/rust-axum/output/openapi-v3/src/types.rs index c2331f6d31da..31a0e8c40420 100644 --- a/samples/server/petstore/rust-axum/output/openapi-v3/src/types.rs +++ b/samples/server/petstore/rust-axum/output/openapi-v3/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs index fb006693d67f..1d34bd604b52 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/server/mod.rs @@ -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}; diff --git a/samples/server/petstore/rust-axum/output/ops-v3/src/types.rs b/samples/server/petstore/rust-axum/output/ops-v3/src/types.rs index fcab6ba59ec4..9de8a80ffc7d 100644 --- a/samples/server/petstore/rust-axum/output/ops-v3/src/types.rs +++ b/samples/server/petstore/rust-axum/output/ops-v3/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index 69f5dda3e2ee..2f4422bcaede 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -279,7 +279,7 @@ impl std::str::FromStr for AdditionalPropertiesClass { None => { return std::result::Result::Err( "Missing value while parsing AdditionalPropertiesClass".to_string(), - ); + ) } }; @@ -417,7 +417,7 @@ impl std::str::FromStr for Animal { None => { return std::result::Result::Err( "Missing value while parsing Animal".to_string(), - ); + ) } }; @@ -435,7 +435,7 @@ impl std::str::FromStr for Animal { _ => { return std::result::Result::Err( "Unexpected key while parsing Animal".to_string(), - ); + ) } } } @@ -721,7 +721,7 @@ impl std::str::FromStr for ApiResponse { None => { return std::result::Result::Err( "Missing value while parsing ApiResponse".to_string(), - ); + ) } }; @@ -743,7 +743,7 @@ impl std::str::FromStr for ApiResponse { _ => { return std::result::Result::Err( "Unexpected key while parsing ApiResponse".to_string(), - ); + ) } } } @@ -864,7 +864,7 @@ impl std::str::FromStr for ArrayOfArrayOfNumberOnly { None => { return std::result::Result::Err( "Missing value while parsing ArrayOfArrayOfNumberOnly".to_string(), - ); + ) } }; @@ -995,7 +995,7 @@ impl std::str::FromStr for ArrayOfNumberOnly { None => { return std::result::Result::Err( "Missing value while parsing ArrayOfNumberOnly".to_string(), - ); + ) } }; @@ -1009,7 +1009,7 @@ impl std::str::FromStr for ArrayOfNumberOnly { _ => { return std::result::Result::Err( "Unexpected key while parsing ArrayOfNumberOnly".to_string(), - ); + ) } } } @@ -1172,7 +1172,7 @@ impl std::str::FromStr for ArrayTest { None => { return std::result::Result::Err( "Missing value while parsing ArrayTest".to_string(), - ); + ) } }; @@ -1183,30 +1183,30 @@ impl std::str::FromStr for ArrayTest { return std::result::Result::Err( "Parsing a container in this style is not supported in ArrayTest" .to_string(), - ); + ) } "array_array_of_integer" => { return std::result::Result::Err( "Parsing a container in this style is not supported in ArrayTest" .to_string(), - ); + ) } "array_array_of_model" => { return std::result::Result::Err( "Parsing a container in this style is not supported in ArrayTest" .to_string(), - ); + ) } "array_of_enum" => { return std::result::Result::Err( "Parsing a container in this style is not supported in ArrayTest" .to_string(), - ); + ) } _ => { return std::result::Result::Err( "Unexpected key while parsing ArrayTest".to_string(), - ); + ) } } } @@ -1387,7 +1387,7 @@ impl std::str::FromStr for Capitalization { None => { return std::result::Result::Err( "Missing value while parsing Capitalization".to_string(), - ); + ) } }; @@ -1421,7 +1421,7 @@ impl std::str::FromStr for Capitalization { _ => { return std::result::Result::Err( "Unexpected key while parsing Capitalization".to_string(), - ); + ) } } } @@ -1562,7 +1562,7 @@ impl std::str::FromStr for Cat { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Cat".to_string()); + return std::result::Result::Err("Missing value while parsing Cat".to_string()) } }; @@ -1584,7 +1584,7 @@ impl std::str::FromStr for Cat { _ => { return std::result::Result::Err( "Unexpected key while parsing Cat".to_string(), - ); + ) } } } @@ -1716,7 +1716,7 @@ impl std::str::FromStr for Category { None => { return std::result::Result::Err( "Missing value while parsing Category".to_string(), - ); + ) } }; @@ -1734,7 +1734,7 @@ impl std::str::FromStr for Category { _ => { return std::result::Result::Err( "Unexpected key while parsing Category".to_string(), - ); + ) } } } @@ -1815,11 +1815,10 @@ impl ClassModel { /// Should be implemented in a serde serializer impl std::fmt::Display for ClassModel { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self._class - .as_ref() - .map(|_class| ["_class".to_string(), _class.to_string()].join(",")), - ]; + let params: Vec> = vec![self + ._class + .as_ref() + .map(|_class| ["_class".to_string(), _class.to_string()].join(","))]; write!( f, @@ -1855,7 +1854,7 @@ impl std::str::FromStr for ClassModel { None => { return std::result::Result::Err( "Missing value while parsing ClassModel".to_string(), - ); + ) } }; @@ -1869,7 +1868,7 @@ impl std::str::FromStr for ClassModel { _ => { return std::result::Result::Err( "Unexpected key while parsing ClassModel".to_string(), - ); + ) } } } @@ -1948,11 +1947,10 @@ impl Client { /// Should be implemented in a serde serializer impl std::fmt::Display for Client { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.client - .as_ref() - .map(|client| ["client".to_string(), client.to_string()].join(",")), - ]; + let params: Vec> = vec![self + .client + .as_ref() + .map(|client| ["client".to_string(), client.to_string()].join(","))]; write!( f, @@ -1988,7 +1986,7 @@ impl std::str::FromStr for Client { None => { return std::result::Result::Err( "Missing value while parsing Client".to_string(), - ); + ) } }; @@ -2002,7 +2000,7 @@ impl std::str::FromStr for Client { _ => { return std::result::Result::Err( "Unexpected key while parsing Client".to_string(), - ); + ) } } } @@ -2139,7 +2137,7 @@ impl std::str::FromStr for Dog { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Dog".to_string()); + return std::result::Result::Err("Missing value while parsing Dog".to_string()) } }; @@ -2161,7 +2159,7 @@ impl std::str::FromStr for Dog { _ => { return std::result::Result::Err( "Unexpected key while parsing Dog".to_string(), - ); + ) } } } @@ -2243,20 +2241,19 @@ impl DollarSpecialLeftSquareBracketModelNameRightSquareBracket { /// Should be implemented in a serde serializer impl std::fmt::Display for DollarSpecialLeftSquareBracketModelNameRightSquareBracket { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.dollar_special_left_square_bracket_property_name_right_square_bracket - .as_ref() - .map( - |dollar_special_left_square_bracket_property_name_right_square_bracket| { - [ - "$special[property.name]".to_string(), - dollar_special_left_square_bracket_property_name_right_square_bracket - .to_string(), - ] - .join(",") - }, - ), - ]; + let params: Vec> = vec![self + .dollar_special_left_square_bracket_property_name_right_square_bracket + .as_ref() + .map( + |dollar_special_left_square_bracket_property_name_right_square_bracket| { + [ + "$special[property.name]".to_string(), + dollar_special_left_square_bracket_property_name_right_square_bracket + .to_string(), + ] + .join(",") + }, + )]; write!( f, @@ -2450,7 +2447,7 @@ impl std::str::FromStr for EnumArrays { None => { return std::result::Result::Err( "Missing value while parsing EnumArrays".to_string(), - ); + ) } }; @@ -2465,18 +2462,18 @@ impl std::str::FromStr for EnumArrays { return std::result::Result::Err( "Parsing a container in this style is not supported in EnumArrays" .to_string(), - ); + ) } "array_array_enum" => { return std::result::Result::Err( "Parsing a container in this style is not supported in EnumArrays" .to_string(), - ); + ) } _ => { return std::result::Result::Err( "Unexpected key while parsing EnumArrays".to_string(), - ); + ) } } } @@ -2684,7 +2681,7 @@ impl std::str::FromStr for EnumTest { None => { return std::result::Result::Err( "Missing value while parsing EnumTest".to_string(), - ); + ) } }; @@ -2715,7 +2712,7 @@ impl std::str::FromStr for EnumTest { _ => { return std::result::Result::Err( "Unexpected key while parsing EnumTest".to_string(), - ); + ) } } } @@ -2972,7 +2969,7 @@ impl std::str::FromStr for FormatTest { None => { return std::result::Result::Err( "Missing value while parsing FormatTest".to_string(), - ); + ) } }; @@ -3011,13 +3008,13 @@ impl std::str::FromStr for FormatTest { return std::result::Result::Err( "Parsing binary data in this style is not supported in FormatTest" .to_string(), - ); + ) } "binary" => { return std::result::Result::Err( "Parsing binary data in this style is not supported in FormatTest" .to_string(), - ); + ) } #[allow(clippy::redundant_clone)] "date" => intermediate_rep.date.push( @@ -3041,7 +3038,7 @@ impl std::str::FromStr for FormatTest { _ => { return std::result::Result::Err( "Unexpected key while parsing FormatTest".to_string(), - ); + ) } } } @@ -3200,7 +3197,7 @@ impl std::str::FromStr for HasOnlyReadOnly { None => { return std::result::Result::Err( "Missing value while parsing HasOnlyReadOnly".to_string(), - ); + ) } }; @@ -3218,7 +3215,7 @@ impl std::str::FromStr for HasOnlyReadOnly { _ => { return std::result::Result::Err( "Unexpected key while parsing HasOnlyReadOnly".to_string(), - ); + ) } } } @@ -3300,10 +3297,10 @@ impl List { /// Should be implemented in a serde serializer impl std::fmt::Display for List { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = - vec![self.param_123_list.as_ref().map(|param_123_list| { - ["123-list".to_string(), param_123_list.to_string()].join(",") - })]; + let params: Vec> = vec![self + .param_123_list + .as_ref() + .map(|param_123_list| ["123-list".to_string(), param_123_list.to_string()].join(","))]; write!( f, @@ -3337,7 +3334,7 @@ impl std::str::FromStr for List { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing List".to_string()); + return std::result::Result::Err("Missing value while parsing List".to_string()) } }; @@ -3351,7 +3348,7 @@ impl std::str::FromStr for List { _ => { return std::result::Result::Err( "Unexpected key while parsing List".to_string(), - ); + ) } } } @@ -3495,7 +3492,7 @@ impl std::str::FromStr for MapTest { None => { return std::result::Result::Err( "Missing value while parsing MapTest".to_string(), - ); + ) } }; @@ -3506,24 +3503,24 @@ impl std::str::FromStr for MapTest { return std::result::Result::Err( "Parsing a container in this style is not supported in MapTest" .to_string(), - ); + ) } "map_map_of_enum" => { return std::result::Result::Err( "Parsing a container in this style is not supported in MapTest" .to_string(), - ); + ) } "map_of_enum_string" => { return std::result::Result::Err( "Parsing a container in this style is not supported in MapTest" .to_string(), - ); + ) } _ => { return std::result::Result::Err( "Unexpected key while parsing MapTest".to_string(), - ); + ) } } } @@ -3812,7 +3809,7 @@ impl std::str::FromStr for Model200Response { None => { return std::result::Result::Err( "Missing value while parsing Model200Response".to_string(), - ); + ) } }; @@ -3830,7 +3827,7 @@ impl std::str::FromStr for Model200Response { _ => { return std::result::Result::Err( "Unexpected key while parsing Model200Response".to_string(), - ); + ) } } } @@ -3976,7 +3973,7 @@ impl std::str::FromStr for Name { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Name".to_string()); + return std::result::Result::Err("Missing value while parsing Name".to_string()) } }; @@ -4002,7 +3999,7 @@ impl std::str::FromStr for Name { _ => { return std::result::Result::Err( "Unexpected key while parsing Name".to_string(), - ); + ) } } } @@ -4085,11 +4082,10 @@ impl NumberOnly { /// Should be implemented in a serde serializer impl std::fmt::Display for NumberOnly { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.just_number - .as_ref() - .map(|just_number| ["JustNumber".to_string(), just_number.to_string()].join(",")), - ]; + let params: Vec> = vec![self + .just_number + .as_ref() + .map(|just_number| ["JustNumber".to_string(), just_number.to_string()].join(","))]; write!( f, @@ -4125,7 +4121,7 @@ impl std::str::FromStr for NumberOnly { None => { return std::result::Result::Err( "Missing value while parsing NumberOnly".to_string(), - ); + ) } }; @@ -4139,7 +4135,7 @@ impl std::str::FromStr for NumberOnly { _ => { return std::result::Result::Err( "Unexpected key while parsing NumberOnly".to_string(), - ); + ) } } } @@ -4489,7 +4485,7 @@ impl std::str::FromStr for Order { None => { return std::result::Result::Err( "Missing value while parsing Order".to_string(), - ); + ) } }; @@ -4524,7 +4520,7 @@ impl std::str::FromStr for Order { _ => { return std::result::Result::Err( "Unexpected key while parsing Order".to_string(), - ); + ) } } } @@ -4701,7 +4697,7 @@ impl std::str::FromStr for OuterComposite { None => { return std::result::Result::Err( "Missing value while parsing OuterComposite".to_string(), - ); + ) } }; @@ -4723,7 +4719,7 @@ impl std::str::FromStr for OuterComposite { _ => { return std::result::Result::Err( "Unexpected key while parsing OuterComposite".to_string(), - ); + ) } } } @@ -5023,7 +5019,7 @@ impl std::str::FromStr for Pet { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Pet".to_string()); + return std::result::Result::Err("Missing value while parsing Pet".to_string()) } }; @@ -5046,12 +5042,12 @@ impl std::str::FromStr for Pet { "photoUrls" => { return std::result::Result::Err( "Parsing a container in this style is not supported in Pet".to_string(), - ); + ) } "tags" => { return std::result::Result::Err( "Parsing a container in this style is not supported in Pet".to_string(), - ); + ) } #[allow(clippy::redundant_clone)] "status" => intermediate_rep.status.push( @@ -5060,7 +5056,7 @@ impl std::str::FromStr for Pet { _ => { return std::result::Result::Err( "Unexpected key while parsing Pet".to_string(), - ); + ) } } } @@ -5200,7 +5196,7 @@ impl std::str::FromStr for ReadOnlyFirst { None => { return std::result::Result::Err( "Missing value while parsing ReadOnlyFirst".to_string(), - ); + ) } }; @@ -5218,7 +5214,7 @@ impl std::str::FromStr for ReadOnlyFirst { _ => { return std::result::Result::Err( "Unexpected key while parsing ReadOnlyFirst".to_string(), - ); + ) } } } @@ -5298,11 +5294,10 @@ impl Return { /// Should be implemented in a serde serializer impl std::fmt::Display for Return { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.r#return - .as_ref() - .map(|r#return| ["return".to_string(), r#return.to_string()].join(",")), - ]; + let params: Vec> = vec![self + .r#return + .as_ref() + .map(|r#return| ["return".to_string(), r#return.to_string()].join(","))]; write!( f, @@ -5338,7 +5333,7 @@ impl std::str::FromStr for Return { None => { return std::result::Result::Err( "Missing value while parsing Return".to_string(), - ); + ) } }; @@ -5352,7 +5347,7 @@ impl std::str::FromStr for Return { _ => { return std::result::Result::Err( "Unexpected key while parsing Return".to_string(), - ); + ) } } } @@ -5480,7 +5475,7 @@ impl std::str::FromStr for Tag { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Tag".to_string()); + return std::result::Result::Err("Missing value while parsing Tag".to_string()) } }; @@ -5498,7 +5493,7 @@ impl std::str::FromStr for Tag { _ => { return std::result::Result::Err( "Unexpected key while parsing Tag".to_string(), - ); + ) } } } @@ -5763,7 +5758,7 @@ impl std::str::FromStr for TestEndpointParametersRequest { None => { return std::result::Result::Err( "Missing value while parsing TestEndpointParametersRequest".to_string(), - ); + ) } }; @@ -5948,7 +5943,7 @@ impl std::str::FromStr for TestEnumParametersRequest { None => { return std::result::Result::Err( "Missing value while parsing TestEnumParametersRequest".to_string(), - ); + ) } }; @@ -5962,7 +5957,7 @@ impl std::str::FromStr for TestEnumParametersRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing TestEnumParametersRequest".to_string(), - ); + ) } } } @@ -6088,7 +6083,7 @@ impl std::str::FromStr for TestJsonFormDataRequest { None => { return std::result::Result::Err( "Missing value while parsing TestJsonFormDataRequest".to_string(), - ); + ) } }; @@ -6106,7 +6101,7 @@ impl std::str::FromStr for TestJsonFormDataRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing TestJsonFormDataRequest".to_string(), - ); + ) } } } @@ -6248,7 +6243,7 @@ impl std::str::FromStr for UpdatePetWithFormRequest { None => { return std::result::Result::Err( "Missing value while parsing UpdatePetWithFormRequest".to_string(), - ); + ) } }; @@ -6266,7 +6261,7 @@ impl std::str::FromStr for UpdatePetWithFormRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing UpdatePetWithFormRequest".to_string(), - ); + ) } } } @@ -6404,7 +6399,7 @@ impl std::str::FromStr for UploadFileRequest { None => { return std::result::Result::Err( "Missing value while parsing UploadFileRequest".to_string(), - ); + ) } }; @@ -6422,7 +6417,7 @@ impl std::str::FromStr for UploadFileRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing UploadFileRequest".to_string(), - ); + ) } } } @@ -6611,7 +6606,7 @@ impl std::str::FromStr for User { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing User".to_string()); + return std::result::Result::Err("Missing value while parsing User".to_string()) } }; @@ -6653,7 +6648,7 @@ impl std::str::FromStr for User { _ => { return std::result::Result::Err( "Unexpected key while parsing User".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 39308cf69152..a535849f7959 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -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}; @@ -183,13 +183,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 || { @@ -336,13 +331,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { @@ -430,13 +419,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { @@ -524,13 +507,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { @@ -618,13 +595,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { @@ -912,13 +883,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 || { @@ -1384,13 +1350,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 || { @@ -1634,13 +1595,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -1715,13 +1670,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -1806,13 +1755,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2055,13 +1998,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 || { @@ -2212,13 +2150,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 || { @@ -2295,13 +2228,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2387,13 +2314,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2753,13 +2674,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -2874,13 +2789,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; diff --git a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/types.rs b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/types.rs index c5d649a86291..5a390a3f5a21 100644 --- a/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/types.rs +++ b/samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/petstore/src/models.rs b/samples/server/petstore/rust-axum/output/petstore/src/models.rs index 107ff2617b50..011a9f76196e 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/models.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/models.rs @@ -249,7 +249,7 @@ impl std::str::FromStr for ApiResponse { None => { return std::result::Result::Err( "Missing value while parsing ApiResponse".to_string(), - ); + ) } }; @@ -271,7 +271,7 @@ impl std::str::FromStr for ApiResponse { _ => { return std::result::Result::Err( "Unexpected key while parsing ApiResponse".to_string(), - ); + ) } } } @@ -411,7 +411,7 @@ impl std::str::FromStr for Category { None => { return std::result::Result::Err( "Missing value while parsing Category".to_string(), - ); + ) } }; @@ -429,7 +429,7 @@ impl std::str::FromStr for Category { _ => { return std::result::Result::Err( "Unexpected key while parsing Category".to_string(), - ); + ) } } } @@ -597,7 +597,7 @@ impl std::str::FromStr for Order { None => { return std::result::Result::Err( "Missing value while parsing Order".to_string(), - ); + ) } }; @@ -632,7 +632,7 @@ impl std::str::FromStr for Order { _ => { return std::result::Result::Err( "Unexpected key while parsing Order".to_string(), - ); + ) } } } @@ -804,7 +804,7 @@ impl std::str::FromStr for Pet { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Pet".to_string()); + return std::result::Result::Err("Missing value while parsing Pet".to_string()) } }; @@ -827,12 +827,12 @@ impl std::str::FromStr for Pet { "photoUrls" => { return std::result::Result::Err( "Parsing a container in this style is not supported in Pet".to_string(), - ); + ) } "tags" => { return std::result::Result::Err( "Parsing a container in this style is not supported in Pet".to_string(), - ); + ) } #[allow(clippy::redundant_clone)] "status" => intermediate_rep.status.push( @@ -841,7 +841,7 @@ impl std::str::FromStr for Pet { _ => { return std::result::Result::Err( "Unexpected key while parsing Pet".to_string(), - ); + ) } } } @@ -979,7 +979,7 @@ impl std::str::FromStr for Tag { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing Tag".to_string()); + return std::result::Result::Err("Missing value while parsing Tag".to_string()) } }; @@ -997,7 +997,7 @@ impl std::str::FromStr for Tag { _ => { return std::result::Result::Err( "Unexpected key while parsing Tag".to_string(), - ); + ) } } } @@ -1127,7 +1127,7 @@ impl std::str::FromStr for UpdatePetWithFormRequest { None => { return std::result::Result::Err( "Missing value while parsing UpdatePetWithFormRequest".to_string(), - ); + ) } }; @@ -1145,7 +1145,7 @@ impl std::str::FromStr for UpdatePetWithFormRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing UpdatePetWithFormRequest".to_string(), - ); + ) } } } @@ -1283,7 +1283,7 @@ impl std::str::FromStr for UploadFileRequest { None => { return std::result::Result::Err( "Missing value while parsing UploadFileRequest".to_string(), - ); + ) } }; @@ -1301,7 +1301,7 @@ impl std::str::FromStr for UploadFileRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing UploadFileRequest".to_string(), - ); + ) } } } @@ -1491,7 +1491,7 @@ impl std::str::FromStr for User { let val = match string_iter.next() { Some(x) => x, None => { - return std::result::Result::Err("Missing value while parsing User".to_string()); + return std::result::Result::Err("Missing value while parsing User".to_string()) } }; @@ -1533,7 +1533,7 @@ impl std::str::FromStr for User { _ => { return std::result::Result::Err( "Unexpected key while parsing User".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs index 2444933c3c72..51d67ea7439c 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs @@ -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}; @@ -126,13 +126,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -303,13 +297,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -384,13 +372,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -475,13 +457,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -567,13 +543,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -740,13 +710,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 || { @@ -897,13 +862,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 || { @@ -980,13 +940,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -1072,13 +1026,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -1482,13 +1430,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; @@ -1619,13 +1561,7 @@ where let mut response = response.status(200); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("text/plain").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); } let body_content = body; diff --git a/samples/server/petstore/rust-axum/output/petstore/src/types.rs b/samples/server/petstore/rust-axum/output/petstore/src/types.rs index 149d3613ea9c..79a6ee8f7602 100644 --- a/samples/server/petstore/rust-axum/output/petstore/src/types.rs +++ b/samples/server/petstore/rust-axum/output/petstore/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs index 164176b0f409..33dc17183ec2 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/server/mod.rs @@ -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}; diff --git a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/types.rs b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/types.rs index 8b410453316b..122ef30ee034 100644 --- a/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/types.rs +++ b/samples/server/petstore/rust-axum/output/ping-bearer-auth/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/server/mod.rs index 529c8e0a5fce..ebe374d0f463 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/server/mod.rs @@ -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}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/types.rs b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/types.rs index 57736940b89c..5c488a6acdc7 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/types.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-array-params-test/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs index b154b7f57abb..621da1e90644 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/server/mod.rs @@ -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}; @@ -105,13 +105,8 @@ where let mut response = response.status(201); { let mut response_headers = response.headers_mut().unwrap(); - response_headers.insert( - CONTENT_TYPE, - HeaderValue::from_str("application/json").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); } let body_content = tokio::task::spawn_blocking(move || { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/types.rs b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/types.rs index 7fb6c7c85af8..0ef27ed62c5d 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/types.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-header-uuid/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs index dbf993dae262..35e1ac030b25 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/models.rs @@ -142,7 +142,7 @@ impl std::str::FromStr for Goodbye { None => { return std::result::Result::Err( "Missing value while parsing Goodbye".to_string(), - ); + ) } }; @@ -161,7 +161,7 @@ impl std::str::FromStr for Goodbye { _ => { return std::result::Result::Err( "Unexpected key while parsing Goodbye".to_string(), - ); + ) } } } @@ -287,7 +287,7 @@ impl std::str::FromStr for GoodbyeD { None => { return std::result::Result::Err( "Missing value while parsing GoodbyeD".to_string(), - ); + ) } }; @@ -301,7 +301,7 @@ impl std::str::FromStr for GoodbyeD { _ => { return std::result::Result::Err( "Unexpected key while parsing GoodbyeD".to_string(), - ); + ) } } } @@ -445,7 +445,7 @@ impl std::str::FromStr for Greeting { None => { return std::result::Result::Err( "Missing value while parsing Greeting".to_string(), - ); + ) } }; @@ -464,7 +464,7 @@ impl std::str::FromStr for Greeting { _ => { return std::result::Result::Err( "Unexpected key while parsing Greeting".to_string(), - ); + ) } } } @@ -590,7 +590,7 @@ impl std::str::FromStr for GreetingD { None => { return std::result::Result::Err( "Missing value while parsing GreetingD".to_string(), - ); + ) } }; @@ -604,7 +604,7 @@ impl std::str::FromStr for GreetingD { _ => { return std::result::Result::Err( "Unexpected key while parsing GreetingD".to_string(), - ); + ) } } } @@ -750,7 +750,7 @@ impl std::str::FromStr for Hello { None => { return std::result::Result::Err( "Missing value while parsing Hello".to_string(), - ); + ) } }; @@ -769,7 +769,7 @@ impl std::str::FromStr for Hello { _ => { return std::result::Result::Err( "Unexpected key while parsing Hello".to_string(), - ); + ) } } } @@ -893,7 +893,7 @@ impl std::str::FromStr for HelloD { None => { return std::result::Result::Err( "Missing value while parsing HelloD".to_string(), - ); + ) } }; @@ -907,7 +907,7 @@ impl std::str::FromStr for HelloD { _ => { return std::result::Result::Err( "Unexpected key while parsing HelloD".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs index 2991586f4a6a..be80a6a15652 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/server/mod.rs @@ -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}; @@ -77,13 +77,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 || { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/types.rs b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/types.rs index 416088221d2d..5e5733cbf01f 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/types.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-oneof/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs index 1d09683c0009..c198f0fec8e8 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/models.rs @@ -142,7 +142,7 @@ impl std::str::FromStr for FooANullableContainer { None => { return std::result::Result::Err( "Missing value while parsing FooANullableContainer".to_string(), - ); + ) } }; @@ -355,7 +355,7 @@ impl std::str::FromStr for FooAllOfObject { None => { return std::result::Result::Err( "Missing value while parsing FooAllOfObject".to_string(), - ); + ) } }; @@ -373,7 +373,7 @@ impl std::str::FromStr for FooAllOfObject { _ => { return std::result::Result::Err( "Unexpected key while parsing FooAllOfObject".to_string(), - ); + ) } } } @@ -456,17 +456,16 @@ impl FooBaseAllOf { impl std::fmt::Display for FooBaseAllOf { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let params: Vec> = - vec![ - self.sample_base_property - .as_ref() - .map(|sample_base_property| { - [ - "sampleBaseProperty".to_string(), - sample_base_property.to_string(), - ] - .join(",") - }), - ]; + vec![self + .sample_base_property + .as_ref() + .map(|sample_base_property| { + [ + "sampleBaseProperty".to_string(), + sample_base_property.to_string(), + ] + .join(",") + })]; write!( f, @@ -502,7 +501,7 @@ impl std::str::FromStr for FooBaseAllOf { None => { return std::result::Result::Err( "Missing value while parsing FooBaseAllOf".to_string(), - ); + ) } }; @@ -516,7 +515,7 @@ impl std::str::FromStr for FooBaseAllOf { _ => { return std::result::Result::Err( "Unexpected key while parsing FooBaseAllOf".to_string(), - ); + ) } } } @@ -642,7 +641,7 @@ impl std::str::FromStr for FooDummyPutRequest { None => { return std::result::Result::Err( "Missing value while parsing FooDummyPutRequest".to_string(), - ); + ) } }; @@ -660,7 +659,7 @@ impl std::str::FromStr for FooDummyPutRequest { _ => { return std::result::Result::Err( "Unexpected key while parsing FooDummyPutRequest".to_string(), - ); + ) } } } @@ -746,11 +745,10 @@ impl FooGetYamlResponse { /// Should be implemented in a serde serializer impl std::fmt::Display for FooGetYamlResponse { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let params: Vec> = vec![ - self.value - .as_ref() - .map(|value| ["value".to_string(), value.to_string()].join(",")), - ]; + let params: Vec> = vec![self + .value + .as_ref() + .map(|value| ["value".to_string(), value.to_string()].join(","))]; write!( f, @@ -786,7 +784,7 @@ impl std::str::FromStr for FooGetYamlResponse { None => { return std::result::Result::Err( "Missing value while parsing FooGetYamlResponse".to_string(), - ); + ) } }; @@ -800,7 +798,7 @@ impl std::str::FromStr for FooGetYamlResponse { _ => { return std::result::Result::Err( "Unexpected key while parsing FooGetYamlResponse".to_string(), - ); + ) } } } @@ -919,7 +917,7 @@ impl std::str::FromStr for FooObjectOfObjects { None => { return std::result::Result::Err( "Missing value while parsing FooObjectOfObjects".to_string(), - ); + ) } }; @@ -934,7 +932,7 @@ impl std::str::FromStr for FooObjectOfObjects { _ => { return std::result::Result::Err( "Unexpected key while parsing FooObjectOfObjects".to_string(), - ); + ) } } } @@ -1062,7 +1060,7 @@ impl std::str::FromStr for FooObjectOfObjectsInner { None => { return std::result::Result::Err( "Missing value while parsing FooObjectOfObjectsInner".to_string(), - ); + ) } }; @@ -1080,7 +1078,7 @@ impl std::str::FromStr for FooObjectOfObjectsInner { _ => { return std::result::Result::Err( "Unexpected key while parsing FooObjectOfObjectsInner".to_string(), - ); + ) } } } diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs index 7c353c0633c3..b52ef0300b58 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/server/mod.rs @@ -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}; @@ -74,13 +74,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { @@ -280,13 +274,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 || { @@ -358,13 +347,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/yaml").map_err(|e| { - error!(error = ?e); - StatusCode::INTERNAL_SERVER_ERROR - })?, - ); + response_headers + .insert(CONTENT_TYPE, HeaderValue::from_static("application/yaml")); } let body_content = body; @@ -436,13 +420,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/html")); } let body_content = body; @@ -573,13 +551,7 @@ where 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 - })?, - ); + response_headers.insert(CONTENT_TYPE, HeaderValue::from_static("*/*")); } let body_content = tokio::task::spawn_blocking(move || { diff --git a/samples/server/petstore/rust-axum/output/rust-axum-test/src/types.rs b/samples/server/petstore/rust-axum/output/rust-axum-test/src/types.rs index 999330a74f54..00e17f45c180 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-test/src/types.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-test/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs index c132fc8c9cb5..c76b7e3d0325 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/server/mod.rs @@ -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}; diff --git a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/types.rs b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/types.rs index 0a808e5a90c5..ed6bc545eadf 100644 --- a/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/types.rs +++ b/samples/server/petstore/rust-axum/output/rust-axum-validation-test/src/types.rs @@ -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)] diff --git a/samples/server/petstore/rust-server-deprecated/output/no-example-v3/src/client/mod.rs b/samples/server/petstore/rust-server-deprecated/output/no-example-v3/src/client/mod.rs index a11785695a1c..f9fb09a11315 100644 --- a/samples/server/petstore/rust-server-deprecated/output/no-example-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/no-example-v3/src/client/mod.rs @@ -423,10 +423,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, diff --git a/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/client/mod.rs index d01a806ff506..cd1e6a1d05a4 100644 --- a/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/client/mod.rs @@ -794,10 +794,7 @@ impl Api for Client where *request.body_mut() = Body::from(body.into_bytes()); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1792,10 +1789,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/octet-stream"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2239,10 +2233,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2393,10 +2384,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2477,10 +2465,7 @@ impl Api for Client where } let header = "text/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2573,10 +2558,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2657,10 +2639,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2741,10 +2720,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2959,10 +2935,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, diff --git a/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/server/mod.rs index db2d5290a1bc..720cb975d171 100644 --- a/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/openapi-v3/src/server/mod.rs @@ -282,8 +282,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -294,8 +293,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -306,8 +304,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(202).expect("Unable to turn 202 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -450,8 +447,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -687,8 +683,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/merge-patch+json") - .expect("Unable to create Content-Type header for application/merge-patch+json")); + HeaderValue::from_static("application/merge-patch+json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -723,8 +718,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -735,8 +729,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -747,8 +740,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(202).expect("Unable to turn 202 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/octet-stream") - .expect("Unable to create Content-Type header for application/octet-stream")); + HeaderValue::from_static("application/octet-stream")); // Binary Body let body = body.0; *response.body_mut() = Body::from(body); @@ -759,8 +751,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(203).expect("Unable to turn 203 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("text/plain") - .expect("Unable to create Content-Type header for text/plain")); + HeaderValue::from_static("text/plain")); // Plain text Body let body = body; *response.body_mut() = Body::from(body); @@ -771,8 +762,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(204).expect("Unable to turn 204 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -783,8 +773,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(205).expect("Unable to turn 205 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -795,8 +784,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(206).expect("Unable to turn 206 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -889,8 +877,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1001,8 +988,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1257,8 +1243,7 @@ impl hyper::service::Service<(Request, C)> for Service where } response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1335,8 +1320,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(204).expect("Unable to turn 204 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1347,8 +1331,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/problem+json") - .expect("Unable to create Content-Type header for application/problem+json")); + HeaderValue::from_static("application/problem+json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1359,8 +1342,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(406).expect("Unable to turn 406 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/problem+xml") - .expect("Unable to create Content-Type header for application/problem+xml")); + HeaderValue::from_static("application/problem+xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1523,8 +1505,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1649,8 +1630,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("text/xml") - .expect("Unable to create Content-Type header for text/xml")); + HeaderValue::from_static("text/xml")); // XML Body // An empty string is used to indicate a global namespace in xmltree. let config = serde_xml_rs::SerdeXml::new() @@ -2103,8 +2083,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); diff --git a/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs b/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs index 62c04f02695f..40100279f987 100644 --- a/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs @@ -460,10 +460,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -614,10 +611,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -703,10 +697,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -792,10 +783,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -881,10 +869,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1036,10 +1021,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1113,10 +1095,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1291,10 +1270,7 @@ impl Api for Client where *request.body_mut() = Body::from(body.into_bytes()); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1421,10 +1397,7 @@ impl Api for Client where *request.body_mut() = Body::from(body.into_bytes()); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1538,10 +1511,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1626,10 +1596,7 @@ impl Api for Client where *request.body_mut() = Body::from(body.into_bytes()); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1773,10 +1740,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1868,10 +1832,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2169,10 +2130,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2492,10 +2450,7 @@ impl Api for Client where *request.body_mut() = Body::from(body.into_bytes()); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -2823,10 +2778,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -3078,10 +3030,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -3155,10 +3104,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -3232,10 +3178,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -3657,10 +3600,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, diff --git a/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 076fa1077513..c3adc82cb031 100644 --- a/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -345,8 +345,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -441,8 +440,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -509,8 +507,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -577,8 +574,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -645,8 +641,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -849,8 +844,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1357,8 +1351,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1536,8 +1529,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1613,8 +1605,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -1898,8 +1889,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2203,8 +2193,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2255,8 +2244,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2327,8 +2315,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2453,8 +2440,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2798,8 +2784,7 @@ impl hyper::service::Service<(Request, C)> for Service where } response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -2946,8 +2931,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/xml") - .expect("Unable to create Content-Type header for application/xml")); + HeaderValue::from_static("application/xml")); // XML Body let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); diff --git a/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/client/mod.rs b/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/client/mod.rs index 5cabbfd3ab8a..d52c192a58b6 100644 --- a/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/client/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/client/mod.rs @@ -571,10 +571,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -797,10 +794,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "text/html"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -883,10 +877,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/yaml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, @@ -1035,10 +1026,7 @@ impl Api for Client where *request.body_mut() = Body::from(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { Ok(h) => h, diff --git a/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/server/mod.rs index e3637b564c7b..fd6bff4c2c22 100644 --- a/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server-deprecated/output/rust-server-test/src/server/mod.rs @@ -186,8 +186,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -320,8 +319,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/json") - .expect("Unable to create Content-Type header for application/json")); + HeaderValue::from_static("application/json")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); @@ -356,8 +354,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("application/yaml") - .expect("Unable to create Content-Type header for application/yaml")); + HeaderValue::from_static("application/yaml")); // Plain text Body let body = body; *response.body_mut() = Body::from(body); @@ -417,8 +414,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("text/html") - .expect("Unable to create Content-Type header for text/html")); + HeaderValue::from_static("text/html")); // Plain text Body let body = body; *response.body_mut() = Body::from(body); @@ -518,8 +514,7 @@ impl hyper::service::Service<(Request, C)> for Service where *response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode"); response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("*/*") - .expect("Unable to create Content-Type header for */*")); + HeaderValue::from_static("*/*")); // JSON Body let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); *response.body_mut() = Body::from(body); diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs index f55b94c32e49..6bdb31f4c2fc 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/client/mod.rs @@ -448,10 +448,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 90ea467c4bca..05d38a1b1a6d 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -839,10 +839,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1893,10 +1890,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/octet-stream"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2360,10 +2354,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2522,10 +2513,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2609,10 +2597,7 @@ impl Api for Client where } let header = "text/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2710,10 +2695,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2797,10 +2779,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2884,10 +2863,7 @@ impl Api for Client where } let header = "application/xml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -3111,10 +3087,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index ac28b04a475a..5e0dfbd722c4 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -308,8 +308,7 @@ impl hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -647,10 +644,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -741,10 +735,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -835,10 +826,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -929,10 +917,7 @@ impl Api for Client where } let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1092,10 +1077,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1172,10 +1154,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1355,10 +1334,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1485,10 +1461,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1605,10 +1578,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1696,10 +1666,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1849,10 +1816,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1950,10 +1914,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2264,10 +2225,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2599,10 +2557,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/x-www-form-urlencoded"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -2945,10 +2900,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -3213,10 +3165,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -3293,10 +3242,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -3373,10 +3319,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -3817,10 +3760,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 1213dfae3c09..d80bcfda95ef 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -375,8 +375,7 @@ impl hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -843,10 +840,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "text/html"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -934,10 +928,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/yaml"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -1094,10 +1085,7 @@ impl Api for Client where *request.body_mut() = body_from_string(body); let header = "application/json"; - 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)); let header = HeaderValue::from_str(Has::::get(context).0.as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs index c68c0a73f3fc..eb1af9c6f09e 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/server/mod.rs @@ -212,8 +212,7 @@ impl hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service hyper::service::Service<(Request, C)> for Service