[rust] fix objects as params for hyper

This commit is contained in:
Amin Yahyaabadi 2025-05-10 22:47:28 -07:00
parent eccf4b0200
commit b345648e28
6 changed files with 42 additions and 8 deletions

View File

@ -74,7 +74,15 @@ impl<C: Connect>{{{classname}}} for {{{classname}}}Client<C>
{{/required}}
{{^required}}
if let Some(ref s) = {{{paramName}}} {
let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::<Vec<String>>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}};
{{#isArray}}
let query_value = s.iter().map(|s| s.to_string()).collect::<Vec<String>>().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}}

View File

@ -73,7 +73,15 @@ impl<C: hyper::client::connect::Connect>{{{classname}}} for {{{classname}}}Clien
{{/required}}
{{^required}}
if let Some(ref s) = {{{paramName}}} {
let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::<Vec<String>>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}};
{{#isArray}}
let query_value = s.iter().map(|s| s.to_string()).collect::<Vec<String>>().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}}

View File

@ -47,7 +47,10 @@ impl<C: Connect>FakeApi for FakeApiClient<C>
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());

View File

@ -118,7 +118,10 @@ impl<C: Connect>PetApi for PetApiClient<C>
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 @@ impl<C: Connect>PetApi for PetApiClient<C>
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);
}

View File

@ -46,7 +46,10 @@ impl<C: hyper::client::connect::Connect>FakeApi for FakeApiClient<C>
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());

View File

@ -117,7 +117,10 @@ impl<C: hyper::client::connect::Connect>PetApi for PetApiClient<C>
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 @@ impl<C: hyper::client::connect::Connect>PetApi for PetApiClient<C>
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);
}