Repository navigation
Commit af3a9f7
[kotlin] fix: explode object query parameters (#24867)
* fix: [kotlin] explode object query parameters in the jvm-okhttp client
A query parameter whose schema is an object and whose style/explode are left at
their defaults — style: form, explode: true — must go on the wire as one
parameter per entry, keyed by the property name alone. The jvm-okhttp client
serialized the whole map with toString() into a single parameter instead
(filter={tld=com, ...}), and a declared map came out as concatenated
Pair.toString()s. The jvm-ktor library already explodes these correctly.
The query building in api.mustache now iterates an exploded map entry by
entry, the same way jvm-ktor does. deepObject and explode: false objects
keep their previous wire format, byte for byte.
The new test fixture covers the four style/explode combinations that decide
the wire format; the test fails without the template change.
No sample changes: no kotlin sample spec declares a free-form or map-typed
query parameter with the default style, the echo api's object query
parameters are all model-typed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CxDNCjqJycKTfzVWg2SeTJ
* fix: [kotlin] skip nulls, repeat collections and append exploded query entries
Follow-up to the review of the exploded object query parameters in the
jvm-okhttp client:
- a null map entry is left out instead of going on the wire as the
literal "null" (Any?.toString() returns "null" rather than throwing)
- a collection value repeats the key once per element instead of being
sent as the collection's toString(); scalar values and elements go
through parameterToString, so dates get the same format as other query
parameters
- an exploded entry named like another query parameter no longer
overwrites it, or gets overwritten by it: the exploded parameters are
now emitted after every declared query parameter and append to an
existing entry, so both values end up on the wire
To place the exploded parameters after the declared ones, the codegen
flags them with x-kotlin-explode-form-object (jvm-okhttp libraries only)
and api.mustache emits them in a second pass; the three duplicated
required/optional/nullable branches of the first version are gone.
deepObject and explode: false parameters are unchanged, and no sample
changes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore: [kotlin] trim the exploded query comment and simplify the entry loop
One comment line above the loop instead of three; the when now only picks
the elements and filterNotNull/parameterToString run once. Drop the
defensive !isModel check, which no other port has: a map-typed parameter
is never isModel. Fix the fixture description, which claimed four
style/explode combinations where it covers three, and retitle the test.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test: [kotlin] keep the shared fixture byte-identical with the other ports
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent aa783ed commit af3a9f7
3 files changed
Lines changed: 68 additions & 0 deletions
File tree
- modules/openapi-generator/src
- main
- java/org/openapitools/codegen/languages
- resources/kotlin-client/libraries/jvm-okhttp
- test/java/org/openapitools/codegen/kotlin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1160 | 1168 | | |
1161 | 1169 | | |
1162 | 1170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| |||
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
254 | 272 | | |
255 | 273 | | |
256 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
256 | 298 | | |
257 | 299 | | |
258 | 300 | | |
| |||
0 commit comments