-
Notifications
You must be signed in to change notification settings - Fork 6k
Add support for async client Retrofit2 in Java Play Framework 2.6 #7664
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
Add support for async client Retrofit2 in Java Play Framework 2.6 #7664
Conversation
Good Job there 👍
I will have a look at this tomorrow. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wasn't that constructor, it was the one below with a parameter :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Well, this client will allow us to use WSClient that is an asynchronous client. A regular java client will be blocking and we will have to set a specific thread pool just for him.
For my curiosity only, what is the use of this client and what is the "link" to play framework.
@JFCote the only connection of ApiClient.java to play! framework is that internally adds callFactory & callAdapterFactory that uses WSClient to discatch api calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have to support each and every version of Play ? This is getting really messy...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, wouldn't Play developers prefer to get scala.concurrent.Future rather than CompletionStage/CompletableFuture ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have merged the play version templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 great work !
I ran mvn test in the folder samples/client/petstore/java/retrofit2-play26 but got the following errors:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /private/tmp/swagger-codegen/samples/client/petstore/java/retrofit2-play26/src/main/java/io/swagger/client/PlayCallFactory.java:[141,56] cannot find symbol
symbol: method setRequestFilter(play.libs.ws.WSRequestFilter)
location: variable wsRequest of type play.libs.ws.WSRequest
[ERROR] /private/tmp/swagger-codegen/samples/client/petstore/java/retrofit2-play26/src/main/java/io/swagger/client/PlayCallFactory.java:[178,36] cannot find symbol
symbol: method getSingleHeader(java.lang.String)
location: variable r of type play.libs.ws.WSResponse
Did you get these errors when running mvn test locally in your machine?
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?
4ba5164 to
949f0e6
Compare
Uh oh!
There was an error while loading. Please reload this page.
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