Bug Report Checklist
Description
Running the generator against a stablediffusion webui on Windows creates invalid escape sequences because its openapi.json includes defaults that are properly escaped, but OpenAPI incorrectly unescapes them.
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i openapi.json -g csharp-netcore --library unityWebRequest --skip-validate-spec
The generator needs to not unescape backslashes and use the default strings literally.
openapi.zip
openapi-generator version
a601002 (HEAD at time of writing)
OpenAPI declaration file content or url
attached
critical section:
"data_dir": {
"title": "Data Dir",
"type": "string",
"description": "base path where all user data is stored",
"default": "C:\\Users\\bberman\\Documents\\stable-diffusion-webui"
},
Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i http://127.0.0.1:7860/openapi.json -g csharp-netcore --library unityWebRequest --skip-validate-spec
Steps to reproduce
- Download the attached zip.
- Unpack it.
- Run the generation command.
Related issues/PRs
(none)
Suggest a fix
{{{defaultValue}}} for strings in csharp-netcore should be verbatim strings (i.e. @"...")
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
index 651a015111b..571061a6587 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
@@ -1121,7 +1121,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
if (p.getDefault() != null) {
String _default = String.valueOf(p.getDefault());
if (p.getEnum() == null) {
- return "\"" + _default + "\"";
+ return "@\"" + _default + "\"";
} else {
// convert to enum var name later in postProcessModels
return _default;
Bug Report Checklist
Description
Running the generator against a stablediffusion webui on Windows creates invalid escape sequences because its openapi.json includes defaults that are properly escaped, but OpenAPI incorrectly unescapes them.
The generator needs to not unescape backslashes and use the default strings literally.
openapi.zip
openapi-generator version
a601002 (HEAD at time of writing)
OpenAPI declaration file content or url
attached
critical section:
Generation Details
Steps to reproduce
Related issues/PRs
(none)
Suggest a fix
{{{defaultValue}}}for strings in csharp-netcore should be verbatim strings (i.e. @"...")