[Java][Retrofit] Add RxJava2 support#4708
Conversation
|
|
||
| cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library.")); | ||
| cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library.")); | ||
| cliOptions.add(CliOption.newBoolean(DO_NOT_USE_RX, "If you do not use RxJava[2], Retrofit's default Call type will be generated instead.")); // setting this to false will have undefined results |
There was a problem hiding this comment.
@ber4444 I suggest we don't expose the option DO_NOT_USE_RX as it should be not set by the users if I understand correctly.
| } | ||
| if (additionalProperties.containsKey(USE_RX_JAVA2)) { | ||
| this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString())); | ||
| } |
There was a problem hiding this comment.
If both USE_RX_JAVA and USE_RX_JAVA2 are incorrectly set to true, maybe it would be a good idea to log a warning/error and only set one of them to true only.
…and v2 are specified
|
@ber4444 I've done some tests and the results look good. Thanks for your contribution. |
|
Actually I discovered some issues. Let me roll back first before working on a fix. |
wing328
left a comment
There was a problem hiding this comment.
Please review and let me know if you need any help fixing the issue.
| </dependency> | ||
| <dependency> | ||
| <groupId>com.jakewharton.retrofit</groupId> | ||
| <artifactId>com.jakewharton.retrofit</artifactId> |
There was a problem hiding this comment.
I think this should be <artifactId>retrofit2-rxjava2-adapter</artifactId> instead.
| } | ||
| if (additionalProperties.containsKey(DO_NOT_USE_RX)) { | ||
| this.setDoNotUseRx(Boolean.valueOf(additionalProperties.get(DO_NOT_USE_RX).toString())); | ||
| } |
There was a problem hiding this comment.
I think these 3 lines can be removed as we no longer allow setting DO_NOT_USE_RX via option.
And after processing all the RX-related option, we will need to update "doNotUseRx" in additionalProperties so that it has a proper value (true or false)
I tested without any RX-related option and got the following compilation errors:
[ERROR] /private/var/tmp/java/useRxJava20/src/main/java/io/swagger/client/api/PetApi.java:[127,3] cannot find symbol
[ERROR] symbol: class Observable
[ERROR] location: interface io.swagger.client.api.PetApi
|
I've discovered 2 minor issues. Please work on those and submit a new PR for the enhancement. |
* 'master' of github.com:swagger-api/swagger-codegen: (40 commits) remove default temp folder during initalization (swagger-api#4749) [Java-retrofit] Fix for swagger-api#4750 String comparison with equals (swagger-api#4751) update java server stub samples with new uuid mapping update java petstore with new uuid mapping [Java-Feign] Fixed String comparison using equals instead of == operator (swagger-api#4740) add SPINEN update jaxrs spec petstore sample (mac) [Jaxrs-spec] fix usage of Jersey templates in shellscript (swagger-api#4722) [Bash] Bash generator improvements (swagger-api#4730) [Java][Issue swagger-api#1806] generate using java.util.UUID for UUIDs Revert "rx2 support" (swagger-api#4737) rx2 support (swagger-api#4708) add https and change order for HPE add Hewlett Packard Enterprise (hpe.com) Add "Simpfony" to list of companies using Swagger (swagger-api#4726) add https://www.slamby.com/ [csharp] Fix enum default value (swagger-api#4681) fix issue swagger-api#4672 - XmlExampleGenerator does not properly handle properties of several numeric types (swagger-api#4673) [JAXRS-CXF] Issue 4569 - Re-added usage of contextPath in api.mustache (basePath) (swagger-api#4580) [Jaxrs-cxf-cdi] merge beanvalidation templates to single one swagger-api#4719 (swagger-api#4723) ...
* master: (40 commits) remove default temp folder during initalization (swagger-api#4749) [Java-retrofit] Fix for swagger-api#4750 String comparison with equals (swagger-api#4751) update java server stub samples with new uuid mapping update java petstore with new uuid mapping [Java-Feign] Fixed String comparison using equals instead of == operator (swagger-api#4740) add SPINEN update jaxrs spec petstore sample (mac) [Jaxrs-spec] fix usage of Jersey templates in shellscript (swagger-api#4722) [Bash] Bash generator improvements (swagger-api#4730) [Java][Issue swagger-api#1806] generate using java.util.UUID for UUIDs Revert "rx2 support" (swagger-api#4737) rx2 support (swagger-api#4708) add https and change order for HPE add Hewlett Packard Enterprise (hpe.com) Add "Simpfony" to list of companies using Swagger (swagger-api#4726) add https://www.slamby.com/ [csharp] Fix enum default value (swagger-api#4681) fix issue swagger-api#4672 - XmlExampleGenerator does not properly handle properties of several numeric types (swagger-api#4673) [JAXRS-CXF] Issue 4569 - Re-added usage of contextPath in api.mustache (basePath) (swagger-api#4580) [Jaxrs-cxf-cdi] merge beanvalidation templates to single one swagger-api#4719 (swagger-api#4723) ...
* rx2 support * NO_NOT_USE_RX is for internal use only; plus sanity check if both v1 and v2 are specified
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.Description of the PR
#4698