File tree 3 files changed +24
-9
lines changed
api_generator/src/generator/code_gen/request
3 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 3
3
Cargo.lock
4
4
5
5
.idea
6
+ * .iml
6
7
.vscode /
7
8
* .log
8
9
yaml_test_runner /yaml /
Original file line number Diff line number Diff line change 1
- merge_imports = true
1
+ # Available on rustfmt nightly currently so commented out so that we remember to enable it once stable
2
+ # merge_imports = true
3
+ # normalize_doc_attributes = true
Original file line number Diff line number Diff line change @@ -125,19 +125,31 @@ impl<'a> RequestBuilder<'a> {
125
125
let query_struct_ty = ident ( "QueryParams" ) ;
126
126
let struct_fields = endpoint_params. iter ( ) . map ( |( param_name, param_type) | {
127
127
let field = Self :: create_struct_field ( ( param_name, param_type) ) ;
128
- let field_rename = lit ( param_name ) ;
129
- // TODO: we special case expand_wildcards here to be a list, but this should be fixed upstream
130
- if param_type . ty == TypeKind :: List || param_name == "expand_wildcards" {
131
- let serialize_with = lit ( "crate::client::serialize_coll_qs" ) ;
128
+
129
+ let renamed = field . ident . as_ref ( ) . unwrap ( ) != param_name ;
130
+ let serde_rename = if renamed {
131
+ let field_rename = lit ( param_name ) ;
132
132
quote ! {
133
- #[ serde( rename = #field_rename, serialize_with = #serialize_with) ]
134
- #field
133
+ #[ serde( rename = #field_rename) ]
135
134
}
136
135
} else {
136
+ quote ! ( )
137
+ } ;
138
+
139
+ // TODO: we special case expand_wildcards here to be a list, but this should be fixed upstream
140
+ let expand = param_type. ty == TypeKind :: List || param_name == "expand_wildcards" ;
141
+ let serialize_with = if expand {
137
142
quote ! {
138
- #[ serde( rename = #field_rename) ]
139
- #field
143
+ #[ serde( serialize_with = "crate::client::serialize_coll_qs" ) ]
140
144
}
145
+ } else {
146
+ quote ! ( )
147
+ } ;
148
+
149
+ quote ! {
150
+ #serde_rename
151
+ #serialize_with
152
+ #field
141
153
}
142
154
} ) ;
143
155
You can’t perform that action at this time.
0 commit comments