-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
After this fix: #21459, when the original string contains a hyphen, surrounded by spaces, the generated enum constant now has three underscores:
"This - string" becomes "THIS___STRING"
Suggested fix: In this file:
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
Replace
modified = value.replaceAll("-", "_");
with:
modified = value.replaceAll(" - ", "_");
modified = value.replaceAll("-", "_");
It could also be that it needs to be fixed on a more fundamental level, because otherwise, there will probably be other edge cases as well.
openapi-generator version
7.15.0