Created by: zoltanwork
We use a legacy REST server that returns a non-empty response even if it the response type is Unit. In this case the following exception is thrown: java.lang.IllegalArgumentException: Platform class kotlin.Unit requires explicit JsonAdapter to be registered at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:76) at com.squareup.moshi.Moshi.adapter(Moshi.java:146) at com.squareup.moshi.Moshi.adapter(Moshi.java:106) at com.squareup.moshi.Moshi.adapter(Moshi.java:75) at com.squareup.moshi._MoshiKotlinExtensionsKt.adapter(-MoshiKotlinExtensions.kt:40) ...
I checked another generator (Java/apache-httpclient) to see how it handles this case. There the Java class of the expected result is checked and the code doesn't call the JSON deserializer if no response is expected.