-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Fix Retrofit template with Jackson for Kotlin #14239
Fix Retrofit template with Jackson for Kotlin #14239
Conversation
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.
@jimschubert could you please have a look? Noticed this bug at work yesterday. We've fixed it locally by altering the templates, but I think that it's better to fix it on the generator level.
5dc216b
to
11edd12
Compare
11edd12
to
da0eabf
Compare
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.
@jimschubert after rebasing again on master
all broken CI's have passed. can you please review this small fix? 🙏
@yonatankarp thanks for the PR. Can you please PM me via Slack to discuss this further? https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g |
dc64035
to
d7a1728
Compare
7933f59
to
8719b8b
Compare
bin/configs/kotlin-jvm-jackson.yaml
Outdated
@@ -0,0 +1,9 @@ | |||
generatorName: kotlin | |||
outputDir: samples/client/petstore/kotlin-jvm-jackson | |||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml |
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.
I did a test locally but got the following errors:
➜ kotlin-jvm-jackson git:(fix_retrofit_generator_with_jackson) ✗ gradle build
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileKotlin
e: /Users/williamcheng/gitclone/yonatankarp_fix_retrofit_generator_with_jackson/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (60, 28): Unresolved reference: Builder
e: /Users/williamcheng/gitclone/yonatankarp_fix_retrofit_generator_with_jackson/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (60, 49): Unresolved reference: Builder
e: /Users/williamcheng/gitclone/yonatankarp_fix_retrofit_generator_with_jackson/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (75, 28): Unresolved reference: Builder
e: /Users/williamcheng/gitclone/yonatankarp_fix_retrofit_generator_with_jackson/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt: (75, 49): Unresolved reference: Builder
> Task :compileKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Can you please take a look when you've time?
Also update use 3.0 spec instead: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
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.
Please commit the new sample files as well so that github workflow will trigger the build.
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.
There was indeed a but with my fix - my bad! 🤦♂️
I have fixed it and updated the sample app and the spec version however seems that GitHub Actions
isn't picking the changes yet, and CircleCI
still failing after I have rebased on master
1d4038a
to
c5a64f7
Compare
please ignore the circleci failure for the time being. can you please update the samples? |
c5a64f7
to
07768a7
Compare
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.
@wing328 I have rebased the branch on master
again (seems that previously it was wrongly done as the generator version was 6.3.0-SNAPSHOT
on my branch) and also executed the command:
$ bin/generate-samples.sh bin/configs/kotlin-*
Everything should (hopefully) be up-to-date now, and waiting for approval for GitHub to run the pipeline.
Moreover, the PR was split into 3 different commits to ensure easier review process 😄
07768a7
to
f5a1278
Compare
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
https://github.com/OpenAPITools/openapi-generator/actions/runs/5847743068/job/15854622468?pr=14239 failure can be ignored for the time being. |
This commit amends the `ApiClient` template for Retrofit. It fixes a bug where the Retrofit client uses Jackson as the serialization library. Until now, the `ApiClient` could not be compiled when using the Jackson library (default in SpringBoot applications), as the constructor of the class had the following parameter: `private val serializerBuilder: Builder = Serializer.Builder,` The change done in the commit, is to ensure that in case of Jackson, the right property of the `Serializer` class is assigned
This commit adds a sample code for the `kotlin-jvm-jackson` generated code to test the changes on CI
This commit only runs the command `bin/generate-samples.sh bin/configs/kotlin-*` to ensure that all code samples are up-to-date and CI can pass successfully.
f5a1278
to
0000b7d
Compare
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 a lot for noticing that!
I believe that now the commits are linked to your GitHub account.
To fix #8147
This commit amends the
ApiClient
template for Retrofit. It fixes a bug where the Retrofit client uses Jackson as the serialization library.Until now, the
ApiClient
could not be compiled when using the Jackson library (default in SpringBoot applications), as the constructor of the class had the following parameter:You can see it more clearly here:
After the fix the outcome of this line would be:
The configuration that was used for the test is as follows:
Commits:
All commits would be squashed into a single commit when this PR is approved, and are separated only for easier review process.
The change done in the commit is to ensure that in the case of Jackson, the right property of the
Serializer
class is assignedvalidation of this change was by running the generator and ensuring that code the generated code passed compilation.
PR checklist
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*
.For Windows users, please run the script in Git BASH.
master
(6.3.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks)