-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
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
Invalid enum var names are generated by multi-byte characters #893
Comments
Double-byte characters are allowed in enum names in OAS v2, v3.
@osjupiter thanks for the details in reporting the issue. I agree with you the existing solution we'd in place won't meet your requirement and I like your idea of using extensions to control the naming of the enum parameter name. Would you have time to contribute a PR to fix the Go or Java client generator as a starting point? (It's late night in Japan so let's resume the conversation over the weekend or on Monday. Have a nice weekend!) |
Thanks for your agreement! |
I send PR! With this extension, users will be able to control names of enum property for more diverse purposes. exmaple EnumProp:
type: string
enum:
- "1"
- "2"
x-enum-varnames:
- ONE
- TWO gererates public enum EnumPropEnum {
ONE("1"), // without extension : _1
TWO("2"); // without extension : _2 Note that this feature affects output of all languages. |
PR #917 is merged |
ABCEnum: Why is this not working??? |
Description
Hi. I have been using openapi-generator with definitions which contains multi-byte characters.
When I wrote enum definitions which names contain only non-word characters(RegExp \W), invalid code generated.
(All of enum names become "_".)
Are double-byte characters not allowed for enum names in OAS ?
If it is valid, I hope these characters will be supported.
generated code
java
go
openapi-generator version
3.2.3-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
just generated
Related issues/PRs
I could not find it.
Suggest a fix/enhancement
I always create a customized config class and add
x-enum-names
extension by overridingpostProcessModelsEnum
andupdateCodegenPropertyEnum
like this.I think it is not good to positively use multi-byte characters as an api parameter.
So it is enough to be able to use it by extension.
Thanks.
The text was updated successfully, but these errors were encountered: