diff --git a/bin/windows/kotlin-client-string.bat b/bin/windows/kotlin-client-string.bat
index f393eedf8f6..6e0310ecadf 100644
--- a/bin/windows/kotlin-client-string.bat
+++ b/bin/windows/kotlin-client-string.bat
@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
-set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --artifact-id "kotlin-petstore-string" --additional-properties dateLibrary=string,serializableModel=true -o samples\client\petstore\kotlin-string
+set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin --artifact-id "kotlin-petstore-string" --additional-properties dateLibrary=string,serializableModel=true,sortParamsByRequiredFlag=false,sortModelPropertiesByRequiredFlag=false -o samples\client\petstore\kotlin-string
java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/docs/generators/kotlin.md b/docs/generators/kotlin.md
index f5771c07492..5c8f71e6792 100644
--- a/docs/generators/kotlin.md
+++ b/docs/generators/kotlin.md
@@ -18,7 +18,7 @@ sidebar_label: kotlin
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |null|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |null|
|modelMutable|Create mutable models| |false|
-|dateLibrary|Option. Date library to use|
- **string**
- String
- **java8**
- Java 8 native JSR310 (jvm only)
- **threetenbp**
- Threetenbp (jvm only)
|java8|
+|dateLibrary|Option. Date library to use|- **threetenbp-localdatetime**
- Threetenbp - Backport of JSR310 (jvm only, for legacy app only)
- **string**
- String
- **java8-localdatetime**
- Java 8 native JSR310 (jvm only, for legacy app only)
- **java8**
- Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)
- **threetenbp**
- Threetenbp - Backport of JSR310 (jvm only, preferred for jdk < 1.8)
|java8|
|collectionType|Option. Collection type to use|- **array**
- kotlin.Array
- **list**
- kotlin.collections.List
|array|
|library|Library template (sub-template) to use|- **jvm-okhttp4**
- [DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.
- **jvm-okhttp3**
- Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.
- **jvm-retrofit2**
- Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.
- **multiplatform**
- Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.
|jvm-okhttp4|
|requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|- **toJson**
- Date formater option using a json converter.
- **toString**
- [DEFAULT] Use the 'toString'-method of the date-time object to retrieve the related string representation.
|toString|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
index 363a76928cb..85bffe3f058 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
@@ -56,7 +56,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
public enum DateLibrary {
STRING("string"),
THREETENBP("threetenbp"),
- JAVA8("java8");
+ THREETENBP_LOCALDATETIME("threetenbp-localdatetime"),
+ JAVA8("java8"),
+ JAVA8_LOCALDATETIME("java8-localdatetime");
public final String value;
@@ -111,9 +113,11 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
Map dateOptions = new HashMap<>();
- dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp (jvm only)");
+ dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp - Backport of JSR310 (jvm only, preferred for jdk < 1.8)");
+ dateOptions.put(DateLibrary.THREETENBP_LOCALDATETIME.value, "Threetenbp - Backport of JSR310 (jvm only, for legacy app only)");
dateOptions.put(DateLibrary.STRING.value, "String");
- dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only)");
+ dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)");
+ dateOptions.put(DateLibrary.JAVA8_LOCALDATETIME.value, "Java 8 native JSR310 (jvm only, for legacy app only)");
dateLibrary.setEnum(dateOptions);
dateLibrary.setDefault(this.dateLibrary);
cliOptions.add(dateLibrary);
@@ -222,19 +226,12 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
private void processDateLibrary() {
- DateLibrary dateLibraryEnum = DateLibrary.valueOf(dateLibrary.toUpperCase(Locale.ROOT));
- switch (dateLibraryEnum) {
- case THREETENBP:
- processThreeTeBpDate();
- break;
- case STRING:
- processStringDate();
- break;
- case JAVA8:
- processJava8Date();
- break;
- default:
- break;
+ if (DateLibrary.THREETENBP.value.equals(dateLibrary) || DateLibrary.THREETENBP_LOCALDATETIME.value.equals(dateLibrary)) {
+ processThreeTeBpDate(dateLibrary);
+ } else if (DateLibrary.STRING.value.equals(dateLibrary)) {
+ processStringDate();
+ } else if (DateLibrary.JAVA8.value.equals(dateLibrary) || DateLibrary.JAVA8_LOCALDATETIME.value.equals(dateLibrary)) {
+ processJava8Date(dateLibrary);
}
}
@@ -246,14 +243,23 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
}
- private void processThreeTeBpDate() {
+ private void processThreeTeBpDate(String dateLibrary) {
additionalProperties.put(DateLibrary.THREETENBP.value, true);
typeMapping.put("date", "LocalDate");
- typeMapping.put("DateTime", "LocalDateTime");
importMapping.put("LocalDate", "org.threeten.bp.LocalDate");
- importMapping.put("LocalDateTime", "org.threeten.bp.LocalDateTime");
defaultIncludes.add("org.threeten.bp.LocalDate");
- defaultIncludes.add("org.threeten.bp.LocalDateTime");
+
+ if (dateLibrary.equals(DateLibrary.THREETENBP.value)) {
+ typeMapping.put("date-time", "org.threeten.bp.OffsetDateTime");
+ typeMapping.put("DateTime", "OffsetDateTime");
+ importMapping.put("OffsetDateTime", "org.threeten.bp.OffsetDateTime");
+ defaultIncludes.add("org.threeten.bp.OffsetDateTime");
+ } else if (dateLibrary.equals(DateLibrary.THREETENBP_LOCALDATETIME.value)) {
+ typeMapping.put("date-time", "org.threeten.bp.LocalDateTime");
+ typeMapping.put("DateTime", "LocalDateTime");
+ importMapping.put("LocalDateTime", "org.threeten.bp.LocalDateTime");
+ defaultIncludes.add("org.threeten.bp.LocalDateTime");
+ }
}
private void processStringDate() {
@@ -263,8 +269,18 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
typeMapping.put("DateTime", "kotlin.String");
}
- private void processJava8Date() {
+ private void processJava8Date(String dateLibrary) {
additionalProperties.put(DateLibrary.JAVA8.value, true);
+
+ if (dateLibrary.equals(DateLibrary.JAVA8.value)) {
+ typeMapping.put("date-time", "java.time.OffsetDateTime");
+ typeMapping.put("DateTime", "OffsetDateTime");
+ importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
+ } else if (dateLibrary.equals(DateLibrary.JAVA8_LOCALDATETIME.value)) {
+ typeMapping.put("date-time", "java.time.LocalDateTime");
+ typeMapping.put("DateTime", "LocalDateTime");
+ importMapping.put("LocalDateTime", "java.time.LocalDateTime");
+ }
}
private void processJVMRetrofit2Library(String infrastructureFolder) {
@@ -280,7 +296,8 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
-
+ supportingFiles.add(new SupportingFile("jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache", infrastructureFolder, "OffsetDateTimeAdapter.kt"));
+
switch (getSerializationLibrary()) {
case moshi:
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache
new file mode 100644
index 00000000000..fbcd16447ac
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache
@@ -0,0 +1,63 @@
+package {{packageName}}.infrastructure
+
+{{#moshi}}
+import com.squareup.moshi.FromJson
+import com.squareup.moshi.ToJson
+{{/moshi}}
+{{#gson}}
+import com.google.gson.TypeAdapter
+import com.google.gson.stream.JsonReader
+import com.google.gson.stream.JsonWriter
+import com.google.gson.stream.JsonToken.NULL
+import java.io.IOException
+{{/gson}}
+{{^threetenbp}}
+import java.time.OffsetDateTime
+import java.time.format.DateTimeFormatter
+{{/threetenbp}}
+{{#threetenbp}}
+import org.threeten.bp.OffsetDateTime
+import org.threeten.bp.format.DateTimeFormatter
+{{/threetenbp}}
+
+{{#moshi}}
+{{#nonPublicApi}}internal {{/nonPublicApi}}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)
+ }
+
+}
+{{/moshi}}
+{{#gson}}
+{{#nonPublicApi}}internal {{/nonPublicApi}}class OffsetDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME) : TypeAdapter() {
+ @Throws(IOException::class)
+ override fun write(out: JsonWriter?, value: OffsetDateTime?) {
+ if (value == null) {
+ out?.nullValue()
+ } else {
+ out?.value(formatter.format(value))
+ }
+ }
+
+ @Throws(IOException::class)
+ override fun read(out: JsonReader?): OffsetDateTime? {
+ out ?: return null
+
+ when (out.peek()) {
+ NULL -> {
+ out.nextNull()
+ return null
+ }
+ else -> {
+ return OffsetDateTime.parse(out.nextString(), formatter)
+ }
+ }
+ }
+}
+{{/gson}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
index 201db4b9d56..3493dee19aa 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/jvm-common/infrastructure/Serializer.kt.mustache
@@ -13,10 +13,12 @@ import com.google.gson.GsonBuilder
{{^threetenbp}}
import java.time.LocalDate
import java.time.LocalDateTime
+import java.time.OffsetDateTime
{{/threetenbp}}
{{#threetenbp}}
import org.threeten.bp.LocalDate
import org.threeten.bp.LocalDateTime
+import org.threeten.bp.OffsetDateTime
{{/threetenbp}}
import java.util.UUID
{{/gson}}
@@ -27,6 +29,7 @@ import java.util.Date
@JvmStatic
val moshiBuilder: Moshi.Builder = Moshi.Builder()
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
+ .add(OffsetDateTimeAdapter())
.add(LocalDateTimeAdapter())
.add(LocalDateAdapter())
.add(UUIDAdapter())
@@ -44,6 +47,7 @@ import java.util.Date
@JvmStatic
val gsonBuilder: GsonBuilder = GsonBuilder()
.registerTypeAdapter(Date::class.java, DateAdapter())
+ .registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter())
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java
index e85b79367f1..7c77ec9ec12 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java
@@ -66,6 +66,7 @@ public class KotlinClientCodegenModelTest {
public void simpleModelTest() {
final Schema schema = getSimpleSchema();
final DefaultCodegen codegen = new KotlinClientCodegen();
+ codegen.processOpts();
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
codegen.setOpenAPI(openAPI);
@@ -100,10 +101,10 @@ public class KotlinClientCodegenModelTest {
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
- Assert.assertEquals(property3.dataType, "java.time.LocalDateTime");
+ Assert.assertEquals(property3.dataType, "java.time.OffsetDateTime");
Assert.assertEquals(property3.name, "createdAt");
Assert.assertEquals(property3.defaultValue, null);
- Assert.assertEquals(property3.baseType, "java.time.LocalDateTime");
+ Assert.assertEquals(property3.baseType, "java.time.OffsetDateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertFalse(property3.isContainer);
@@ -120,6 +121,30 @@ public class KotlinClientCodegenModelTest {
codegen.setOpenAPI(openAPI);
final CodegenModel cm = codegen.fromModel("sample", schema);
+ final CodegenProperty property3 = cm.vars.get(2);
+ Assert.assertEquals(property3.baseName, "createdAt");
+ Assert.assertEquals(property3.dataType, "org.threeten.bp.OffsetDateTime");
+ Assert.assertEquals(property3.name, "createdAt");
+ Assert.assertEquals(property3.defaultValue, null);
+ Assert.assertEquals(property3.baseType, "org.threeten.bp.OffsetDateTime");
+ Assert.assertFalse(property3.hasMore);
+ Assert.assertFalse(property3.required);
+ Assert.assertFalse(property3.isContainer);
+ }
+
+ @Test(description = "convert a simple model: threetenbp-localdatetime")
+ public void selectDateLibraryAsThreetenbpLocalDateTime() {
+ final Schema schema = getSimpleSchema();
+ final KotlinClientCodegen codegen = new KotlinClientCodegen();
+ String value = KotlinClientCodegen.DateLibrary.THREETENBP_LOCALDATETIME.value;
+ Assert.assertEquals(value, "threetenbp-localdatetime");
+ codegen.setDateLibrary(KotlinClientCodegen.DateLibrary.THREETENBP_LOCALDATETIME.value);
+ codegen.processOpts();
+
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", schema);
+
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
Assert.assertEquals(property3.dataType, "org.threeten.bp.LocalDateTime");
@@ -164,6 +189,30 @@ public class KotlinClientCodegenModelTest {
codegen.setOpenAPI(openAPI);
final CodegenModel cm = codegen.fromModel("sample", schema);
+ final CodegenProperty property3 = cm.vars.get(2);
+ Assert.assertEquals(property3.baseName, "createdAt");
+ Assert.assertEquals(property3.dataType, "java.time.OffsetDateTime");
+ Assert.assertEquals(property3.name, "createdAt");
+ Assert.assertEquals(property3.defaultValue, null);
+ Assert.assertEquals(property3.baseType, "java.time.OffsetDateTime");
+ Assert.assertFalse(property3.hasMore);
+ Assert.assertFalse(property3.required);
+ Assert.assertFalse(property3.isContainer);
+ }
+
+ @Test(description = "convert a simple model: date java8-localdatetime")
+ public void selectDateLibraryAsJava8LocalDateTime() {
+ final Schema schema = getSimpleSchema();
+ final KotlinClientCodegen codegen = new KotlinClientCodegen();
+ String value = KotlinClientCodegen.DateLibrary.JAVA8_LOCALDATETIME.value;
+ Assert.assertEquals(value, "java8-localdatetime");
+ codegen.setDateLibrary(KotlinClientCodegen.DateLibrary.JAVA8_LOCALDATETIME.value);
+ codegen.processOpts();
+
+ OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
+ codegen.setOpenAPI(openAPI);
+ final CodegenModel cm = codegen.fromModel("sample", schema);
+
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
Assert.assertEquals(property3.dataType, "java.time.LocalDateTime");
diff --git a/samples/client/petstore/kotlin-gson/docs/Order.md b/samples/client/petstore/kotlin-gson/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-gson/docs/Order.md
+++ b/samples/client/petstore/kotlin-gson/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..e615135c9cc
--- /dev/null
+++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -0,0 +1,35 @@
+package org.openapitools.client.infrastructure
+
+import com.google.gson.TypeAdapter
+import com.google.gson.stream.JsonReader
+import com.google.gson.stream.JsonWriter
+import com.google.gson.stream.JsonToken.NULL
+import java.io.IOException
+import java.time.OffsetDateTime
+import java.time.format.DateTimeFormatter
+
+class OffsetDateTimeAdapter(private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME) : TypeAdapter() {
+ @Throws(IOException::class)
+ override fun write(out: JsonWriter?, value: OffsetDateTime?) {
+ if (value == null) {
+ out?.nullValue()
+ } else {
+ out?.value(formatter.format(value))
+ }
+ }
+
+ @Throws(IOException::class)
+ override fun read(out: JsonReader?): OffsetDateTime? {
+ out ?: return null
+
+ when (out.peek()) {
+ NULL -> {
+ out.nextNull()
+ return null
+ }
+ else -> {
+ return OffsetDateTime.parse(out.nextString(), formatter)
+ }
+ }
+ }
+}
diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 0461f8a47e9..6465f148553 100644
--- a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -4,6 +4,7 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import java.time.LocalDate
import java.time.LocalDateTime
+import java.time.OffsetDateTime
import java.util.UUID
import java.util.Date
@@ -11,6 +12,7 @@ object Serializer {
@JvmStatic
val gsonBuilder: GsonBuilder = GsonBuilder()
.registerTypeAdapter(Date::class.java, DateAdapter())
+ .registerTypeAdapter(OffsetDateTime::class.java, OffsetDateTimeAdapter())
.registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeAdapter())
.registerTypeAdapter(LocalDate::class.java, LocalDateAdapter())
.registerTypeAdapter(ByteArray::class.java, ByteArrayAdapter())
diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt
index ac55ce97d53..5a33789128b 100644
--- a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ data class Order (
@SerializedName("quantity")
val quantity: kotlin.Int? = null,
@SerializedName("shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@SerializedName("status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-json-request-date/docs/Order.md b/samples/client/petstore/kotlin-json-request-date/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-json-request-date/docs/Order.md
+++ b/samples/client/petstore/kotlin-json-request-date/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-json-request-date/docs/PetApi.md b/samples/client/petstore/kotlin-json-request-date/docs/PetApi.md
index f3b19f26edb..dd70fe9495d 100644
--- a/samples/client/petstore/kotlin-json-request-date/docs/PetApi.md
+++ b/samples/client/petstore/kotlin-json-request-date/docs/PetApi.md
@@ -170,7 +170,7 @@ Get all pets
//import org.openapitools.client.models.*
val apiInstance = PetApi()
-val lastUpdated : java.time.LocalDateTime = 2013-10-20T19:20:30+01:00 // java.time.LocalDateTime | When this endpoint was hit last to help indentify if the client already has the latest copy.
+val lastUpdated : java.time.OffsetDateTime = 2013-10-20T19:20:30+01:00 // java.time.OffsetDateTime | When this endpoint was hit last to help indentify if the client already has the latest copy.
try {
val result : kotlin.Array = apiInstance.getAllPets(lastUpdated)
println(result)
@@ -187,7 +187,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **lastUpdated** | **java.time.LocalDateTime**| When this endpoint was hit last to help indentify if the client already has the latest copy. | [optional]
+ **lastUpdated** | **java.time.OffsetDateTime**| When this endpoint was hit last to help indentify if the client already has the latest copy. | [optional]
### Return type
diff --git a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/apis/PetApi.kt
index 3f70f1a2e20..cb72e1568f3 100644
--- a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/apis/PetApi.kt
+++ b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/apis/PetApi.kt
@@ -164,7 +164,7 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli
*/
@Suppress("UNCHECKED_CAST")
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
- fun getAllPets(lastUpdated: java.time.LocalDateTime?) : kotlin.Array {
+ fun getAllPets(lastUpdated: java.time.OffsetDateTime?) : kotlin.Array {
val localVariableBody: kotlin.Any? = null
val localVariableQuery: MultiValueMap = mutableMapOf>()
.apply {
diff --git a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/models/Order.kt
index bcdb149159b..6bf55feb4ea 100644
--- a/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-json-request-date/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-moshi-codegen/docs/Order.md b/samples/client/petstore/kotlin-moshi-codegen/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-moshi-codegen/docs/Order.md
+++ b/samples/client/petstore/kotlin-moshi-codegen/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 2ea1cde78de..06d9fe0bdc8 100644
--- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -8,6 +8,7 @@ object Serializer {
@JvmStatic
val moshiBuilder: Moshi.Builder = Moshi.Builder()
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
+ .add(OffsetDateTimeAdapter())
.add(LocalDateTimeAdapter())
.add(LocalDateAdapter())
.add(UUIDAdapter())
diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/models/Order.kt
index 34441ed63c5..dd01d68e3f0 100644
--- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -32,7 +32,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-nonpublic/docs/Order.md b/samples/client/petstore/kotlin-nonpublic/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-nonpublic/docs/Order.md
+++ b/samples/client/petstore/kotlin-nonpublic/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..be7703c103d
--- /dev/null
+++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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
+
+internal 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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index ae334fcad26..371e2a7013e 100644
--- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -9,6 +9,7 @@ internal object Serializer {
@JvmStatic
val moshiBuilder: Moshi.Builder = Moshi.Builder()
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe())
+ .add(OffsetDateTimeAdapter())
.add(LocalDateTimeAdapter())
.add(LocalDateAdapter())
.add(UUIDAdapter())
diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/models/Order.kt
index 23ee50a8af9..fcec740e09e 100644
--- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ internal data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-nullable/docs/Order.md b/samples/client/petstore/kotlin-nullable/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-nullable/docs/Order.md
+++ b/samples/client/petstore/kotlin-nullable/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/models/Order.kt
index 47862cfb7b6..452a176c120 100644
--- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -32,7 +32,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-okhttp3/docs/Order.md b/samples/client/petstore/kotlin-okhttp3/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-okhttp3/docs/Order.md
+++ b/samples/client/petstore/kotlin-okhttp3/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Order.kt
index bcdb149159b..6bf55feb4ea 100644
--- a/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-okhttp3/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-retrofit2/docs/Order.md b/samples/client/petstore/kotlin-retrofit2/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin-retrofit2/docs/Order.md
+++ b/samples/client/petstore/kotlin-retrofit2/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/models/Order.kt
index bcdb149159b..6bf55feb4ea 100644
--- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-threetenbp/docs/Order.md b/samples/client/petstore/kotlin-threetenbp/docs/Order.md
index fb2b4ace861..776e0ddc2f0 100644
--- a/samples/client/petstore/kotlin-threetenbp/docs/Order.md
+++ b/samples/client/petstore/kotlin-threetenbp/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**org.threeten.bp.LocalDateTime**](org.threeten.bp.LocalDateTime.md) | | [optional]
+**shipDate** | [**org.threeten.bp.OffsetDateTime**](org.threeten.bp.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..28b3eb3cd70
--- /dev/null
+++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -0,0 +1,19 @@
+package org.openapitools.client.infrastructure
+
+import com.squareup.moshi.FromJson
+import com.squareup.moshi.ToJson
+import org.threeten.bp.OffsetDateTime
+import org.threeten.bp.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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt
index a1e3c6e200d..cb25060ae82 100644
--- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -31,7 +31,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: org.threeten.bp.LocalDateTime? = null,
+ val shipDate: org.threeten.bp.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin/docs/Order.md b/samples/client/petstore/kotlin/docs/Order.md
index ef31dbf2f4f..5112f08958d 100644
--- a/samples/client/petstore/kotlin/docs/Order.md
+++ b/samples/client/petstore/kotlin/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **kotlin.Long** | | [optional]
**petId** | **kotlin.Long** | | [optional]
**quantity** | **kotlin.Int** | | [optional]
-**shipDate** | [**java.time.LocalDateTime**](java.time.LocalDateTime.md) | | [optional]
+**shipDate** | [**java.time.OffsetDateTime**](java.time.OffsetDateTime.md) | | [optional]
**status** | [**inline**](#StatusEnum) | Order Status | [optional]
**complete** | **kotlin.Boolean** | | [optional]
diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
new file mode 100644
index 00000000000..87437871a31
--- /dev/null
+++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt
@@ -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)
+ }
+
+}
diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
index 3f39c48d4dc..697559b2ec1 100644
--- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
+++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
@@ -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())
diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt
index 47862cfb7b6..452a176c120 100644
--- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt
+++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/models/Order.kt
@@ -32,7 +32,7 @@ data class Order (
@Json(name = "quantity")
val quantity: kotlin.Int? = null,
@Json(name = "shipDate")
- val shipDate: java.time.LocalDateTime? = null,
+ val shipDate: java.time.OffsetDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
diff --git a/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/StoreApiTest.kt b/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/StoreApiTest.kt
index 1807e516eb0..733df971a8b 100644
--- a/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/StoreApiTest.kt
+++ b/samples/client/petstore/kotlin/src/test/kotlin/org/openapitools/client/StoreApiTest.kt
@@ -6,7 +6,7 @@ import org.openapitools.client.apis.PetApi
import org.openapitools.client.apis.StoreApi
import org.openapitools.client.models.Order
import org.openapitools.client.models.Pet
-import java.time.LocalDateTime.now
+import java.time.OffsetDateTime.now
class StoreApiTest : ShouldSpec() {
init {