Base solution for your next web application
Open Closed

Exported enums are not accurately reflected in service-proxy.ts #9999


User avatar
0
timmackey created

ANZ v10.0.0

Not sure which organization can fix this, so am reporting the issue here.

On the server the following enum is not accurately exported to typescript.

namespace EnumsLibrary
{
    public enum SeatType
    {
        NoSeat = 0,               // bitfields
        SeatTypeFirst_Seat = 0,
        SeatTypeFirst_Student = 1,
        LeftHanded = 1,
        RightHanded = 2,
        Ambidextrous = 3,
        NoPreference = 3,
        Handicap = 4,
        LastSeatType = 4,
        DefaultProfile = 5,
        Blocked = 6
    }
}

After running 'refresh.bat' in \angular\nswag results in:

export enum SeatType {
    NoSeat = 0,
    SeatTypeFirst_Seat = 1,
    SeatTypeFirst_Student = 2,
    LeftHanded = 3,
    RightHanded = 4,
    Ambidextrous = 5,
    NoPreference = 6,
}

... in service-proxy.ts

This may be due to the disconnect of identifiers and values in 'https://localhost:44301/swagger/v1/swagger.json'

      "SeatType": {
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5,
          6
        ],
        "type": "integer",
        "format": "int32",
        "x-enumNames": [
          "NoSeat",
          "SeatTypeFirst_Seat",
          "SeatTypeFirst_Student",
          "LeftHanded",
          "RightHanded",
          "Ambidextrous",
          "NoPreference",
          "Handicap",
          "LastSeatType",
          "DefaultProfile",
          "Blocked"
        ]
      },

It seems the first 7 values are assigned to the first 7 identifiers.

This was not an issues for ANZ V8.0.0. SeatType was accurately reflected in service-proxy.cs

export enum SeatType {
    NoSeat = 0,
    SeatTypeFirst_Seat = 0,
    SeatTypeFirst_Student = 1,
    LeftHanded = 1,
    RightHanded = 2,
    Ambidextrous = 3,
    NoPreference = 3,
    Handicap = 4,
    LastSeatType = 4,
    DefaultProfile = 5,
    Blocked = 6,
}

... and in swagger.json

     "SeatType": {
        "enum": [
          0,
          0,
          1,
          1,
          2,
          3,
          3,
          4,
          4,
          5,
          6
        ],
        "type": "integer",
        "format": "int32",
        "x-enumNames": [
          "NoSeat",
          "SeatTypeFirst_Seat",
          "SeatTypeFirst_Student",
          "LeftHanded",
          "RightHanded",
          "Ambidextrous",
          "NoPreference",
          "Handicap",
          "LastSeatType",
          "DefaultProfile",
          "Blocked"
        ]
      },

10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Tim,

    This might be related to https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1636. Could you upgrade your Swashbuckle.AspNetCore package to latest version and see if it fixes this ?

    Thanks,

  • User Avatar
    0
    timmackey created

    This problem occurs with the latest Swashbuckle version 5.6.3

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you try downgrading to a version smaller than 5.4 ? If that works, at least we can understand if it is related to Swashbuckle or not.

  • User Avatar
    0
    timmackey created

    SeatType is correct for ANZ version 8.5.0 Swashbuckle 5.2.1

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @timmackey

    So, it seems like this is related to Swashbuckle if you face the same problem with ANZ version 8.5.0 and Swashbuckle > 5.2.1

  • User Avatar
    0
    timmackey created

    Agreed. How will this get resolved?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @timmackey

    Normally, I wouldn't use same value for different enums. If it is not a big problem, I suggest you to refactor it.

  • User Avatar
    0
    timmackey created

    Hi @ismcagdas

    It is a big problem. It's a supported feature of the C# language. As the vendor, why wouldn't you fix something that you, or one or your vendors, broke?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @timmackey

    Unfortunately, we don't have controler over Swashbuckle.AspNetCore library. Otherwise, we would try to offer you a solution. I'm not sure if it is possible to fix this in AspNet Zero side but we will try. Is it possible for you to downgrade Swashbuckle.AspNetCore package at least until this is fixed ?

  • User Avatar
    0
    timmackey created

    Deploying ANZ version 8.1.0. The issue does need to get resolved before I can upgrade beyond ANZ version 8.5.0.