File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
modules/openapi-generator/src/main/resources/rust/reqwest Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,13 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
155
155
{ {/isArray} }
156
156
{ {^isArray} }
157
157
{ {^isNullable} }
158
+ { {#isModel} }
159
+ let params = crate::apis::parse_flat_object(&serde_json::to_value({ {{vendorExtensions.x-rust-param-identifier} }})?);
160
+ req_builder = req_builder.query(¶ms);
161
+ { {/isModel} }
162
+ { {^isModel} }
158
163
req_builder = req_builder.query(& [("{ {{baseName} }}", & { {{vendorExtensions.x-rust-param-identifier} }}.to_string())]);
164
+ { {/isModel} }
159
165
{ {/isNullable} }
160
166
{ {#isNullable} }
161
167
{ {#isDeepObject} }
@@ -232,7 +238,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
232
238
req_builder = req_builder.query(& [("{ {{baseName} }}", &serde_json::to_string(param_value)?)]);
233
239
{ {/isObject} }
234
240
{ {#isModel} }
235
- req_builder = req_builder.query(& [("{ {{baseName} }}", &serde_json::to_string(param_value)?)]);
241
+ let params = crate::apis::parse_flat_object(&serde_json::to_value(param_value)?);
242
+ req_builder = req_builder.query(¶ms);
236
243
{ {/isModel} }
237
244
{ {^isObject} }
238
245
{ {^isModel} }
Original file line number Diff line number Diff line change @@ -105,6 +105,33 @@ pub fn urlencode<T: AsRef<str>>(s: T) -> String {
105
105
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
106
106
}
107
107
108
+ pub fn parse_flat_object(value: &serde_json::Value) -> Vec<(String, String)> {
109
+ if let serde_json::Value::Object(object) = value {
110
+ let mut params = vec! [];
111
+
112
+ for (key, value) in object {
113
+ match value {
114
+ serde_json::Value::Object(_) => {
115
+ unreachable! (
116
+ " This should never be reached, there's a bug on the codegen or the templates"
117
+ )
118
+ }
119
+ serde_json::Value::Array(array) => {
120
+ for (i, value) in array.iter().enumerate() {
121
+ params.push((format! (" {key}[{i}]" ), value.to_string()));
122
+ }
123
+ }
124
+ serde_json::Value::String(s) => params.push((key.to_string(), s.clone())),
125
+ _ => params.push((key.to_string(), value.to_string())),
126
+ }
127
+ }
128
+
129
+ return params;
130
+ }
131
+
132
+ unimplemented!("Only objects are supported")
133
+ }
134
+
108
135
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
109
136
if let serde_json::Value::Object(object) = value {
110
137
let mut params = vec! [];
You can’t perform that action at this time.
0 commit comments