mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Sanitize pipe in var name (#461)
This commit is contained in:
parent
b0cae23777
commit
1d69566cb1
@ -3631,6 +3631,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
// input-name => input_name
|
// input-name => input_name
|
||||||
name = name.replaceAll("-", "_");
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// a|b => a_b
|
||||||
|
name = name.replace("|", "_");
|
||||||
|
|
||||||
// input name and age => input_name_and_age
|
// input name and age => input_name_and_age
|
||||||
name = name.replaceAll(" ", "_");
|
name = name.replaceAll(" ", "_");
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ public class AbstractJavaCodegenTest {
|
|||||||
Assert.assertEquals(fakeJavaCodegen.toVarName("nam$$e"), "nam$$e");
|
Assert.assertEquals(fakeJavaCodegen.toVarName("nam$$e"), "nam$$e");
|
||||||
Assert.assertEquals(fakeJavaCodegen.toVarName("user-name"), "userName");
|
Assert.assertEquals(fakeJavaCodegen.toVarName("user-name"), "userName");
|
||||||
Assert.assertEquals(fakeJavaCodegen.toVarName("user_name"), "userName");
|
Assert.assertEquals(fakeJavaCodegen.toVarName("user_name"), "userName");
|
||||||
|
Assert.assertEquals(fakeJavaCodegen.toVarName("user|name"), "userName");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user