NSwag Enum generation starts from 0

Viewed 90

I have an Enum declared on a API like this :

 public enum Currencies
    {
        RON = 1,
        USD,
        EUR,
        GBP,
        CHF,
        PLN,
        CAD,
        HUF,
        NOK,
        SEK
    }

but when I use NSwag to generate a HttpClient, it starts from 0 and I obtain this:

public enum Currencies
    {

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

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

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

        [System.Runtime.Serialization.EnumMember(Value = @"GBP")]
        GBP = 3,

        [System.Runtime.Serialization.EnumMember(Value = @"CHF")]
        CHF = 4,

        [System.Runtime.Serialization.EnumMember(Value = @"PLN")]
        PLN = 5,

        [System.Runtime.Serialization.EnumMember(Value = @"CAD")]
        CAD = 6,

        [System.Runtime.Serialization.EnumMember(Value = @"HUF")]
        HUF = 7,

        [System.Runtime.Serialization.EnumMember(Value = @"NOK")]
        NOK = 8,

        [System.Runtime.Serialization.EnumMember(Value = @"SEK")]
        SEK = 9,

    }

the generated one starts from 0, while the initial one stars from 1. This leads to validation problems when I try to call the api. how can I map this ?

0 Answers
Related