You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple json as this one {cod_state_region: "whatever"}, moshi is not able to parse this String to the property in my class. i just read out on moshi, and the correct way to implement the mapping for snake_case and camel case in kotlin is to use the KotlinJsonAdapterFactory class.
At the moment of writing this i am on openapi-generator-maven-plugin V4.0.0 beta 3 and I tested the last release v4.0.0 and the problem is still the same
Description
My suggestion is to change the ApiClient mustache.
This method
protected inline fun <reified T: Any?> responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? {
if(body == null) {
return null
}
val bodyContent = body.string()
if (bodyContent.length == 0) {
return null
}
return when(mediaType) {
JsonMediaType -> Moshi.Builder().add(object {
@ToJson
fun toJson(uuid: UUID) = uuid.toString()
@FromJson
fun fromJson(s: String) = UUID.fromString(s)
})
//.add(ByteArrayAdapter())
.build().adapter(T::class.java).fromJson(bodyContent)
else -> TODO("responseBody currently only supports JSON body.")
}
}
Bug
A simple json as this one {cod_state_region: "whatever"}, moshi is not able to parse this String to the property in my class. i just read out on moshi, and the correct way to implement the mapping for snake_case and camel case in kotlin is to use the KotlinJsonAdapterFactory class.
At the moment of writing this i am on openapi-generator-maven-plugin V4.0.0 beta 3 and I tested the last release v4.0.0 and the problem is still the same
Description
My suggestion is to change the ApiClient mustache.
This method
Into this method:
The text was updated successfully, but these errors were encountered: