fix: parameter appending for number types#21947
Conversation
Updated string and number parameter handling to ensure proper conversion to string before appending.
|
Mentioning committee group based on PR template (thank you in advanced) @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) |
| {{/isNumber}} | ||
| {{#isNumber}} | ||
| {{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}) } | ||
| {{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}.toString()) } |
There was a problem hiding this comment.
thanks for the PR
do we need to do a null check, i.e. {{{paramName}}}?.toString() ?
There was a problem hiding this comment.
Great point, let's add it.
There was a problem hiding this comment.
Ended up adding to to both of the .toString() methods.
|
circleci failure not related to this change. i'll add some tests later thanks for the contribution |
|
I added a test but got errors: can you please take a look ? auto-generated test code: https://github.com/OpenAPITools/openapi-generator/pull/21952/files#diff-0a5b12edfc72d1712f3be5a8c8c1020063d76e2d40fa7fa6be634efeae7524c5R91 Ref PR: #21952 |
|
I included a fix (a06a6ee) in that PR Basically there seems to be no need for --- a/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt
+++ b/samples/client/petstore/kotlin-jvm-ktor-gson/src/main/kotlin/org/openapitools/client/apis/FakeApi.kt
@@ -87,8 +87,8 @@ import java.text.DateFormat
val localVariableBody =
ParametersBuilder().also {
name?.apply { it.append("name", name) }
- status?.apply { it.append("status", status?.toString()) }
- status2?.apply { it.append("status2", status2?.toString()) }
+ status?.apply { it.append("status", status.toString()) }
+ status2?.apply { it.append("status2", status2.toString()) }
}.build()
|
|
I wish I had caught that earlier! Thanks @wing328 for getting this across the finish line 😁 |
* fix: parameter appending for number types Updated string and number parameter handling to ensure proper conversion to string before appending. * Update api.mustache
* fix: parameter appending for number types Updated string and number parameter handling to ensure proper conversion to string before appending. * Update api.mustache
Updated string and number parameter handling to ensure proper conversion to string before appending.
Fixes errors like this:
$ ./gradlew compileKotlin // --snip-- generated-client-code/.../SomeApi.kt:100:50 Type mismatch: inferred type is BigDecimal but String was expectedPR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)