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
@ -6,6 +6,7 @@ import {{invokerPackage}}.ApiException;
|
|||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
{{^fullJavaUtil}}
|
{{^fullJavaUtil}}
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -17,6 +18,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* API tests for {{classname}}
|
* API tests for {{classname}}
|
||||||
*/
|
*/
|
||||||
|
@Ignore
|
||||||
public class {{classname}}Test {
|
public class {{classname}}Test {
|
||||||
|
|
||||||
private final {{classname}} api = new {{classname}}();
|
private final {{classname}} api = new {{classname}}();
|
||||||
@ -35,7 +37,7 @@ public class {{classname}}Test {
|
|||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{{dataType}}} {{paramName}} = null;
|
{{{dataType}}} {{paramName}} = null;
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
// {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
|
|
||||||
// TODO: test validations
|
// TODO: test validations
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ public class {{classname}} {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
private com.squareup.okhttp.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||||
{{^performBeanValidation}}
|
{{^performBeanValidation}}
|
||||||
{{#allParams}}{{#required}}
|
{{#allParams}}{{#required}}
|
||||||
@ -131,7 +132,7 @@ public class {{classname}} {
|
|||||||
|
|
||||||
Object[] parameterValues = { {{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}} };
|
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}});
|
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}});
|
||||||
Set<ConstraintViolation<Object>> violations = executableValidator.validateParameters(this, method,
|
Set<ConstraintViolation<{{classname}}>> violations = executableValidator.validateParameters(this, method,
|
||||||
parameterValues);
|
parameterValues);
|
||||||
|
|
||||||
if (violations.size() == 0) {
|
if (violations.size() == 0) {
|
||||||
@ -139,8 +140,7 @@ public class {{classname}} {
|
|||||||
return {{localVariablePrefix}}call;
|
return {{localVariablePrefix}}call;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Set<ConstraintViolation<Object>> violationsObj = (Set<ConstraintViolation<Object>>) violations;
|
throw new BeanValidationException((Set) violations);
|
||||||
throw new BeanValidationException(violationsObj);
|
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user