-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
fix: parameter appending for number types #21947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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) |
@@ -72,7 +72,7 @@ import com.fasterxml.jackson.databind.ObjectMapper | |||
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}.toString()) } | |||
{{/isNumber}} | |||
{{#isNumber}} | |||
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}) } | |||
{{{paramName}}}?.apply { append("{{{baseName}}}", {{{paramName}}}.toString()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR
do we need to do a null check, i.e. {{{paramName}}}?.toString()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, let's add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 😁 |
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 expected
PR 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.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)"fixes #123"
present in the PR description)