forked from loafle/openapi-generator-original
Add class prefix to tag with numbers (#6561)
* add class prefix to tag with numbers, update java to default tag name * update codegen test
This commit is contained in:
@@ -3502,7 +3502,7 @@ public class DefaultCodegen {
|
||||
|
||||
// tag starts with numbers
|
||||
if (tag.matches("^\\d.*")) {
|
||||
tag = "_" + tag;
|
||||
tag = "Class" + tag;
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
||||
@@ -1229,11 +1229,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
additionalProperties.put(propertyKey, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
return camelize(sanitizeName(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the Getter name for boolean property, e.g. isActive
|
||||
*
|
||||
|
||||
@@ -17,11 +17,12 @@ public class CodegenTest {
|
||||
public void sanitizeTagTest() {
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
Assert.assertEquals(codegen.sanitizeTag("foo"), "Foo");
|
||||
Assert.assertEquals(codegen.sanitizeTag("$foo!"), "Foo");
|
||||
Assert.assertEquals(codegen.sanitizeTag("foo bar"), "FooBar");
|
||||
Assert.assertEquals(codegen.sanitizeTag("foo_bar"), "FooBar");
|
||||
Assert.assertEquals(codegen.sanitizeTag("foo1 bar2"), "Foo1Bar2");
|
||||
Assert.assertEquals(codegen.sanitizeTag("foo bar 1"), "FooBar1");
|
||||
Assert.assertEquals(codegen.sanitizeTag("1foo"), "_1foo");
|
||||
Assert.assertEquals(codegen.sanitizeTag("1foo"), "Class1foo");
|
||||
}
|
||||
|
||||
@Test(description = "test camelize")
|
||||
|
||||
Reference in New Issue
Block a user