forked from loafle/openapi-generator-original
updated camelize function for #567
This commit is contained in:
parent
99271e77ab
commit
0686a91690
@ -1099,6 +1099,21 @@ public class DefaultCodegen {
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// case out dots
|
||||
String[] parts = word.split("\\.");
|
||||
StringBuilder f = new StringBuilder();
|
||||
for(String z : parts) {
|
||||
if(z.length() > 0)
|
||||
f.append(Character.toUpperCase(z.charAt(0))).append(z.substring(1));
|
||||
}
|
||||
word = f.toString();
|
||||
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
word = m.replaceFirst("" + Character.toUpperCase(m.group(1).charAt(0)) + m.group(1).substring(1)/*.toUpperCase()*/);
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// Uppercase the class name.
|
||||
p = Pattern.compile("(\\.?)(\\w)([^\\.]*)$");
|
||||
m = p.matcher(word);
|
||||
|
@ -335,4 +335,15 @@ class JavaModelTest extends FlatSpec with Matchers {
|
||||
vars.get(0).setter should be ("setCreatedAt")
|
||||
vars.get(0).name should be ("createdAt")
|
||||
}
|
||||
|
||||
it should "properly escape names per 567" in {
|
||||
val model = new ModelImpl()
|
||||
.description("a sample model")
|
||||
.property("created-at", new DateTimeProperty())
|
||||
|
||||
val codegen = new JavaClientCodegen()
|
||||
val cm = codegen.fromModel("with.dots", model)
|
||||
val vars = cm.vars
|
||||
cm.classname should be ("WithDots")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user