mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
Fix Java Generator to always generate valid Java variable names
This commit is contained in:
parent
f17654cd96
commit
7bde2ffd6e
@ -41,10 +41,10 @@ public class {{classname}} {
|
||||
{{/requiredParamCount}}
|
||||
|
||||
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
|
||||
queryParams.put("{{paramName}}", String.valueOf({{paramName}}));
|
||||
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
|
||||
{{/queryParams}}
|
||||
|
||||
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}});
|
||||
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
|
||||
{{/headerParams}}
|
||||
|
||||
String contentType = "application/json";
|
||||
@ -68,4 +68,4 @@ public class {{classname}} {
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
|
@ -93,6 +93,11 @@ class BasicJavaGenerator extends BasicGenerator {
|
||||
// file suffix
|
||||
override def fileSuffix = ".java"
|
||||
|
||||
override def toVarName(name: String): String = {
|
||||
val paramName = name.replaceAll("[^a-zA-Z0-9_]","")
|
||||
super.toVarName(paramName)
|
||||
}
|
||||
|
||||
// response classes
|
||||
override def processResponseClass(responseClass: String): Option[String] = {
|
||||
responseClass match {
|
||||
@ -209,4 +214,4 @@ class BasicJavaGenerator extends BasicGenerator {
|
||||
("JsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"),
|
||||
("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"),
|
||||
("pom.mustache", "generated-code/java", "pom.xml"))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user