forked from loafle/openapi-generator-original
add function to handle missing delimiter in regex
This commit is contained in:
@@ -542,7 +542,7 @@ public class DefaultCodegen {
|
||||
* @return properly-escaped pattern
|
||||
*/
|
||||
public String toRegularExpression(String pattern) {
|
||||
return escapeText(pattern);
|
||||
return escapeText(addRegularExpressionDelimiter(pattern));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3264,4 +3264,19 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the pattern misses the delimiter, add "/" to the beginning and end
|
||||
* Otherwise, return the original pattern
|
||||
*
|
||||
* @param pattern the pattern (regular expression)
|
||||
* @return the pattern with delimiter
|
||||
*/
|
||||
public String addRegularExpressionDelimiter(String pattern) {
|
||||
if (pattern != null && !pattern.matches("^/.*")) {
|
||||
return "/" + pattern + "/";
|
||||
}
|
||||
|
||||
return pattern;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -727,4 +727,5 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user