Skip to content

Commit 9f051ec

Browse files
authored
[haskell-servant][haskell-yesod] fix specialCharReplacements (#16289)
HaskellServantCodegen and HaskellYesodServerCodegen modify specialCharReplacements by replacing its keys: backslash ("\\") with "\\\\" and "\"" with "\\\"". It seems that those replacements were for using the keys in string literals in the specialChars table in the generated code. However, modifying the keys causes the substitution of those characters in field names not to work, making generated code syntactically invalid. Since the specialChars table has already been removed, we can safely stop modifying the specialCharReplacements.
1 parent d955ff6 commit 9f051ec

2 files changed

Lines changed: 0 additions & 12 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ public HaskellServantCodegen() {
114114
specialCharReplacements.put(">", "GreaterThan");
115115
specialCharReplacements.put("<", "LessThan");
116116

117-
// backslash and double quote need double the escapement for both Java and Haskell
118-
specialCharReplacements.remove("\\");
119-
specialCharReplacements.remove("\"");
120-
specialCharReplacements.put("\\\\", "Back_Slash");
121-
specialCharReplacements.put("\\\"", "Double_Quote");
122-
123117
// set the output folder here
124118
outputFolder = "generated-code/haskell-servant";
125119

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellYesodServerCodegen.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ public HaskellYesodServerCodegen() {
108108
specialCharReplacements.put(">", "GreaterThan");
109109
specialCharReplacements.put("<", "LessThan");
110110

111-
// backslash and double quote need double the escapement for both Java and Haskell
112-
specialCharReplacements.remove("\\");
113-
specialCharReplacements.remove("\"");
114-
specialCharReplacements.put("\\\\", "Back_Slash");
115-
specialCharReplacements.put("\\\"", "Double_Quote");
116-
117111
outputFolder = "generated-code" + File.separator + "haskell-yesod";
118112
apiTemplateFiles.put("api.mustache", ".hs");
119113
apiTestTemplateFiles.put("api_test.mustache", ".hs");

0 commit comments

Comments
 (0)