RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.67k stars 1.23k forks source link

C# autogenerated enum values #4715

Open kkumarkarthik opened 7 months ago

kkumarkarthik commented 7 months ago

Hello,

We are facing issue with enums in the autogenerated c# code.

The origin code contains an enum as below

public enum AccountAction
{
    Enable = 1,
    Disable = 2,
    Close = 3
}

In the auto-generated c# code, the enum starts with 0 instead of 1 as defined in the origin code.

  [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.2.0 (Newtonsoft.Json v13.0.0.0)")]
  public enum AccountAction
  {

      [System.Runtime.Serialization.EnumMember(Value = @"Enable")]
      Enable = 0,

      [System.Runtime.Serialization.EnumMember(Value = @"Disable")]
      Disable = 1,

      [System.Runtime.Serialization.EnumMember(Value = @"Close")]
      Close = 2,

  }

We are using Net 6.0 and NSwag version 13.19.0.

Could you please let me know if it is the expected behavior?

Any input is highly appreciated.