swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Add support for async client Retrofit2 in Java Play Framework 2.6

Open ignaciomolina opened this issue 7 years ago • 8 comments

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if 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\.
  • [ ] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • [x] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@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

ignaciomolina avatar Feb 15 '18 14:02 ignaciomolina

Good Job there 👍

tzimisce012 avatar Feb 15 '18 15:02 tzimisce012

I will have a look at this tomorrow. Thanks

JFCote avatar Feb 15 '18 18:02 JFCote

@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 :)

JFCote avatar Feb 16 '18 11:02 JFCote

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.

tzimisce012 avatar Feb 16 '18 12:02 tzimisce012

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.

lukoyanov avatar Feb 16 '18 13:02 lukoyanov

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?

wing328 avatar Feb 22 '18 14:02 wing328

Sorry @wing328, you were right, I already fix all the issues and now it compiles fine in Maven, Sbt and Gradle

ignaciomolina avatar Mar 07 '18 19:03 ignaciomolina

@wing328 Do you think this is good to merge?

ignaciomolina avatar Apr 30 '18 08:04 ignaciomolina