[android] volley socket timeout configurable (#3646)

* [android] volley socket timeout configurable

* Updated Android Volley Petstore sample
This commit is contained in:
sidhantgoyal 2016-08-29 14:01:49 +05:30 committed by wing328
parent d93ef8531b
commit 8dfe230b7c
5 changed files with 24 additions and 12 deletions

View File

@ -2,6 +2,7 @@
package {{invokerPackage}};
import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
@ -486,7 +487,12 @@ public class ApiInvoker {
} else {
request = new PatchRequest(url, headers, null, null, stringRequest, errorListener);
}
}
}
if (request != null) {
request.setRetryPolicy(new DefaultRetryPolicy((int)TimeUnit.SECONDS.toMillis(this.connectionTimeout), DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
return request;
}

View File

@ -116,12 +116,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth
- **Type**: OAuth
@ -131,6 +125,12 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account
- read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation

View File

@ -222,7 +222,7 @@ Name | Type | Description | Notes
### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP request headers

View File

@ -25,6 +25,7 @@
package io.swagger.client;
import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
@ -213,9 +214,9 @@ public class ApiInvoker {
// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>();
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// TODO: comment out below as OAuth does not exist
//INSTANCE.authentications.put("petstore_auth", new OAuth());
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
}
@ -500,7 +501,12 @@ public class ApiInvoker {
} else {
request = new PatchRequest(url, headers, null, null, stringRequest, errorListener);
}
}
}
if (request != null) {
request.setRetryPolicy(new DefaultRetryPolicy((int)TimeUnit.SECONDS.toMillis(this.connectionTimeout), DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
return request;
}

View File

@ -623,7 +623,7 @@ public class PetApi {
// normal form params
}
String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
@ -693,7 +693,7 @@ public class PetApi {
// normal form params
}
String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,