Add support for async client Retrofit2 in Java Play Framework 2.6#7664
Add support for async client Retrofit2 in Java Play Framework 2.6#7664ignaciomolina wants to merge 11 commits intoswagger-api:masterfrom
Conversation
|
Good Job there 👍 |
|
I will have a look at this tomorrow. Thanks |
| // authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} | ||
| // Prevent the authentications from being modified. | ||
| authentications = Collections.unmodifiableMap(authentications); | ||
|
|
| public Play26CallAdapterFactory() { | ||
| } | ||
|
|
||
| public Play26CallAdapterFactory( |
There was a problem hiding this comment.
why is there a carriage return here?
|
@ignaciomolina For my curiosity only, what is the use of this client and what is the "link" to play framework. I'm the main contributor to the Play Framework server stub codegen and to connect to it, we use java client, c# client, typescript client but I would like to know the advantage of using this one. Thanks :) |
|
|
||
| public Play26CallAdapterFactory() { | ||
| } | ||
| public Play26CallAdapterFactory() { } |
There was a problem hiding this comment.
it wasn't that constructor, it was the one below with a parameter :)
|
Well, this client will allow us to use |
@JFCote the only connection of ApiClient.java to play! framework is that internally adds callFactory & callAdapterFactory that uses WSClient to discatch api calls. |
| cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library.")); | ||
| cliOptions.add(CliOption.newBoolean(PARCELABLE_MODEL, "Whether to generate models for Android that implement Parcelable with the okhttp-gson library.")); | ||
| cliOptions.add(CliOption.newBoolean(USE_PLAY_WS, "Use Play! Async HTTP client (Play WS API)")); | ||
| cliOptions.add(CliOption.newString(PLAY_VERSION, "Version of Play! Framework (possible values \"play24\", \"play25\")")); |
There was a problem hiding this comment.
Do we really have to support each and every version of Play ? This is getting really messy...
There was a problem hiding this comment.
Since each change of version of play means that everything changes completly, it is so far necessary to keep all of them...
There was a problem hiding this comment.
This is a retrofit generator, not a Play one. Also it seems to me that a lot of templates are just duplicated between 2.5 and 2.6
There was a problem hiding this comment.
I am glad that the client generator for play is using retrofit.
There is a folder called common where all duplicated templates between versions 2.5 and 2.6 should be. If there is a duplicated template not located there, this PR should be rejected
There was a problem hiding this comment.
I looked and it seems 2.6 is almost entirely duplicate of 2.5 (minor changes but that probably also work for 2.5)
I also think it should be possible to have common templates between 2.4 and 2.5 with minimal work which would greatly simplify the Java generator code.
And 2.5 seems to introduce adapters for CompletionStage (CompletableFuture) which are already part of retrofit-adapters so they could probably be replaced by the built in ones.
There was a problem hiding this comment.
Eventually, wouldn't Play developers prefer to get scala.concurrent.Future rather than CompletionStage/CompletableFuture ?
There was a problem hiding this comment.
Those minor changes don't work on play 2.5 (100% sure)
OK so they should be applied by mustache tags, not by duplicating the templates.
There was a problem hiding this comment.
Meanwhile there are 2 different versions of Play (Scala and Java), we should have an autogenerated client for both versions.
I don't know what could be the reason to program play with java. Moreover, I don't know the reason to program on play at all 🍡
There was a problem hiding this comment.
ok, I have merged the play version templates
|
I ran Did you get these errors when running |
|
Sorry @wing328, you were right, I already fix all the issues and now it compiles fine in Maven, Sbt and Gradle |
|
@wing328 Do you think this is good to merge? |
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). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger
Description of the PR
Add templates to support Play Framework version 2.6 with async clients using Retrofit2