Fix Java Play server generator when path variables aren't camelCase (#6086)

This commit is contained in:
Ximo Guanter
2017-07-17 19:33:52 +02:00
committed by wing328
parent f999936c1d
commit 5aced55075

View File

@@ -10,6 +10,8 @@ import io.swagger.util.Json;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
@@ -264,8 +266,12 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
}
}
if (operation.path.contains("{")) {
operation.path = operation.path.replace("{", ":").replace("}", "");
Pattern pathVariableMatcher = Pattern.compile("\\{(.+)}");
Matcher match = pathVariableMatcher.matcher(operation.path);
while (match.find()) {
String completeMatch = match.group();
String replacement = ":" + camelize(match.group(1), true);
operation.path = operation.path.replace(completeMatch, replacement);
}
if (operation.returnType != null) {