forked from loafle/openapi-generator-original
codegen: add == -> 'Double_Equal' to specialCharReplacements (#19125)
* codegen: add == -> 'Double_Equal' to specialCharReplacements The double equal '==' is a common operator in a few contexts (specific use case for me is haystack operators). Currently if this value appears in an enum its name gets sanitized to empty and generates invalid syntax. Very similar to https://github.com/OpenAPITools/openapi-generator/pull/12801 * makes java underscore test more flexible Given the name and purpose of this test, maybe it is better to test that the generated value is not an underscore rather than to test that it _is_ a specific (and possibly arbitrary) substitute value.
This commit is contained in:
parent
ba056dbf10
commit
005d5b0232
@ -1833,6 +1833,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
specialCharReplacements.put("!=", "Not_Equal");
|
||||
specialCharReplacements.put("<>", "Not_Equal");
|
||||
specialCharReplacements.put("~=", "Tilde_Equal");
|
||||
specialCharReplacements.put("==", "Double_Equal");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,8 +80,8 @@ public class AbstractJavaCodegenTest {
|
||||
*/
|
||||
@Test
|
||||
public void toEnumVarNameShouldNotResultInSingleUnderscore() {
|
||||
Assert.assertEquals(codegen.toEnumVarName(" ", "String"), "SPACE");
|
||||
Assert.assertEquals(codegen.toEnumVarName("==", "String"), "u");
|
||||
Assert.assertNotEquals(codegen.toEnumVarName(" ", "String"), "_");
|
||||
Assert.assertNotEquals(codegen.toEnumVarName("==", "String"), "_");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user