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] Rxjava3 support #6998

Merged
merged 7 commits into from
Aug 4, 2020
Merged

Conversation

tgerth
Copy link
Contributor

@tgerth tgerth commented Jul 20, 2020

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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/kotlin*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

similar to PR: #6622 which did the same for Java

@wing328
Copy link
Member

wing328 commented Jul 23, 2020

@tgerth please update the Kotlin samples when you've time

     @PUT("user/{username}")
-    fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Call<Unit>
+    fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Completable
 
 }
Perform git status
On branch pull/6998
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   samples/client/petstore/kotlin-retrofit2-rx3/.openapi-generator/FILES
	modified:   samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt
	modified:   samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt
	modified:   samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt

@tgerth
Copy link
Contributor Author

tgerth commented Jul 23, 2020

@wing328 I'm not sure why 4 files are modified, when I ran ./bin/generate-samples.sh bin/configs/kotlin-jvm-retrofit2* only FILES got updated.

@wing328
Copy link
Member

wing328 commented Jul 24, 2020

I've updated the samples. Let's see if the tests pass.

cc @jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03)

@@ -98,6 +101,10 @@ dependencies {
compile "io.reactivex.rxjava2:rxjava:$rxJava2Version"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
{{/useRxJava2}}
{{#useRxJava3}}
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version"
compile "com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0"
Copy link
Contributor

@4brunu 4brunu Jul 24, 2020

Choose a reason for hiding this comment

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

What if we use the RxJava3 adapter from square com.squareup.retrofit2:adapter-rxjava3?
More info here square/retrofit#3158

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@4brunu When I run ./bin/generate-samples.sh bin/configs/kotlin*now, the samples will delete all rxjava3 code lines, I don't know why.

@@ -32,6 +32,9 @@ import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
{{#useRxJava2}}
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
{{/useRxJava2}}
{{#useRxJava3}}
import hu.akarnokd.rxjava3.retrofit.RxJava3CallAdapterFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

@tgerth since you changed the lib of RxJava3CallAdapterFactory this import it's not correct anymore.
Can you please update it to retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory?

@wing328
Copy link
Member

wing328 commented Jul 30, 2020

If no further feedback, I'll merge this PR over the weekend.

@wing328
Copy link
Member

wing328 commented Aug 4, 2020

I tested it locally but got the following errors:

> Task :compileKotlin
e: /Users/williamcheng/Code/openapi-generator/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt: (121, 130): Unresolved reference: MultipartBody

> Task :compileKotlin FAILED

FAILURE: Build failed with an exception.

Does it work for you locally?

UPDATE: it turns out kotlin-retrofit2 sample has the same issue so it's not related to this PR.

@wing328
Copy link
Member

wing328 commented Aug 4, 2020

I've filed #7121 to fix the missing import issue.

@wing328 wing328 merged commit 66cd0f6 into OpenAPITools:master Aug 4, 2020
@tgerth tgerth deleted the rxjava3-support-kotlin branch August 4, 2020 09:02
jimschubert added a commit that referenced this pull request Aug 12, 2020
* master: (129 commits)
  [typescript-axios] add promise to bearer and oauth tokens (#7132)
  update doc
  [REQ] Added enumClassPrefix option to Go server generation (#7008)
  [Java][jersey2] Add helper methods for oneOf Java classes (#7115)
  [Kotlin][Retrofit2] fix missing import for file (#7121)
  adding handling for epoch dates in javascript ApiClient mustache file (#6497) (#6504)
  update doc
  comment out cpanm in travis
  [Kotlin] Rxjava3 support (#6998)
  [BUG][JAVA] Fix error handling in okhttp-gson async api client (#7089)
  Update to reset httpRepsonse.Body (#6948)
  [php-lumen] Set required PHP version to ^7.2.5 (#6949)
  [contrib][docs] Assert importance of title/description/repro steps (#7103)
  ISSUE-4222: Prevent conflicts with accept(s) local variables in generated Java RestTemplate ApiClient (#7101)
  [bug][core] Copy all attributes (not properties) on composed schemas when flattening models (#7106)
  [core] Add type and format properties to model of inline response (#6153)
  [PowerShell] better publishing workflow (#7114)
  [aspnetcore] Typo issues in docs and generated code (#7094)
  fix http signaure auth in build.sbt (#7110)
  fix for the issue facing spec invlolving arrayschema structure with ref (#6310)
  ...
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.

3 participants