forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/4.3.x' into 5.0.x
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package org.openapitools.client.infrastructure
|
||||
|
||||
import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import java.time.OffsetDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
class OffsetDateTimeAdapter {
|
||||
@ToJson
|
||||
fun toJson(value: OffsetDateTime): String {
|
||||
return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value)
|
||||
}
|
||||
|
||||
@FromJson
|
||||
fun fromJson(value: String): OffsetDateTime {
|
||||
return OffsetDateTime.parse(value, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ object Serializer {
|
||||
@JvmStatic
|
||||
val moshiBuilder: Moshi.Builder = Moshi.Builder()
|
||||
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
|
||||
.add(OffsetDateTimeAdapter())
|
||||
.add(LocalDateTimeAdapter())
|
||||
.add(LocalDateAdapter())
|
||||
.add(UUIDAdapter())
|
||||
|
||||
Reference in New Issue
Block a user