I have generated some models using the Open API tool on one of our backend APIs with Swagger. I got the following as the enum definition:
@Serializable
enum class ClientBackgroundState(val value: kotlin.Int) {
@SerialName(value = "0")
NONE(0),
@SerialName(value = "1")
FOREGROUND(1),
@SerialName(value = "2")
BACKGROUND(2);
}
When I use Kotlin Serializer, it serializes the above type into a String like "FOREGROUND" and the Backend API explodes because it wants an Integer.
Is there a way to configure the serializer to convert this enum to an Integer?
ClientBackgroundState
? Istype
set to beinteger
, like this example? What version of the generator are you using? – Radiosonde@SerialName
annotation does. Of course that would still fail if the backend expects an integer. Just trying to understand whether you pinpointed the exact problem correctly; this is suspicious. – Tedford