-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Android volley library enhancement and tests #1920
Conversation
…iInvoker from Android Context
About timeout, yes please make it configurable. C#, Ruby, PHP, Java, etc allows developers to set the timeout. |
RE: should it let the request be made and let the server return failure? General speaking, if the authentication setting (e.g. username, password, token, API key,etc) is not passed to the method via Configuration or other ways (e.g. set default header), then the API client (in Ruby, PHP, Java, etc) will still make the request and the server will send back an error (e.g. 401), which will be handled by the API client and throw an Api Exception accordingly. |
To add OAuth support to the Android client, you may want to have a look at at the Java Retrofit client: https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/auth |
For I'm not familiar with petstore.json.org so I'm not sure if it's correct. |
I've added configurable timeout, some fix for apikey check in order to let the request to be sent when no apikey was set. |
Thanks @Shyri I suggest we merge these changes into master now so as to gather feedback from the developers while you're working on the remaining items. |
@wing328 That's fine by me :) |
Android volley library enhancement and tests
Hi! I have added some enhancements to android-volley-library generator. I want to add tests requested in #1839 but I have some questions so I am gonna make a to do list:
I will explain one by one:
Add Synchronous Requests support
The most common usage of Volley is making asynchronous requests with callbacks as there were already in the volley generator, something like:
But there are cases, like in services for instance, where you want to call that request synchronously. I've added this functionality so one can call both the way above or like android-default was:
I've set a 30 seconds timeout, I don't know if this is ok with you. Should I make it configurable?
Improve RequestQueue configuration capabilities
With current version is necessary to provide a
Context
toApiInvoker
initializer so it can build aRequestQueue
based on that Context. I've added to the initializer some parameters to configure the Volley request queue like:ApiInvoker(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery)
. These are passed toRequestQueue
constructor. Default would do something equivalent to:``` java`
HttpStack stack = new HurlStack();
network = new BasicNetwork(stack);
cache = new NoCache();
mRequestQueue = new RequestQueue(cache, network)
as
ResponseDelivery
Unit Tests
I've been testing the petstore.json.orig file. There are some issues: As OAuth2 support is not yet implemented I cannot get it working straight out of the generated code, as it expects to receive some value for auth keys. Is this the correct the correct behaviour? Should the client throw an exception when no authentication was provided but it is specified, like in deletePet
or should it let the request be made and let the server return failure?
Anyway, I've written the PetApiTest both for sync and async apis from a modified json removing oauth and adding apikey authentication in all methods. Once I have this clear I'll make the necessary changes and write the rest of the tests