diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache index 386c68eebc2..c49bdd656df 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-mod.mustache @@ -21,7 +21,7 @@ fn into_base_path(input: impl TryInto, } } - let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; + let host = uri.host().ok_or(ClientInitError::MissingHost)?; let port = uri.port_u16().map(|x| format!(":{}", x)).unwrap_or_default(); Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/'))) } @@ -160,7 +160,7 @@ impl Client, C> where "https" => { let connector = connector.https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; HyperClient::Https(hyper::client::Client::builder().build(connector)) }, _ => { @@ -212,7 +212,7 @@ impl Client, C let https_connector = Connector::builder() .https() .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -233,7 +233,7 @@ impl Client, C .https() .pin_server_certificate(ca_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } @@ -261,7 +261,7 @@ impl Client, C .pin_server_certificate(ca_certificate) .client_authentication(client_key, client_certificate) .build() - .map_err(|e| ClientInitError::SslError(e))?; + .map_err(ClientInitError::SslError)?; Self::try_new_with_connector(base_path, Some("https"), https_connector) } } diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache index 768e846eb9d..ca566860288 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache @@ -298,7 +298,7 @@ {{/bodyParam}} {{/x-consumes-multipart}} {{/vendorExtensions}} - let header = HeaderValue::from_str(Has::::get(context).0.clone().to_string().as_str()); + 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, Err(e) => return Err(ApiError(format!("Unable to create X-Span ID header value: {}", e))) @@ -382,7 +382,7 @@ {{/isMap}} {{/headerParams}} - let mut response = client_service.call((request, context.clone())) + let response = client_service.call((request, context.clone())) .map_err(|e| ApiError(format!("No response received: {}", e))).await?; match response.status().as_u16() { @@ -415,8 +415,8 @@ }; {{/headers}} - let body = response.into_body(); {{#dataType}} + let body = response.into_body(); let body = body .into_raw() .map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?; diff --git a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache index 57147489c6c..7603c82c6cc 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache @@ -1,4 +1,5 @@ #![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] +#![allow(unused_imports)] use async_trait::async_trait; use futures::Stream; @@ -9,9 +10,9 @@ use serde::{Serialize, Deserialize}; type ServiceError = Box; -pub const BASE_PATH: &'static str = "{{{basePathWithoutHost}}}"; +pub const BASE_PATH: &str = "{{{basePathWithoutHost}}}"; {{#appVersion}} -pub const API_VERSION: &'static str = "{{{.}}}"; +pub const API_VERSION: &str = "{{{.}}}"; {{/appVersion}} {{#apiInfo}} @@ -82,7 +83,7 @@ pub trait ApiNoContext { pub trait ContextWrapperExt where Self: Sized { /// Binds this API to a context. - fn with_context(self: Self, context: C) -> ContextWrapper; + fn with_context(self, context: C) -> ContextWrapper; } impl + Send + Sync, C: Clone + Send + Sync> ContextWrapperExt for T {