swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.02k stars 6.03k forks source link

Set RetryPolicy in Android Volley library #5744

Open theindra opened 7 years ago

theindra commented 7 years ago

I have a problem that my swagger generated code is executing the requests twice sometimes. I think this is due to the RetryPolicy of the volley library.

Description: https://stackoverflow.com/questions/26264942/android-volley-makes-2-requests-to-the-server-when-retry-policy-is-set-to-0

Now I want to set the RetryPolicy of my swagger generated code with out changing the ApiInvoker-Class everytime after regeneration of the code. Is any possibility to accomplish that?

wing328 commented 7 years ago

@theindra would customizing the Android volley template meet your requirement?

Android Volley templates: https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/android/libraries/volley

Ref: https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-customize-the-template-to-add-headerfooter-to-the-auto-generated-code

theindra commented 7 years ago

Probably... I've never tried adopting a template.

It should be fixed by setting the RetryPolicy of the request at the end of the method createRequest.

wing328 commented 7 years ago

@theindra you can also use the Java Retrofit2 API client instead: https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-generate-an-android-sdk

theindra commented 7 years ago

Adopting the template worked for us. We haven't tried Retrofit2.