diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache index ad0410bc9e4..9c0f7fd314b 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache @@ -74,7 +74,15 @@ impl{{{classname}}} for {{{classname}}}Client {{/required}} {{^required}} if let Some(ref s) = {{{paramName}}} { - let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}}; + {{#isArray}} + let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); + {{/isArray}} + {{^isArray}} + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; + {{/isArray}} req = req.with_query_param("{{{baseName}}}".to_string(), query_value); } {{/required}} diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache index f59705ea7b7..fe1a65c7920 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache @@ -73,7 +73,15 @@ impl{{{classname}}} for {{{classname}}}Clien {{/required}} {{^required}} if let Some(ref s) = {{{paramName}}} { - let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}}; + {{#isArray}} + let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); + {{/isArray}} + {{^isArray}} + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; + {{/isArray}} req = req.with_query_param("{{{baseName}}}".to_string(), query_value); } {{/required}} diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs index 8e422ef9d4b..8247b1b21de 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs @@ -47,7 +47,10 @@ implFakeApi for FakeApiClient let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string()) ; if let Some(ref s) = content { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("content".to_string(), query_value); } req = req.with_query_param("anyType".to_string(), any_type.to_string()); diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs index f6c8e0f0d83..d66d351e01a 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs @@ -118,7 +118,10 @@ implPetApi for PetApiClient let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets/explode".to_string()) ; if let Some(ref s) = page_explode { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("pageExplode".to_string(), query_value); } @@ -130,7 +133,10 @@ implPetApi for PetApiClient let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets".to_string()) ; if let Some(ref s) = page { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("page".to_string(), query_value); } diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs index 099602bb22a..fb74cf88997 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs @@ -46,7 +46,10 @@ implFakeApi for FakeApiClient let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string()) ; if let Some(ref s) = content { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("content".to_string(), query_value); } req = req.with_query_param("anyType".to_string(), any_type.to_string()); diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs index dac261755a9..8c2f35c7ead 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs @@ -117,7 +117,10 @@ implPetApi for PetApiClient let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets/explode".to_string()) ; if let Some(ref s) = page_explode { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("pageExplode".to_string(), query_value); } @@ -129,7 +132,10 @@ implPetApi for PetApiClient let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets".to_string()) ; if let Some(ref s) = page { - let query_value = s.to_string(); + let query_value = match serde_json::to_string(s) { + Ok(value) => value, + Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), + }; req = req.with_query_param("page".to_string(), query_value); }