directions-api-clients icon indicating copy to clipboard operation
directions-api-clients copied to clipboard

OkHttp 3

Open devemux86 opened this issue 8 years ago • 7 comments

Since client-hc uses OkHttp 3, is there a reason why directions-api-clients/java is still with OkHttp 2?

It's a bit inconvenient (specially on Android) to include double similar http libs, if want to use both clients together.

devemux86 avatar Nov 15 '17 20:11 devemux86

Indeed but we just use the automatically created client from swagger. Maybe they released a new version with a more recent okhttp or there is already an issue?

karussell avatar Nov 15 '17 21:11 karussell

I had a look into swagger code gen and they have different library versions available for java:

library
            library template (sub-template) to use (Default: okhttp-gson)
                jersey1 - HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
                feign - HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9
                jersey2 - HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.9
                okhttp-gson - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
                retrofit - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.
                retrofit2 - HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)
                resttemplate - HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.8.9
                resteasy - HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.8.9

If we would choose retrofit2, we would get OkHttp3, but we would also get a different Gson version (not sure if this matters). I just tried that here.

I haven't tested it though, just ran the generation and as usual swagger generates a huge change :).

@devemux86, do you think your issue would be resolved with this update?

BTW: I used Swagger-Codegen 2.2.3, which is still the current stable and it could not find the language R, maybe the current state of this repo was generated with a different version of the swagger codegen?

boldtrn avatar Nov 16 '17 05:11 boldtrn

BTW: I used Swagger-Codegen 2.2.3, which is still the current stable and it could not find the language R, maybe the current state of this repo was generated with a different version of the swagger codegen?

Yeah, it was included recently and had to use master.

karussell avatar Nov 16 '17 06:11 karussell

If understand correctly the generated code, it uses OkHttp 3 and introduces new dependency for Retrofit?

devemux86 avatar Nov 16 '17 07:11 devemux86

If understand correctly the generated code, it uses OkHttp 3 and introduces new dependency for Retrofit?

Yes :). Probably also not a good solution for Android?

boldtrn avatar Nov 20 '17 04:11 boldtrn

Probably also not a good solution for Android?

At least would have same OkHttp 3 version. :slightly_smiling_face: BTW the old one mentions Retrofit too, though not required in client.

devemux86 avatar Nov 20 '17 08:11 devemux86

The simplest would be to create a PR at swagger codegen, they usually merge fast and this does not sound like a big change. Or at least create an issue there ;)

karussell avatar Nov 20 '17 11:11 karussell