From b1fac19a758210583e9c31e62b6955fc8dfcd60c Mon Sep 17 00:00:00 2001 From: myz-dev <62795612+myz-dev@users.noreply.github.com> Date: Mon, 6 May 2024 06:24:33 +0200 Subject: [PATCH] Fix #18572 rust server: Silence clippy lints by refactoring (#18575) * refactor: move closure definition to own statement A clippy lint recommends not using a closure inside of a statement. The code generation used to produce code that triggered this warning, which caused the rust-server integration test to fail because clippy is configured to return lint violations as errors. For details for the lint see: https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions * refactor: Remove unnecessary qualification A GitHub action test used to fail because of a clippy warning that was emitted due to not using an imported symbol but qualifying its use. A failed test can be seen here: https://github.com/OpenAPITools/openapi-generator/actions/runs/8958257509/job/24603984954?pr=18563 With the relevant error being: error: unnecessary qualification --> output/openapi-v3/src/client/callbacks.rs:88:9 | 88 | futures::future::ok(Service::new( This commit simply removes the qualification. * test: Update examples and run integration test. Updated examples by running `./bin/generate-samples.sh ./bin/configs/rust-server-*` The integration test with the following command passes: `mvn integration-test -f samples/server/petstore/rust-server/pom.xml` --- .../rust-server/server-make-service.mustache | 2 +- .../rust-server/server-operation.mustache | 14 +- .../output/multipart-v3/src/server/mod.rs | 7 +- .../output/no-example-v3/src/server/mod.rs | 11 +- .../output/openapi-v3/src/client/callbacks.rs | 2 +- .../output/openapi-v3/src/server/mod.rs | 65 ++++---- .../output/ops-v3/src/server/mod.rs | 2 +- .../src/server/mod.rs | 146 ++++++++++-------- .../output/ping-bearer-auth/src/server/mod.rs | 2 +- .../output/rust-server-test/src/server/mod.rs | 20 +-- 10 files changed, 150 insertions(+), 121 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-make-service.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-make-service.mustache index b2c7afd5fdf9..684406fbc03a 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-make-service.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-make-service.mustache @@ -31,7 +31,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache index f0ba616a9abc..3bc9b31296ca 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache @@ -224,10 +224,11 @@ let deserializer = &mut serde_json::Deserializer::from_slice(&body); {{/x-consumes-json}} {{^x-consumes-plain-text}} - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_{{{paramName}}}) => param_{{{paramName}}}, {{#required}} Err(e) => return Ok(Response::builder() @@ -421,10 +422,11 @@ Some("{{{contentType}}}") if param_{{{paramName}}}.is_none() => { // Extract JSON part. let deserializer = &mut serde_json::Deserializer::from_slice(part.body.as_slice()); - let json_data: {{dataType}} = match serde_ignored::deserialize(deserializer, |path| { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { warn!("Ignoring unknown field in JSON part: {}", path); unused_elements.push(path.to_string()); - }) { + }; + let json_data: {{dataType}} = match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(json_data) => json_data, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs index c3ab4bd0e641..9bf8330d4461 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/server/mod.rs @@ -81,7 +81,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } @@ -206,10 +206,11 @@ impl hyper::service::Service<(Request, C)> for Service where Some("application/json") if param_object_field.is_none() => { // Extract JSON part. let deserializer = &mut serde_json::Deserializer::from_slice(part.body.as_slice()); - let json_data: models::MultipartRequestObjectField = match serde_ignored::deserialize(deserializer, |path| { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { warn!("Ignoring unknown field in JSON part: {}", path); unused_elements.push(path.to_string()); - }) { + }; + let json_data: models::MultipartRequestObjectField = match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(json_data) => json_data, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs index 1e951f6e0e72..496d89296365 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/server/mod.rs @@ -70,7 +70,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } @@ -150,10 +150,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_op_get_request: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_op_get_request) => param_op_get_request, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index 3f3d2b0cf82f..cfc2f9059c3e 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -85,7 +85,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } 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 3808a67d7573..3825329a51ec 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 @@ -155,7 +155,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } @@ -1269,10 +1269,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_object_untyped_props: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_object_untyped_props) => param_object_untyped_props, Err(_) => None, } @@ -1368,10 +1369,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_duplicate_xml_object: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_duplicate_xml_object) => param_duplicate_xml_object, Err(_) => None, } @@ -1435,10 +1437,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_another_xml_object: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_another_xml_object) => param_another_xml_object, Err(_) => None, } @@ -1513,10 +1516,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_another_xml_array: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_another_xml_array) => param_another_xml_array, Err(_) => None, } @@ -1580,10 +1584,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_xml_array: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_xml_array) => param_xml_array, Err(_) => None, } @@ -1647,10 +1652,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_xml_object: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_xml_object) => param_xml_object, Err(_) => None, } @@ -1714,10 +1720,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_object_param: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_object_param) => param_object_param, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) diff --git a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs index e27cc1ed58c6..d922ae3966f6 100644 --- a/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ops-v3/src/server/mod.rs @@ -178,7 +178,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } 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 ea3e74c470f2..ff2047c16f40 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 @@ -188,7 +188,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } @@ -268,10 +268,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -377,10 +378,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(_) => None, } @@ -447,10 +449,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(_) => None, } @@ -517,10 +520,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(_) => None, } @@ -587,10 +591,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(_) => None, } @@ -766,10 +771,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -840,10 +846,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -1136,10 +1143,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_param: Option> = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_param) => param_param, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -1254,10 +1262,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -1364,10 +1373,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -1803,10 +1813,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -2318,10 +2329,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -2402,10 +2414,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -2475,10 +2488,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option> = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -2548,10 +2562,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option> = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -2927,10 +2942,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_body: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_body) => param_body, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) diff --git a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs index 0657f06dd602..331ede91fd7c 100644 --- a/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/ping-bearer-auth/src/server/mod.rs @@ -70,7 +70,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } 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 3152eb63a364..6d0b342010ac 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 @@ -92,7 +92,7 @@ impl hyper::service::Service for MakeService where } fn call(&mut self, target: Target) -> Self::Future { - futures::future::ok(Service::new( + future::ok(Service::new( self.api_impl.clone(), )) } @@ -237,10 +237,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_nested_response: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_nested_response) => param_nested_response, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -547,10 +548,11 @@ impl hyper::service::Service<(Request, C)> for Service where let mut unused_elements = Vec::new(); let param_value: Option = if !body.is_empty() { let deserializer = &mut serde_json::Deserializer::from_slice(&body); - match serde_ignored::deserialize(deserializer, |path| { - warn!("Ignoring unknown field in body: {}", path); - unused_elements.push(path.to_string()); - }) { + let handle_unknown_field = |path: serde_ignored::Path<'_>| { + warn!("Ignoring unknown field in body: {}", path); + unused_elements.push(path.to_string()); + }; + match serde_ignored::deserialize(deserializer, handle_unknown_field) { Ok(param_value) => param_value, Err(e) => return Ok(Response::builder() .status(StatusCode::BAD_REQUEST)