forked from loafle/openapi-generator-original
Merge branch 'beanval_2549' of https://github.com/jfiala/swagger-codegen into jfiala-beanval_2549
This commit is contained in:
commit
d9de3b540d
@ -1,43 +1,45 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
|
|
||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
import {{invokerPackage}}.ApiException;
|
import {{invokerPackage}}.ApiException;
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Ignore;
|
||||||
{{^fullJavaUtil}}
|
|
||||||
import java.util.ArrayList;
|
{{^fullJavaUtil}}
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
{{/fullJavaUtil}}
|
import java.util.Map;
|
||||||
|
{{/fullJavaUtil}}
|
||||||
/**
|
|
||||||
* API tests for {{classname}}
|
/**
|
||||||
*/
|
* API tests for {{classname}}
|
||||||
public class {{classname}}Test {
|
*/
|
||||||
|
@Ignore
|
||||||
private final {{classname}} api = new {{classname}}();
|
public class {{classname}}Test {
|
||||||
|
|
||||||
{{#operations}}{{#operation}}
|
private final {{classname}} api = new {{classname}}();
|
||||||
/**
|
|
||||||
* {{summary}}
|
{{#operations}}{{#operation}}
|
||||||
*
|
/**
|
||||||
* {{notes}}
|
* {{summary}}
|
||||||
*
|
*
|
||||||
* @throws ApiException
|
* {{notes}}
|
||||||
* if the Api call fails
|
*
|
||||||
*/
|
* @throws ApiException
|
||||||
@Test
|
* if the Api call fails
|
||||||
public void {{operationId}}Test() throws ApiException {
|
*/
|
||||||
{{#allParams}}
|
@Test
|
||||||
{{{dataType}}} {{paramName}} = null;
|
public void {{operationId}}Test() throws ApiException {
|
||||||
{{/allParams}}
|
{{#allParams}}
|
||||||
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{{dataType}}} {{paramName}} = null;
|
||||||
|
{{/allParams}}
|
||||||
// TODO: test validations
|
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
}
|
|
||||||
{{/operation}}{{/operations}}
|
// TODO: test validations
|
||||||
}
|
}
|
||||||
|
{{/operation}}{{/operations}}
|
||||||
|
}
|
||||||
|
@ -1,221 +1,221 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
|
|
||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
import {{invokerPackage}}.ApiCallback;
|
import {{invokerPackage}}.ApiCallback;
|
||||||
import {{invokerPackage}}.ApiClient;
|
import {{invokerPackage}}.ApiClient;
|
||||||
import {{invokerPackage}}.ApiException;
|
import {{invokerPackage}}.ApiException;
|
||||||
import {{invokerPackage}}.ApiResponse;
|
import {{invokerPackage}}.ApiResponse;
|
||||||
import {{invokerPackage}}.Configuration;
|
import {{invokerPackage}}.Configuration;
|
||||||
import {{invokerPackage}}.Pair;
|
import {{invokerPackage}}.Pair;
|
||||||
import {{invokerPackage}}.ProgressRequestBody;
|
import {{invokerPackage}}.ProgressRequestBody;
|
||||||
import {{invokerPackage}}.ProgressResponseBody;
|
import {{invokerPackage}}.ProgressResponseBody;
|
||||||
{{#performBeanValidation}}
|
{{#performBeanValidation}}
|
||||||
import {{invokerPackage}}.BeanValidationException;
|
import {{invokerPackage}}.BeanValidationException;
|
||||||
{{/performBeanValidation}}
|
{{/performBeanValidation}}
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
{{#performBeanValidation}}
|
{{#performBeanValidation}}
|
||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
import javax.validation.Validation;
|
import javax.validation.Validation;
|
||||||
import javax.validation.ValidatorFactory;
|
import javax.validation.ValidatorFactory;
|
||||||
import javax.validation.executable.ExecutableValidator;
|
import javax.validation.executable.ExecutableValidator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
{{/performBeanValidation}}
|
{{/performBeanValidation}}
|
||||||
|
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
{{^fullJavaUtil}}
|
{{^fullJavaUtil}}
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
{{/fullJavaUtil}}
|
{{/fullJavaUtil}}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public class {{classname}} {
|
public class {{classname}} {
|
||||||
private ApiClient {{localVariablePrefix}}apiClient;
|
private ApiClient {{localVariablePrefix}}apiClient;
|
||||||
|
|
||||||
public {{classname}}() {
|
public {{classname}}() {
|
||||||
this(Configuration.getDefaultApiClient());
|
this(Configuration.getDefaultApiClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
public {{classname}}(ApiClient apiClient) {
|
public {{classname}}(ApiClient apiClient) {
|
||||||
this.{{localVariablePrefix}}apiClient = apiClient;
|
this.{{localVariablePrefix}}apiClient = apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiClient getApiClient() {
|
public ApiClient getApiClient() {
|
||||||
return {{localVariablePrefix}}apiClient;
|
return {{localVariablePrefix}}apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApiClient(ApiClient apiClient) {
|
public void setApiClient(ApiClient apiClient) {
|
||||||
this.{{localVariablePrefix}}apiClient = apiClient;
|
this.{{localVariablePrefix}}apiClient = apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/* Build call for {{operationId}} */
|
/* Build call for {{operationId}} */
|
||||||
private com.squareup.okhttp.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
private com.squareup.okhttp.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
|
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
|
||||||
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
|
||||||
|
|
||||||
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();{{#queryParams}}
|
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();{{#queryParams}}
|
||||||
if ({{paramName}} != null)
|
if ({{paramName}} != null)
|
||||||
{{localVariablePrefix}}localVarQueryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));{{/queryParams}}
|
{{localVariablePrefix}}localVarQueryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));{{/queryParams}}
|
||||||
|
|
||||||
{{javaUtilPrefix}}Map<String, String> {{localVariablePrefix}}localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();{{#headerParams}}
|
{{javaUtilPrefix}}Map<String, String> {{localVariablePrefix}}localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();{{#headerParams}}
|
||||||
if ({{paramName}} != null)
|
if ({{paramName}} != null)
|
||||||
{{localVariablePrefix}}localVarHeaderParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{/headerParams}}
|
{{localVariablePrefix}}localVarHeaderParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{/headerParams}}
|
||||||
|
|
||||||
{{javaUtilPrefix}}Map<String, Object> {{localVariablePrefix}}localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();{{#formParams}}
|
{{javaUtilPrefix}}Map<String, Object> {{localVariablePrefix}}localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();{{#formParams}}
|
||||||
if ({{paramName}} != null)
|
if ({{paramName}} != null)
|
||||||
{{localVariablePrefix}}localVarFormParams.put("{{baseName}}", {{paramName}});{{/formParams}}
|
{{localVariablePrefix}}localVarFormParams.put("{{baseName}}", {{paramName}});{{/formParams}}
|
||||||
|
|
||||||
final String[] {{localVariablePrefix}}localVarAccepts = {
|
final String[] {{localVariablePrefix}}localVarAccepts = {
|
||||||
{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||||
};
|
};
|
||||||
final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);
|
final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);
|
||||||
if ({{localVariablePrefix}}localVarAccept != null) {{localVariablePrefix}}localVarHeaderParams.put("Accept", {{localVariablePrefix}}localVarAccept);
|
if ({{localVariablePrefix}}localVarAccept != null) {{localVariablePrefix}}localVarHeaderParams.put("Accept", {{localVariablePrefix}}localVarAccept);
|
||||||
|
|
||||||
final String[] {{localVariablePrefix}}localVarContentTypes = {
|
final String[] {{localVariablePrefix}}localVarContentTypes = {
|
||||||
{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||||
};
|
};
|
||||||
final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);
|
final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);
|
||||||
{{localVariablePrefix}}localVarHeaderParams.put("Content-Type", {{localVariablePrefix}}localVarContentType);
|
{{localVariablePrefix}}localVarHeaderParams.put("Content-Type", {{localVariablePrefix}}localVarContentType);
|
||||||
|
|
||||||
if(progressListener != null) {
|
if(progressListener != null) {
|
||||||
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
|
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
|
||||||
@Override
|
@Override
|
||||||
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
|
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
|
||||||
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
|
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
|
||||||
return originalResponse.newBuilder()
|
return originalResponse.newBuilder()
|
||||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||||
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener);
|
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
@SuppressWarnings("rawtypes")
|
||||||
{{^performBeanValidation}}
|
private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
{{#allParams}}{{#required}}
|
{{^performBeanValidation}}
|
||||||
// verify the required parameter '{{paramName}}' is set
|
{{#allParams}}{{#required}}
|
||||||
if ({{paramName}} == null) {
|
// verify the required parameter '{{paramName}}' is set
|
||||||
throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)");
|
if ({{paramName}} == null) {
|
||||||
}
|
throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)");
|
||||||
{{/required}}{{/allParams}}
|
}
|
||||||
|
{{/required}}{{/allParams}}
|
||||||
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
|
||||||
return {{localVariablePrefix}}call;
|
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
||||||
|
return {{localVariablePrefix}}call;
|
||||||
{{/performBeanValidation}}
|
|
||||||
{{#performBeanValidation}}
|
{{/performBeanValidation}}
|
||||||
try {
|
{{#performBeanValidation}}
|
||||||
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
try {
|
||||||
ExecutableValidator executableValidator = factory.getValidator().forExecutables();
|
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||||
|
ExecutableValidator executableValidator = factory.getValidator().forExecutables();
|
||||||
Object[] parameterValues = { {{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}} };
|
|
||||||
Method method = this.getClass().getMethod("{{operationId}}WithHttpInfo"{{#allParams}}, {{#isListContainer}}java.util.List{{/isListContainer}}{{#isMapContainer}}java.util.Map{{/isMapContainer}}{{^isListContainer}}{{^isMapContainer}}{{{dataType}}}{{/isMapContainer}}{{/isListContainer}}.class{{/allParams}});
|
Object[] parameterValues = { {{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}} };
|
||||||
Set<ConstraintViolation<Object>> violations = executableValidator.validateParameters(this, method,
|
Method method = this.getClass().getMethod("{{operationId}}WithHttpInfo"{{#allParams}}, {{#isListContainer}}java.util.List{{/isListContainer}}{{#isMapContainer}}java.util.Map{{/isMapContainer}}{{^isListContainer}}{{^isMapContainer}}{{{dataType}}}{{/isMapContainer}}{{/isListContainer}}.class{{/allParams}});
|
||||||
parameterValues);
|
Set<ConstraintViolation<{{classname}}>> violations = executableValidator.validateParameters(this, method,
|
||||||
|
parameterValues);
|
||||||
if (violations.size() == 0) {
|
|
||||||
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
if (violations.size() == 0) {
|
||||||
return {{localVariablePrefix}}call;
|
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
||||||
|
return {{localVariablePrefix}}call;
|
||||||
} else {
|
|
||||||
Set<ConstraintViolation<Object>> violationsObj = (Set<ConstraintViolation<Object>>) violations;
|
} else {
|
||||||
throw new BeanValidationException(violationsObj);
|
throw new BeanValidationException((Set) violations);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ApiException(e.getMessage());
|
throw new ApiException(e.getMessage());
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ApiException(e.getMessage());
|
throw new ApiException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/performBeanValidation}}
|
{{/performBeanValidation}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {{summary}}
|
* {{summary}}
|
||||||
* {{notes}}{{#allParams}}
|
* {{notes}}{{#allParams}}
|
||||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}}
|
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}}
|
||||||
* @return {{returnType}}{{/returnType}}
|
* @return {{returnType}}{{/returnType}}
|
||||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
*/
|
*/
|
||||||
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
{{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
return {{localVariablePrefix}}resp.getData();{{/returnType}}
|
return {{localVariablePrefix}}resp.getData();{{/returnType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {{summary}}
|
* {{summary}}
|
||||||
* {{notes}}{{#allParams}}
|
* {{notes}}{{#allParams}}
|
||||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
|
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
|
||||||
* @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
* @return ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
|
||||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||||
*/
|
*/
|
||||||
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
|
||||||
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null, null);
|
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null, null);
|
||||||
{{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
{{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||||
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType);{{/returnType}}{{^returnType}}return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
|
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType);{{/returnType}}{{^returnType}}return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {{summary}} (asynchronously)
|
* {{summary}} (asynchronously)
|
||||||
* {{notes}}{{#allParams}}
|
* {{notes}}{{#allParams}}
|
||||||
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
|
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
|
||||||
* @param callback The callback to be executed when the API call finishes
|
* @param callback The callback to be executed when the API call finishes
|
||||||
* @return The request call
|
* @return The request call
|
||||||
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||||
*/
|
*/
|
||||||
public com.squareup.okhttp.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException {
|
public com.squareup.okhttp.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException {
|
||||||
|
|
||||||
ProgressResponseBody.ProgressListener progressListener = null;
|
ProgressResponseBody.ProgressListener progressListener = null;
|
||||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||||
@Override
|
@Override
|
||||||
public void update(long bytesRead, long contentLength, boolean done) {
|
public void update(long bytesRead, long contentLength, boolean done) {
|
||||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
com.squareup.okhttp.Call {{localVariablePrefix}}call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}progressListener, progressRequestListener);
|
||||||
{{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
{{#returnType}}Type {{localVariablePrefix}}localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
|
||||||
{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType, {{localVariablePrefix}}callback);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}callback);{{/returnType}}
|
{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}localVarReturnType, {{localVariablePrefix}}callback);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.executeAsync({{localVariablePrefix}}call, {{localVariablePrefix}}callback);{{/returnType}}
|
||||||
return {{localVariablePrefix}}call;
|
return {{localVariablePrefix}}call;
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user