Skip to content

[BUG][Kotlin] Enum with Int values generated to hold String #15204

@ivanvasheka-intellias

Description

@ivanvasheka-intellias
openapi-generator version

6.3.0

Source json
"typeIDs": {
          "description": "Ids",
          "type": "array",
          "items": {
            "format": "int32",
            "type": "integer",
            "enum": [
              0,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              19,
              -98
            ]
          }
        }
Generation code
enum class TypeIDs(val value: kotlin.String) {
        @Json(name = "0") _0(0),
        @Json(name = "7") _7(7),
        @Json(name = "8") _8(8),
        @Json(name = "9") _9(9),
        @Json(name = "10") _10(10),
        @Json(name = "11") _11(11),
        @Json(name = "12") _12(12),
        @Json(name = "13") _13(13),
        @Json(name = "14") _14(14),
        @Json(name = "15") _15(15),
        @Json(name = "16") _16(16),
        @Json(name = "19") _19(19),
        @Json(name = "-98") MINUS98(-98);
    }

Generated code has type String in the declaration (enum class TypeIDs(val value: kotlin.String)), however every entry is populated with an Int value (ex. _0(0), and not _0("0")), which results into a compilation error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions