File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
modules/openapi-generator/src/main/resources/kotlin-client/infrastructure Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 11package { {packageName} }.infrastructure
22
3+ import com.squareup.moshi.FromJson
4+ import com.squareup.moshi.Moshi
5+ import com.squareup.moshi.ToJson
36import okhttp3.*
47import java.io.File
8+ import java.util.*
59
610open class ApiClient(val baseUrl: String) {
711 companion object {
@@ -51,7 +55,12 @@ open class ApiClient(val baseUrl: String) {
5155 protected inline fun <reified T: Any?> responseBody(body: ResponseBody?, mediaType: String = JsonMediaType): T? {
5256 if(body == null) return null
5357 return when(mediaType) {
54- JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(body.source())
58+ JsonMediaType -> Moshi.Builder().add(object {
59+ @ToJson
60+ fun toJson(uuid: UUID) = uuid.toString()
61+ @FromJson
62+ fun fromJson(s: String) = UUID.fromString(s)
63+ }).build().adapter(T::class.java).fromJson(body.source())
5564 else -> TODO()
5665 }
5766 }
You can’t perform that action at this time.
0 commit comments