Skip to content

[kotlin][client] gson complete integration #4332

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

4brunu
Copy link
Contributor

@4brunu 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
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 this to the 4.2.1 milestone Nov 3, 2019
@wing328
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
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we undo this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@wing328 wing328 merged commit 7cf027f into OpenAPITools:master Nov 8, 2019
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)
  ...
@4brunu 4brunu deleted the feature/kotlin-client-gson-complete-integration branch November 25, 2019 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][kotlin][client] incomplete implementation of gson usage
2 participants