Skip to content
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

Discussion: .NET enums & OpenAPI model generation #1071

Open
Kwok-he-Chu opened this issue Oct 8, 2024 · 0 comments
Open

Discussion: .NET enums & OpenAPI model generation #1071

Kwok-he-Chu opened this issue Oct 8, 2024 · 0 comments

Comments

@Kwok-he-Chu
Copy link
Contributor

Kwok-he-Chu commented Oct 8, 2024

Describe the bug
When the models are generated using the sdk-automation based on the OpenApi Specifications, the enums fields in C# are assigned their respective integer values based on alphabetical order. This may pose a problem when f.e. developers upgrade the library and have stored it previously as integers.

See also: dotnet/csharplang#2849
The AWS-dotnet SDK, takes a forward compatible approach

When enums are removed, or added, the following happens:

To Reproduce:

Similar enum changes can be found here during the generation process:

Considered options

  • Leave it-as-is with a README notice (see PR)
  • Change all enums to strings
    • Con: Developer will have no any idea what string value it should enter unless it's mentioned in a description/summary or documentation
  • Change all enums to a class that holds a string enum, See branche with a proof-of-concept
    • Con: Classes cannot be parameterized in unittests as constants. If we keep the names the same, we can keep the functionality of the library similar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant