graphhopper / directions-api-clients

API clients for various languages for the GraphHopper Directions API
https://docs.graphhopper.com/
Apache License 2.0
30 stars 36 forks source link

OkHttp 3 #12

Open devemux86 opened 7 years ago

devemux86 commented 7 years ago

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.

karussell commented 7 years ago

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?

boldtrn commented 7 years ago

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?

karussell commented 7 years ago

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.

devemux86 commented 7 years ago

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

boldtrn commented 7 years ago

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?

devemux86 commented 7 years ago

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.

karussell commented 7 years ago

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 ;)