Luxoft / gengen

Tool for generating models and Angular services based on OpenAPIs and Swagger's JSON.
MIT License
17 stars 8 forks source link

Wrong sorting when generating enums #47

Closed ddiyteam closed 3 years ago

ddiyteam commented 3 years ago

Describe the bug Wrong sorting when generating enums

To Reproduce gengen ver. 1.0.0-rc.0 openapi.json - openapi v3 version file

Run gengen g --all --file openapi.json --output ./src/generated

enum config from openapi v3 json file

....
"EntityStatus": {
        "enum": [
          0,
          1,
          2,
          3,
          -2,
          -1
        ],
        "type": "integer",
        "format": "int32",
        "x-enumNames": [
          "Candidate",
          "Active",
          "OnProbationPeriod",
          "OnTermination",
          "Canceled",
          "Terminated"
        ]
      },
...

Actual output Result:

export enum EntityStatus {
    Candidate = -1,
    Active = -2,
    OnProbationPeriod = 0,
    OnTermination = 1,
    Canceled = 2,
    Terminated = 3
}

Expected behavior Expected output Result:

export enum EntityStatus {
  Candidate = 0,
  Active = 1,
  OnProbationPeriod = 2,
  OnTermination = 3,
  Canceled = -2,
  Terminated = -1
}