add validation to method parameters

This commit is contained in:
wing328
2016-04-26 00:06:44 +08:00
parent 89703d86b7
commit 354449ebfe
11 changed files with 228 additions and 102 deletions

View File

@@ -121,6 +121,7 @@ public class CodegenParameter {
output.items = this.items;
}
output.vendorExtensions = this.vendorExtensions;
output.hasValidation = this.hasValidation;
output.isBinary = this.isBinary;
output.isByteArray = this.isByteArray;
output.isString = this.isString;

View File

@@ -86,6 +86,7 @@ public class CodegenProperty {
result = prime * result + ((setter == null) ? 0 : setter.hashCode());
result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode());
result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode());
result = prime * result + ((hasValidation == null) ? 0 : hasValidation.hashCode());
result = prime * result + ((isString == null) ? 0 : isString.hashCode());
result = prime * result + ((isInteger == null) ? 0 : isInteger.hashCode());
result = prime * result + ((isLong == null) ? 0 : isLong.hashCode());
@@ -203,12 +204,19 @@ public class CodegenProperty {
if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) {
return false;
}
if (this.vendorExtensions != other.vendorExtensions && (this.vendorExtensions == null || !this.vendorExtensions.equals(other.vendorExtensions))) {
return false;
}
if (this.hasValidation != other.hasValidation && (this.hasValidation == null || !this.hasValidation.equals(other.hasValidation))) {
return false;
}
if (this.isString != other.isString && (this.isString == null || !this.isString.equals(other.isString))) {
return false;
}
if (this.isInteger != other.isInteger && (this.isInteger == null || !this.isInteger.equals(other.isInteger))) {
return false;
}

View File

@@ -1838,7 +1838,10 @@ public class DefaultCodegen {
p.minimum != null || p.exclusiveMinimum != null ||
p.maxLength != null || p.minLength != null ||
p.maxItems != null || p.minItems != null ||
p.pattern != null ||
p.pattern != null) {
p.hasValidation = true;
}
} else {
if (!(param instanceof BodyParameter)) {
LOGGER.error("Cannot use Parameter " + param + " as Body Parameter");