Merge pull request #2716 from wing328/better_naming_pattern_function

Renmae toJSONSchemaPattern to toRegularExpression
This commit is contained in:
wing328 2016-04-27 16:39:34 +08:00
commit 59f9849ca0

View File

@ -328,12 +328,12 @@ public class DefaultCodegen {
}
/**
* Return the JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
* Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
*
* @param pattern the pattern (regular expression)
* @return properly-escaped pattern
*/
public String toJSONSchemaPattern(String pattern) {
public String toRegularExpression(String pattern) {
return escapeText(pattern);
}
@ -1125,7 +1125,7 @@ public class DefaultCodegen {
StringProperty sp = (StringProperty) p;
property.maxLength = sp.getMaxLength();
property.minLength = sp.getMinLength();
property.pattern = toJSONSchemaPattern(sp.getPattern());
property.pattern = toRegularExpression(sp.getPattern());
// check if any validation rule defined
if (property.pattern != null || property.minLength != null || property.maxLength != null)
@ -1828,7 +1828,7 @@ public class DefaultCodegen {
p.exclusiveMinimum = qp.isExclusiveMinimum();
p.maxLength = qp.getMaxLength();
p.minLength = qp.getMinLength();
p.pattern = toJSONSchemaPattern(qp.getPattern());
p.pattern = toRegularExpression(qp.getPattern());
p.maxItems = qp.getMaxItems();
p.minItems = qp.getMinItems();
p.uniqueItems = qp.isUniqueItems();