Commit 501e5c6
[kotlin] Add = null default for optional parameters in jvm-ktor and javalin templates (#24556)
* [kotlin] Add = null default for optional parameters in jvm-ktor and javalin templates
Fixes #23100
Several Kotlin templates made optional parameters nullable (Type?) but
did not assign = null as a default value, forcing callers to explicitly
pass null for every optional parameter instead of omitting them.
Updated templates:
- kotlin-client/libraries/jvm-ktor/api.mustache
- kotlin-server/libraries/javalin5/service.mustache
- kotlin-server/libraries/javalin5/serviceImpl.mustache
- kotlin-server/libraries/javalin6/service.mustache
- kotlin-server/libraries/javalin6/serviceImpl.mustache
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* [kotlin] Add `= null` default for optional parameters in jvm-ktor templates and javalin serviceImpls
Expanded test coverage for jvm-ktor optional parameters to verify `= null` defaults in generated code. Updated javalin5 and javalin6 serviceImpl templates to include correct default value assignments.
* [kotlin] Fix nullable Flow types in javalin5 and javalin6 service templates
* Update samples for kotlin jvm-ktor and javalin templates
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* [kotlin] Simplify default value template logic per PR review
Move defaultValue outside required-check since it always applies,
simplify nullable/default patterns in jvm-ktor api.mustache and
javalin5/javalin6 service.mustache templates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* [kotlin] Add default `= null` for optional parameter in `addPet` method
* disabled failing tests
---------
Co-authored-by: Bartłomiej Kozak <b.kozak@avsystem.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Bartłomiej Kozak <bartlomiejkozak@proton.me>1 parent d278939 commit 501e5c6
12 files changed
Lines changed: 38 additions & 21 deletions
File tree
- modules/openapi-generator/src
- main/resources
- kotlin-client/libraries/jvm-ktor
- kotlin-server/libraries
- javalin5
- javalin6
- test/java/org/openapitools/codegen
- kotlin
- validations/oas
- samples
- client/petstore
- kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/apis
- kotlin-jvm-ktor-jackson/src/main/kotlin/org/openapitools/client/apis
- kotlin-jvm-ktor-kotlinx_serialization/src/main/kotlin/org/openapitools/client/apis
- server/petstore
- kotlin-server-required-and-nullable-properties/src/main/kotlin/org/openapitools/server/apis
- kotlin-server
- javalin-6/src/main/kotlin/org/openapitools/server/apis
- javalin/src/main/kotlin/org/openapitools/server/apis
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
105 | 122 | | |
106 | 123 | | |
107 | 124 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
0 commit comments