forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 5.4.x
This commit is contained in:
@@ -871,6 +871,8 @@ public class ApiClient {
|
||||
} else if (obj instanceof File) {
|
||||
// File body parameter support.
|
||||
return RequestBody.create((File) obj, MediaType.parse(contentType));
|
||||
} else if ("text/plain".equals(contentType) && obj instanceof String) {
|
||||
return RequestBody.create((String) obj, MediaType.parse(contentType));
|
||||
} else if (isJsonMime(contentType)) {
|
||||
String content;
|
||||
if (obj != null) {
|
||||
@@ -1102,8 +1104,8 @@ public class ApiClient {
|
||||
* @return The HTTP call
|
||||
* @throws org.openapitools.client.ApiException If fail to serialize the request body object
|
||||
*/
|
||||
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
|
||||
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
|
||||
public Call buildCall(String baseUrl, String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
|
||||
Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
|
||||
|
||||
return httpClient.newCall(request);
|
||||
}
|
||||
@@ -1124,12 +1126,12 @@ public class ApiClient {
|
||||
* @return The HTTP request
|
||||
* @throws org.openapitools.client.ApiException If fail to serialize the request body object
|
||||
*/
|
||||
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
|
||||
public Request buildRequest(String baseUrl, String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
|
||||
// aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams
|
||||
List<Pair> allQueryParams = new ArrayList<Pair>(queryParams);
|
||||
allQueryParams.addAll(collectionQueryParams);
|
||||
|
||||
final String url = buildUrl(path, queryParams, collectionQueryParams);
|
||||
final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams);
|
||||
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
@@ -1184,9 +1186,13 @@ public class ApiClient {
|
||||
* @param collectionQueryParams The collection query parameters
|
||||
* @return The full URL
|
||||
*/
|
||||
public String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
|
||||
public String buildUrl(String baseUrl, String path, List<Pair> queryParams, List<Pair> collectionQueryParams) {
|
||||
final StringBuilder url = new StringBuilder();
|
||||
url.append(basePath).append(path);
|
||||
if (baseUrl != null) {
|
||||
url.append(baseUrl).append(path);
|
||||
} else {
|
||||
url.append(basePath).append(path);
|
||||
}
|
||||
|
||||
if (queryParams != null && !queryParams.isEmpty()) {
|
||||
// support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
|
||||
@@ -38,6 +38,8 @@ import java.io.InputStream;
|
||||
|
||||
public class PingApi {
|
||||
private ApiClient localVarApiClient;
|
||||
private int localHostIndex;
|
||||
private String localCustomBaseUrl;
|
||||
|
||||
public PingApi() {
|
||||
this(Configuration.getDefaultApiClient());
|
||||
@@ -55,6 +57,22 @@ public class PingApi {
|
||||
this.localVarApiClient = apiClient;
|
||||
}
|
||||
|
||||
public int getHostIndex() {
|
||||
return localHostIndex;
|
||||
}
|
||||
|
||||
public void setHostIndex(int hostIndex) {
|
||||
this.localHostIndex = hostIndex;
|
||||
}
|
||||
|
||||
public String getCustomBaseUrl() {
|
||||
return localCustomBaseUrl;
|
||||
}
|
||||
|
||||
public void setCustomBaseUrl(String customBaseUrl) {
|
||||
this.localCustomBaseUrl = customBaseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build call for postPing
|
||||
* @param someObj (optional)
|
||||
@@ -68,6 +86,20 @@ public class PingApi {
|
||||
</table>
|
||||
*/
|
||||
public okhttp3.Call postPingCall(SomeObj someObj, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
// Determine Base Path to Use
|
||||
if (localCustomBaseUrl != null){
|
||||
basePath = localCustomBaseUrl;
|
||||
} else if ( localBasePaths.length > 0 ) {
|
||||
basePath = localBasePaths[localHostIndex];
|
||||
} else {
|
||||
basePath = null;
|
||||
}
|
||||
|
||||
Object localVarPostBody = someObj;
|
||||
|
||||
// create path and map variables
|
||||
@@ -96,7 +128,7 @@ public class PingApi {
|
||||
}
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||
return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
Reference in New Issue
Block a user