mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
[rust] fix objects as params for hyper
This commit is contained in:
parent
eccf4b0200
commit
b345648e28
@ -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}}
|
||||
|
@ -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}}
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user