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

[csharp] masked EnumMember value in modelEnum #8129

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

jages
Copy link
Contributor

@jages jages commented May 3, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

EnumMember Code generated for csharp was unable to compile, because no masking (double quotes) was provided for String literals in the EnumMember Value field.

This is a template change only.

Generated Code before this change:

public enum StatusEnum
        {
            
            /// <summary>
            /// Enum Available for value: available
            /// </summary>
            [EnumMember(Value = available)]
            Available = 1,
            
            /// <summary>
            /// Enum Pending for value: pending
            /// </summary>
            [EnumMember(Value = pending)]
            Pending = 2,
            
            /// <summary>
            /// Enum Sold for value: sold
            /// </summary>
            [EnumMember(Value = sold)]
            Sold = 3
        }

Generated Code after this change:

public enum StatusEnum
        {
            
            /// <summary>
            /// Enum Available for value: available
            /// </summary>
            [EnumMember(Value = "available")]
            Available = 1,
            
            /// <summary>
            /// Enum Pending for value: pending
            /// </summary>
            [EnumMember(Value = "pending")]
            Pending = 2,
            
            /// <summary>
            /// Enum Sold for value: sold
            /// </summary>
            [EnumMember(Value = "sold")]
            Sold = 3
        }

References

Issues:
#7656 , #8027 , #7947

Notification towards technical committee

@mandrean @jimschubert

jages and others added 2 commits May 3, 2018 12:17
@jimschubert
Copy link
Contributor

This looks good. This issue seems to come up every now and again, and gets switched back and forth from quoted to unquoted, causing the templates to change. I wonder if there should be a fix in the post-processing of enums that checks if the enum name is double quoted and remove the double quotes? That's unrelated to this PR, just a general question.

@HugoMario HugoMario merged commit 5d6e370 into swagger-api:master Mar 2, 2021
This was referenced Mar 11, 2021
This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants