We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The generator takes enum values and creates "safe" names to wrap the "raw" values, but is also escaping the values.
This means I am unable to produce the enum values I need, for example:
openapi: 3.0.3 info: title: "manifest" description: "manifest" version: "0.0.1" paths: {} components: schemas: someEnum: type: string enum: - mything/* - mything/1 - mything/2
The enum is generated with:
star("mything/_*"),
such that the value is mything/_* rather than mything/* as desired.
mything/_*
mything/*
This seems very similar to #12457, which was fixed via #12469 but only for that limited case.
I believe the same thing applies to other generators, though I am likely missing the underlying reasoning behind mutating the provided values.
7.1.0
Generated above as kotlin via gradle plugin or cli, eg:
openapi-generator generate -g kotlin -o issue-oas -i ~/tmp/issueOAS.yml
#12457 is similar and "fixed" for that specific case
Do not escape/sanitize quoted enum values, eg
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java index 83843142ae2..9e46d916a4f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java @@ -903,7 +903,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co } else if ("kotlin.Float".equals(datatype)) { return value + "f"; } else { - return "\"" + escapeText(value) + "\""; + return "\"" + value + "\""; } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java index 374d1d08e61..b820edc3384 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/AbstractKotlinCodegenTest.java @@ -60,6 +60,7 @@ public class AbstractKotlinCodegenTest { assertEquals(codegen.toEnumVarName("long Name", null), "long_Name"); assertEquals(codegen.toEnumVarName("1long Name", null), "_1long_Name"); assertEquals(codegen.toEnumVarName("not1long Name", null), "not1long_Name"); + assertEquals(codegen.toEnumVarName("data/*", null), "dataSlashStar"); } @Test public void pascalCaseEnumConverter() { @@ -78,6 +79,7 @@ public class AbstractKotlinCodegenTest { assertEquals(codegen.toEnumValue("5", "kotlin.Float"), "5f"); assertEquals(codegen.toEnumValue("1.0", "kotlin.Float"), "1.0f"); assertEquals(codegen.toEnumValue("data", "Something"), "\"data\""); + assertEquals(codegen.toEnumValue("data/*", "Something"), "\"data/*\""); } private static class P_AbstractKotlinCodegen extends AbstractKotlinCodegen {
The text was updated successfully, but these errors were encountered:
can you please file a PR with the suggested fix when you've time?
Sorry, something went wrong.
Should be fixed in 18305, closing.
No branches or pull requests
Bug Report Checklist
Description
The generator takes enum values and creates "safe" names to wrap the "raw" values, but is also escaping the values.
This means I am unable to produce the enum values I need, for example:
The enum is generated with:
star("mything/_*"),
such that the value is
mything/_*
rather thanmything/*
as desired.This seems very similar to #12457, which was fixed via #12469 but only for that limited case.
I believe the same thing applies to other generators, though I am likely missing the underlying reasoning behind mutating the provided values.
openapi-generator version
7.1.0
OpenAPI declaration file content or url
Generation Details
Generated above as kotlin via gradle plugin or cli, eg:
Steps to reproduce
mything/_*
rather thanmything/*
as desired.Related issues/PRs
#12457 is similar and "fixed" for that specific case
Suggest a fix
Do not escape/sanitize quoted enum values, eg
The text was updated successfully, but these errors were encountered: