Open shadowsheep1 opened 3 years ago
The x-enum-varnames
should also be addressed here https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache and in all other files that bulds enums.
The old plugin version generates an x-enum-varnames
type enum like that instead:
@Serializable
enum class SoftwareTiers {
@SerialName("200")
CASISTICA_GUASTI,
@SerialName("250")
CASISTICA_GUASTI_EDIT,
@SerialName("300")
OFFICINA,
@SerialName("310")
ODL,
@SerialName("350")
WORKSHOP_NET,
@SerialName("400")
REVISIONI,
@SerialName("401")
REGISTRO_REVISIONI,
@SerialName("701")
KROMEDA,
@SerialName("503")
DATA_FULL,
@SerialName("600")
FATTURAZIONE_ITALIA,
@SerialName("900")
COMUNICAZIONI,
@SerialName("410")
SMART,
@SerialName("800")
YAP_LITE,
@SerialName("8888")
ADMIN,
@SerialName("9999")
LANG,
@SerialName("1000")
MAGAZZINO,
@SerialName("6666")
MEZZI_SPECIALI,
@SerialName("7777")
GOMME,
@SerialName("7778")
CONTESTO_GOMME,
@SerialName("1100")
CED,
@SerialName("5555")
PRIMA_NOTA,
@SerialName("11111")
E_TICKET,
@SerialName("21111")
FCA,
@SerialName("22111")
FIRMA;
}
With this setup:
AS Artic Fox 2020.3.1 Patch 2
For enum declaration in the openapi specification like that:
I've found this error:
The integer literal does not conform to the expected type String
I've found a solution changing this file: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
By changing this part:
with this:
By wrapping with double quotes
"
the values of the enum in the value constructor.But I'm not sure if my solution
{{^isString}}{{#isContainer}}"{{/isContainer}}{{/isString}}{{{value}}}{{^isString}}{{#isContainer}}"{{/isContainer}
addresses all the cases or if is semantically right.
It also seems that the above enum doesn't match the specifications, because I'd expect to see an
Int
value constructor, and not aString
one, so a better solution should be to add anInt
constructor and all should work fine.I'm not a mustache template file expert, so I need help choosing the right solution in this case.