Skip to content

Commit 50d3a51

Browse files
committed
applying same fix to hyper
1 parent 44136fb commit 50d3a51

4 files changed

Lines changed: 52 additions & 4 deletions

File tree

modules/openapi-generator/src/main/resources/rust/hyper/api.mustache

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,25 @@ impl<C: Connect>{{{classname}}} for {{{classname}}}Client<C>
7878
let query_value = s.iter().map(|s| s.to_string()).collect::<Vec<String>>().join(",");
7979
{{/isArray}}
8080
{{^isArray}}
81+
{{#isPrimitiveType}}
8182
let query_value = s.to_string();
83+
{{/isPrimitiveType}}
84+
{{^isPrimitiveType}}
85+
{{#isEnum}}
86+
let query_value = s.to_string();
87+
{{/isEnum}}
88+
{{^isEnum}}
89+
{{#isEnumRef}}
90+
let query_value = s.to_string();
91+
{{/isEnumRef}}
92+
{{^isEnumRef}}
93+
let query_value = match serde_json::to_string(s) {
94+
Ok(value) => value,
95+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
96+
};
97+
{{/isEnumRef}}
98+
{{/isEnum}}
99+
{{/isPrimitiveType}}
82100
{{/isArray}}
83101
req = req.with_query_param("{{{baseName}}}".to_string(), query_value);
84102
}

modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,25 @@ impl<C: hyper::client::connect::Connect>{{{classname}}} for {{{classname}}}Clien
7777
let query_value = s.iter().map(|s| s.to_string()).collect::<Vec<String>>().join(",");
7878
{{/isArray}}
7979
{{^isArray}}
80+
{{#isPrimitiveType}}
8081
let query_value = s.to_string();
82+
{{/isPrimitiveType}}
83+
{{^isPrimitiveType}}
84+
{{#isEnum}}
85+
let query_value = s.to_string();
86+
{{/isEnum}}
87+
{{^isEnum}}
88+
{{#isEnumRef}}
89+
let query_value = s.to_string();
90+
{{/isEnumRef}}
91+
{{^isEnumRef}}
92+
let query_value = match serde_json::to_string(s) {
93+
Ok(value) => value,
94+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
95+
};
96+
{{/isEnumRef}}
97+
{{/isEnum}}
98+
{{/isPrimitiveType}}
8199
{{/isArray}}
82100
req = req.with_query_param("{{{baseName}}}".to_string(), query_value);
83101
}

samples/client/petstore/rust/hyper/petstore/src/apis/pet_api.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ impl<C: Connect>PetApi for PetApiClient<C>
118118
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets/explode".to_string())
119119
;
120120
if let Some(ref s) = page_explode {
121-
let query_value = s.to_string();
121+
let query_value = match serde_json::to_string(s) {
122+
Ok(value) => value,
123+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
124+
};
122125
req = req.with_query_param("pageExplode".to_string(), query_value);
123126
}
124127

@@ -130,7 +133,10 @@ impl<C: Connect>PetApi for PetApiClient<C>
130133
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets".to_string())
131134
;
132135
if let Some(ref s) = page {
133-
let query_value = s.to_string();
136+
let query_value = match serde_json::to_string(s) {
137+
Ok(value) => value,
138+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
139+
};
134140
req = req.with_query_param("page".to_string(), query_value);
135141
}
136142

samples/client/petstore/rust/hyper0x/petstore/src/apis/pet_api.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ impl<C: hyper::client::connect::Connect>PetApi for PetApiClient<C>
117117
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets/explode".to_string())
118118
;
119119
if let Some(ref s) = page_explode {
120-
let query_value = s.to_string();
120+
let query_value = match serde_json::to_string(s) {
121+
Ok(value) => value,
122+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
123+
};
121124
req = req.with_query_param("pageExplode".to_string(), query_value);
122125
}
123126

@@ -129,7 +132,10 @@ impl<C: hyper::client::connect::Connect>PetApi for PetApiClient<C>
129132
let mut req = __internal_request::Request::new(hyper::Method::POST, "/pets".to_string())
130133
;
131134
if let Some(ref s) = page {
132-
let query_value = s.to_string();
135+
let query_value = match serde_json::to_string(s) {
136+
Ok(value) => value,
137+
Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
138+
};
133139
req = req.with_query_param("page".to_string(), query_value);
134140
}
135141

0 commit comments

Comments
 (0)