openapi-generator
openapi-generator copied to clipboard
[BUG][Kotlin] Enum with Int values generated to hold String
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.
Any workaround for this? Or any expectation if this will be fixed?
This also can be reproduced with this openapi file: https://api-docs.jrni.com/v5/swagger/admin.json
(also with openapi-generator 7.2.0 version)
Still happening with 7.5.0
Still happening with 7.9.0