-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[csharp] Introducing the enumPropertyNaming
option to the C# Generator
#16981
[csharp] Introducing the enumPropertyNaming
option to the C# Generator
#16981
Conversation
@fujieda thanks for the PR. What about adding an option similar to |
I couldn't find an option to define enum name mappings similar to However, in our projects, our primary goal is not to establish specific name mappings, but rather to exert control over the naming styles of enum names. We have a significant number of enum names within our OpenAPI definitions, over fifty in total. Given this scale, defining individual name mappings for each enum name isn't a practical or feasible approach for us. |
Sorry I wasn't clear. I mean "adding an option" to your requirement (which means the option doesn't exist yet) Thanks for sharing the use cases. I'll review and get back to you. |
...penapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java
Show resolved
Hide resolved
{ "foo-bar", "fooBar", camelCase }, | ||
{ "foo_bar", "fooBar", camelCase }, | ||
{ "foo bar", "fooBar", camelCase }, | ||
{ "FOO-BAR", "fOOBAR", camelCase }, // camelize doesn't support uppercase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will try to fix that in another PR.
LGTM. Let's give it a try. Thanks again for the PR. |
This pull request introduces the
enumPropertyNaming
option to the C# generator. This option, which is currently supported by the Kotlin and TypeScript generators, allows you to control the naming style of enum names.In our projects, we consistently use
UPPER_SNAKE_CASE
for constants in our OpenAPI definitions, and we prefer to maintain this naming style in our C# code. However, the current C# generator changes the enum names by removing the underscores, resulting in enum names likeUPPERSNAKECASE
.While searching for a solution to this problem, I came across the
enumPropertyNaming
option available in the Kotlin and TypeScript generators. To resolve this discrepancy and ensure that our enum naming style remains consistent withUPPER_SNAKE_CASE
, I ported this option to the C# generator.PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@mandrean @shibayan @Blackclaws @lucamazzanti @iBicha