Skip to content
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

[kotlin][client] gson complete integration #4332

Conversation

@4brunu
Copy link
Contributor

4brunu commented Oct 30, 2019

The kotlin client generator, has an option to choose gson as the serialization library, but this only affects the models, the ApiClient still uses Moshi despite choosing gson.
This PR propagates the gson usage to everywhere when it's the choosen serialization library.
It fixes #4331.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10)

@auto-labeler

This comment has been minimized.

Copy link

auto-labeler bot commented Oct 30, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@wing328 wing328 added the Issue: Bug label Nov 3, 2019
@wing328 wing328 added this to the 4.2.1 milestone Nov 3, 2019
@wing328

This comment has been minimized.

Copy link
Member

wing328 commented Nov 3, 2019

I ran gradle test with the kotlin-client-gson client and got the following errors:

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :compileKotlin
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt: (6, 12): Unresolved reference: json
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt: (24, 13): Unresolved reference: JSONObject
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt: (6, 12): Unresolved reference: json
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt: (28, 13): Unresolved reference: JSONObject
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt: (6, 12): Unresolved reference: json
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt: (26, 13): Unresolved reference: JSONObject
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt: (6, 12): Unresolved reference: json
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt: (26, 13): Unresolved reference: JSONObject
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt: (6, 12): Unresolved reference: json
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt: (25, 13): Unresolved reference: NULL

> Task :compileKotlin FAILED

FAILURE: Build failed with an exception.

Does it work for you locally?

@wing328

This comment has been minimized.

Copy link
Member

wing328 commented Nov 3, 2019

Can you please add an entry below https://github.com/OpenAPITools/openapi-generator/blob/master/pom.xml#L1253 to test the kotlin-client-gson samples÷

4brunu added 20 commits Nov 3, 2019
…-client-gson-complete-integration
@4brunu

This comment has been minimized.

Copy link
Contributor Author

4brunu commented Nov 7, 2019

@wing328 the tests are now passing in the CI server.
Can you please review this PR?
Thanks 👍

@@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-okhttp3 --library jvm-okhttp3 -o samples/client/petstore/kotlin-okhttp3 $@"

java ${JAVA_OPTS} -jar ${executable} ${ags}

#cp CI/samples.ci/client/petstore/kotlin-okhttp3/pom.xml samples/client/petstore/kotlin-okhttp3/pom.xml

This comment has been minimized.

Copy link
@wing328

wing328 Nov 8, 2019

Member

Shall we undo this change?

@@ -30,5 +30,3 @@ export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/kotlin-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g kotlin --artifact-id kotlin-petstore-nonpublic --additional-properties nonPublicApi=true -o samples/client/petstore/kotlin-nonpublic $@"

java ${JAVA_OPTS} -jar ${executable} ${ags}

cp CI/samples.ci/client/petstore/kotlin-string/pom.xml samples/client/petstore/kotlin-string/pom.xml

This comment has been minimized.

Copy link
@wing328

wing328 Nov 8, 2019

Member

Shall we undo this change?

This comment has been minimized.

Copy link
@wing328

wing328 Nov 8, 2019

Member

No worry. I'l update those in another PR.

@@ -46,5 +46,5 @@ dependencies {
{{#threetenbp}}
compile "org.threeten:threetenbp:1.4.0"
{{/threetenbp}}
testCompile "io.kotlintest:kotlintest-runner-junit5:3.4.2"
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.0"

This comment has been minimized.

Copy link
@wing328

wing328 Nov 8, 2019

Member

@4brunu so downgrading the version actually fixes the issue...

This comment has been minimized.

Copy link
@4brunu

4brunu Nov 8, 2019

Author Contributor

Yes

@wing328 wing328 merged commit 7cf027f into OpenAPITools:master Nov 8, 2019
5 checks passed
5 checks passed
Shippable Run 11900 status is SUCCESS.
Details
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/drone/pr Build is passing
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jimschubert added a commit to jimschubert/openapi-generator that referenced this pull request Nov 10, 2019
* master: (28 commits)
  [meta] Support Kotlin meta generator (OpenAPITools#4156)
  [Go][Server] minor enhancement to the template (OpenAPITools#4417)
  Replace the old ResourceSupport (OpenAPITools#4426)
  [Core, Rust Server, ASP.NET Core] Fix Codegen Operation Scope Consistency (OpenAPITools#3495)
  Add Go Server featureCORS option (OpenAPITools#4400)
  Fix treatment of nullable types in a few more places (OpenAPITools#4315)
  prefix local variable with localVar (OpenAPITools#4402)
  [kotlin][client] gson complete integration (OpenAPITools#4332)
  [kotlin] [bugfix] [maven-plugin]: prevent ClassCastException with boolean config options (OpenAPITools#4361)
  add sbt, bazel to integration (OpenAPITools#4416)
  Add a blog post tutorial about generating Java clients using OpenAPI v3 (OpenAPITools#4405)
  add freshcells to company list (OpenAPITools#4414)
  Update isSet when the object is received from callback. (OpenAPITools#4385)
  Ruby client nullable (OpenAPITools#4391)
  Fixes Kotlin client property names that include a dollar sign for template override (OpenAPITools#4351)
  [Python] [Performance] Avoid unnessacary checks inside the loop (OpenAPITools#4305)
  Add QEDIT as a company that's using OpenAPI Generator (OpenAPITools#4392)
  update cpp flag for pistache (OpenAPITools#4386)
  Feature optional emit default values (OpenAPITools#4347)
  skip the test as async call may have finished (OpenAPITools#4377)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.