OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Java] RxJava2CallAdapterFactory should not be used & io.reactivex.Observable / io.reactivex.Completable not imported when useRxJava2: 'false'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
When using useRxJava2: 'false', then the com.squareup.retrofit2:adapter-rxjava2 dependency (and due to & through it transitively its own dependency org.reactivestreams:reactive-streams) are still required - even though they should not be used in the generated code with that configuration.
The reason for that is that the generated ApiClient has an import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory because createDefaultAdapter() does a .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) - which, of course, isn't actually needed when using useRxJava2: 'false'. Similarly, all classes generated into the apiPackage folder always have an import io.reactivex.Observable; and a import io.reactivex.Completable; even though, again, they are not used anywhere with useRxJava2: 'false'.
The templates could thus be improved to skip those lines for users who don't need Rx.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Java templates that generate ApiClient and the classes in the apiPackage, then inspect createDefaultAdapter() and the RxJava imports. Generate a client with useRxJava set to false and verify that the RxJava adapter, Observable, and Completable imports and dependencies are no longer required.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100