File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/rust
samples/client/petstore/rust
hyper0x/petstore/src/apis Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,15 @@ impl<C: Connect>{{{classname}}} for {{{classname}}}Client<C>
7474 { {/required} }
7575 { {^required} }
7676 if let Some(ref s) = { {{paramName} }} {
77- let query_value = {{#isArray} }s.iter().map(|s| s.to_string()).collect::<Vec <String >>().join(","){ {/isArray} }{ {^isArray} }s.to_string(){ {/isArray} };
77+ {{#isArray} }
78+ let query_value = s.iter().map(|s| s.to_string()).collect::<Vec <String >>().join(",");
79+ { {/isArray} }
80+ { {^isArray} }
81+ let query_value = match serde_json::to_string(s) {
82+ Ok(value) => value,
83+ Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
84+ } ;
85+ { {/isArray} }
7886 req = req.with_query_param("{ {{baseName} }}".to_string(), query_value);
7987 }
8088 { {/required} }
Original file line number Diff line number Diff line change @@ -73,7 +73,15 @@ impl<C: hyper::client::connect::Connect>{{{classname}}} for {{{classname}}}Clien
7373 { {/required} }
7474 { {^required} }
7575 if let Some(ref s) = { {{paramName} }} {
76- let query_value = {{#isArray} }s.iter().map(|s| s.to_string()).collect::<Vec <String >>().join(","){ {/isArray} }{ {^isArray} }s.to_string(){ {/isArray} };
76+ {{#isArray} }
77+ let query_value = s.iter().map(|s| s.to_string()).collect::<Vec <String >>().join(",");
78+ { {/isArray} }
79+ { {^isArray} }
80+ let query_value = match serde_json::to_string(s) {
81+ Ok(value) => value,
82+ Err(e) => return Box::pin(futures::future::err(Error::Serde(e))),
83+ } ;
84+ { {/isArray} }
7785 req = req.with_query_param("{ {{baseName} }}".to_string(), query_value);
7886 }
7987 { {/required} }
Original file line number Diff line number Diff line change @@ -47,7 +47,10 @@ impl<C: Connect>FakeApi for FakeApiClient<C>
4747 let mut req = __internal_request:: Request :: new ( hyper:: Method :: GET , "/fake/user/{user_name}" . to_string ( ) )
4848 ;
4949 if let Some ( ref s) = content {
50- let query_value = s. to_string ( ) ;
50+ let query_value = match serde_json:: to_string ( s) {
51+ Ok ( value) => value,
52+ Err ( e) => return Box :: pin ( futures:: future:: err ( Error :: Serde ( e) ) ) ,
53+ } ;
5154 req = req. with_query_param ( "content" . to_string ( ) , query_value) ;
5255 }
5356 req = req. with_query_param ( "anyType" . to_string ( ) , any_type. to_string ( ) ) ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -46,7 +46,10 @@ impl<C: hyper::client::connect::Connect>FakeApi for FakeApiClient<C>
4646 let mut req = __internal_request:: Request :: new ( hyper:: Method :: GET , "/fake/user/{user_name}" . to_string ( ) )
4747 ;
4848 if let Some ( ref s) = content {
49- let query_value = s. to_string ( ) ;
49+ let query_value = match serde_json:: to_string ( s) {
50+ Ok ( value) => value,
51+ Err ( e) => return Box :: pin ( futures:: future:: err ( Error :: Serde ( e) ) ) ,
52+ } ;
5053 req = req. with_query_param ( "content" . to_string ( ) , query_value) ;
5154 }
5255 req = req. with_query_param ( "anyType" . to_string ( ) , any_type. to_string ( ) ) ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments