diff --git a/.travis.yml b/.travis.yml
index 973a0dc3ce8..8c3abe8a927 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -136,10 +136,10 @@ script:
- mvn --quiet --batch-mode --show-version clean install
- mvn --quiet --batch-mode --show-version verify -Psamples
# test maven plugin
- - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml
- - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
- - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml
- - mvn clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml
+ - mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml
+ - mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
+ - mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml
+ - mvn --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml
# test gradle plugin
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk)
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
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/Java/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
index 47059d550b1..1aa650293b1 100644
--- a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
@@ -138,7 +138,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
index e70e3e2945f..fcdbf1c4f2b 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
@@ -122,7 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
{{#threetenbp}}
jackson_threetenbp_version = "2.9.10"
{{/threetenbp}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
index 7910027eb91..fd0315830ed 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
@@ -315,7 +315,7 @@
{{#useFeign10}}10.2.3{{/useFeign10}}{{^useFeign10}}9.7.0{{/useFeign10}}
2.1.0
2.9.10
- 0.2.0
+ 0.2.1
2.9.10.1
{{#threetenbp}}
2.9.10
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
index 57deb75c560..aa26930fd96 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
@@ -122,7 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
google_api_client_version = "1.23.0"
jersey_common_version = "2.25.1"
jodatime_version = "2.9.9"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
index 89f8be6132c..4e17016acb6 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
@@ -308,7 +308,7 @@
2.25.1
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
{{#joda}}
2.9.9
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
index 998d6ebc8b4..56d0e55fcb5 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
@@ -121,7 +121,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
{{#supportJava6}}
jersey_version = "2.6"
commons_io_version=2.5
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
index 5a108ed6ee4..21f566f2c43 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
@@ -362,7 +362,7 @@
{{/supportJava6}}
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
{{#threetenbp}}
2.9.10
{{/threetenbp}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
index e3fe7f74118..75f54dab22f 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
@@ -215,7 +215,7 @@
11
11
2.9.9
- 0.2.0
+ 0.2.1
4.12
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
index c40c9c3eb92..dd848e0f5ec 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
@@ -101,7 +101,7 @@ ext {
{{#jackson}}
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10"
- jackson_databind_nullable_version = 0.2.0
+ jackson_databind_nullable_version = 0.2.1
{{/jackson}}
{{#gson}}
gson_version = "2.8.5"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
index 330fd660725..f4eb427c766 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
@@ -325,7 +325,7 @@
{{#jackson}}
2.9.10
2.9.10
- 0.2.0
+ 0.2.1
{{#threetenbp}}
2.9.10
{{/threetenbp}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
index bf9f5408c2a..6579b7c46c9 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
@@ -121,7 +121,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
threetenbp_version = "2.9.10"
resteasy_version = "3.1.3.Final"
{{^java8}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache
index 16a1a3fe1fa..30a4ba06e6f 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache
@@ -296,7 +296,7 @@
3.1.3.Final
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
{{^java8}}
2.9.9
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
index 1c631f1a557..2e2485139fa 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
@@ -122,7 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache
index eb3ddfb12f9..e55bc8e7fe5 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache
@@ -311,7 +311,7 @@
4.3.9.RELEASE
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
{{#joda}}
2.9.9
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
index ddeb061cd02..362c8a504a6 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
@@ -133,7 +133,7 @@ ext {
{{#play26}}
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
play_version = "2.6.7"
{{/play26}}
{{/usePlayWS}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache
index 428e4203763..f0415112104 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache
@@ -388,7 +388,7 @@
2.9.10
2.6.7
{{/play26}}
- 0.2.0
+ 0.2.1
{{/usePlayWS}}
2.5.0
{{#useRxJava}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache
index cdbb87d1800..51125fa48e0 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache
@@ -291,7 +291,7 @@
1.5.22
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
4.12
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
index f32f6ee5f45..f07bbf5e942 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
@@ -145,7 +145,7 @@
5.0.8.RELEASE
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
4.12
3.1.8.RELEASE
0.7.8.RELEASE
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/java/feign/build.gradle b/samples/client/petstore/java/feign/build.gradle
index c8f199b701b..d2ed9b1b02e 100644
--- a/samples/client/petstore/java/feign/build.gradle
+++ b/samples/client/petstore/java/feign/build.gradle
@@ -98,7 +98,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jackson_threetenbp_version = "2.9.10"
feign_version = "9.7.0"
feign_form_version = "2.1.0"
diff --git a/samples/client/petstore/java/feign/pom.xml b/samples/client/petstore/java/feign/pom.xml
index 71137666166..5890ab94013 100644
--- a/samples/client/petstore/java/feign/pom.xml
+++ b/samples/client/petstore/java/feign/pom.xml
@@ -282,7 +282,7 @@
9.7.0
2.1.0
2.9.10
- 0.2.0
+ 0.2.1
2.9.10.1
2.9.10
4.12
diff --git a/samples/client/petstore/java/feign10x/build.gradle b/samples/client/petstore/java/feign10x/build.gradle
index f59ac8f69d1..4488d473292 100644
--- a/samples/client/petstore/java/feign10x/build.gradle
+++ b/samples/client/petstore/java/feign10x/build.gradle
@@ -98,7 +98,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jackson_threetenbp_version = "2.9.10"
feign_version = "10.2.3"
feign_form_version = "2.1.0"
diff --git a/samples/client/petstore/java/feign10x/pom.xml b/samples/client/petstore/java/feign10x/pom.xml
index 6b773b2cd91..2dbf864e3a1 100644
--- a/samples/client/petstore/java/feign10x/pom.xml
+++ b/samples/client/petstore/java/feign10x/pom.xml
@@ -282,7 +282,7 @@
10.2.3
2.1.0
2.9.10
- 0.2.0
+ 0.2.1
2.9.10.1
2.9.10
4.12
diff --git a/samples/client/petstore/java/google-api-client/build.gradle b/samples/client/petstore/java/google-api-client/build.gradle
index a84e8f60020..179019d022d 100644
--- a/samples/client/petstore/java/google-api-client/build.gradle
+++ b/samples/client/petstore/java/google-api-client/build.gradle
@@ -98,7 +98,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
google_api_client_version = "1.23.0"
jersey_common_version = "2.25.1"
jodatime_version = "2.9.9"
diff --git a/samples/client/petstore/java/google-api-client/pom.xml b/samples/client/petstore/java/google-api-client/pom.xml
index e99897809e8..47a18571de9 100644
--- a/samples/client/petstore/java/google-api-client/pom.xml
+++ b/samples/client/petstore/java/google-api-client/pom.xml
@@ -260,7 +260,7 @@
2.25.1
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
1.0.0
4.12
diff --git a/samples/client/petstore/java/jersey1/build.gradle b/samples/client/petstore/java/jersey1/build.gradle
index 2c4a3af46cb..0d16f055d7d 100644
--- a/samples/client/petstore/java/jersey1/build.gradle
+++ b/samples/client/petstore/java/jersey1/build.gradle
@@ -114,7 +114,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/samples/client/petstore/java/jersey2-java6/pom.xml b/samples/client/petstore/java/jersey2-java6/pom.xml
index 70150988b35..f4cf661f437 100644
--- a/samples/client/petstore/java/jersey2-java6/pom.xml
+++ b/samples/client/petstore/java/jersey2-java6/pom.xml
@@ -292,7 +292,7 @@
3.6
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
1.0.0
4.12
diff --git a/samples/client/petstore/java/jersey2-java8/build.gradle b/samples/client/petstore/java/jersey2-java8/build.gradle
index 1c2b2d6f336..c3eb9a069f6 100644
--- a/samples/client/petstore/java/jersey2-java8/build.gradle
+++ b/samples/client/petstore/java/jersey2-java8/build.gradle
@@ -97,7 +97,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jersey_version = "2.27"
junit_version = "4.12"
}
diff --git a/samples/client/petstore/java/jersey2-java8/pom.xml b/samples/client/petstore/java/jersey2-java8/pom.xml
index 475b490728e..9197b3718c8 100644
--- a/samples/client/petstore/java/jersey2-java8/pom.xml
+++ b/samples/client/petstore/java/jersey2-java8/pom.xml
@@ -279,7 +279,7 @@
2.27
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
1.0.0
4.12
diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle
index ac168318d96..3b60e74d4b6 100644
--- a/samples/client/petstore/java/jersey2/build.gradle
+++ b/samples/client/petstore/java/jersey2/build.gradle
@@ -97,7 +97,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jersey_version = "2.27"
junit_version = "4.12"
threetenbp_version = "2.9.10"
diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml
index 6e341a40e8f..36ae053a4b2 100644
--- a/samples/client/petstore/java/jersey2/pom.xml
+++ b/samples/client/petstore/java/jersey2/pom.xml
@@ -285,7 +285,7 @@
2.27
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
1.0.0
4.12
diff --git a/samples/client/petstore/java/native/pom.xml b/samples/client/petstore/java/native/pom.xml
index 273a741e0ed..5681e8b004c 100644
--- a/samples/client/petstore/java/native/pom.xml
+++ b/samples/client/petstore/java/native/pom.xml
@@ -208,7 +208,7 @@
11
11
2.9.9
- 0.2.0
+ 0.2.1
4.12
diff --git a/samples/client/petstore/java/resteasy/build.gradle b/samples/client/petstore/java/resteasy/build.gradle
index bd2a69eafa2..74d6ad55673 100644
--- a/samples/client/petstore/java/resteasy/build.gradle
+++ b/samples/client/petstore/java/resteasy/build.gradle
@@ -97,7 +97,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
threetenbp_version = "2.9.10"
resteasy_version = "3.1.3.Final"
jodatime_version = "2.9.9"
diff --git a/samples/client/petstore/java/resteasy/pom.xml b/samples/client/petstore/java/resteasy/pom.xml
index 1051701e860..561259f7184 100644
--- a/samples/client/petstore/java/resteasy/pom.xml
+++ b/samples/client/petstore/java/resteasy/pom.xml
@@ -245,7 +245,7 @@
3.1.3.Final
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
2.9.9
1.0.0
diff --git a/samples/client/petstore/java/resttemplate-withXml/build.gradle b/samples/client/petstore/java/resttemplate-withXml/build.gradle
index b857b47737b..8310f0f4a36 100644
--- a/samples/client/petstore/java/resttemplate-withXml/build.gradle
+++ b/samples/client/petstore/java/resttemplate-withXml/build.gradle
@@ -98,7 +98,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/samples/client/petstore/java/resttemplate-withXml/pom.xml b/samples/client/petstore/java/resttemplate-withXml/pom.xml
index f498ec40eeb..909b61ab16a 100644
--- a/samples/client/petstore/java/resttemplate-withXml/pom.xml
+++ b/samples/client/petstore/java/resttemplate-withXml/pom.xml
@@ -269,7 +269,7 @@
4.3.9.RELEASE
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
1.0.0
4.12
diff --git a/samples/client/petstore/java/resttemplate/build.gradle b/samples/client/petstore/java/resttemplate/build.gradle
index 848d01a1a12..845612fa0ff 100644
--- a/samples/client/petstore/java/resttemplate/build.gradle
+++ b/samples/client/petstore/java/resttemplate/build.gradle
@@ -98,7 +98,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/samples/client/petstore/java/resttemplate/pom.xml b/samples/client/petstore/java/resttemplate/pom.xml
index ac33a8e2360..49ca9e754ae 100644
--- a/samples/client/petstore/java/resttemplate/pom.xml
+++ b/samples/client/petstore/java/resttemplate/pom.xml
@@ -261,7 +261,7 @@
4.3.9.RELEASE
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
2.9.10
1.0.0
4.12
diff --git a/samples/client/petstore/java/retrofit2-play24/pom.xml b/samples/client/petstore/java/retrofit2-play24/pom.xml
index 6ba692a3eb6..eab89a5e1f5 100644
--- a/samples/client/petstore/java/retrofit2-play24/pom.xml
+++ b/samples/client/petstore/java/retrofit2-play24/pom.xml
@@ -282,7 +282,7 @@
2.9.10.1
2.6.6
2.4.11
- 0.2.0
+ 0.2.1
2.5.0
1.0.1
4.12
diff --git a/samples/client/petstore/java/retrofit2-play25/pom.xml b/samples/client/petstore/java/retrofit2-play25/pom.xml
index 5b16aa6a53f..e1191e2d5d5 100644
--- a/samples/client/petstore/java/retrofit2-play25/pom.xml
+++ b/samples/client/petstore/java/retrofit2-play25/pom.xml
@@ -287,7 +287,7 @@
2.9.10.1
2.9.10
2.5.15
- 0.2.0
+ 0.2.1
2.5.0
1.4.0
1.0.1
diff --git a/samples/client/petstore/java/retrofit2-play26/build.gradle b/samples/client/petstore/java/retrofit2-play26/build.gradle
index 541c3fa8032..5ce5e94d58e 100644
--- a/samples/client/petstore/java/retrofit2-play26/build.gradle
+++ b/samples/client/petstore/java/retrofit2-play26/build.gradle
@@ -99,7 +99,7 @@ ext {
retrofit_version = "2.3.0"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
play_version = "2.6.7"
swagger_annotations_version = "1.5.22"
junit_version = "4.12"
diff --git a/samples/client/petstore/java/retrofit2-play26/pom.xml b/samples/client/petstore/java/retrofit2-play26/pom.xml
index a5dbd177064..02565e20400 100644
--- a/samples/client/petstore/java/retrofit2-play26/pom.xml
+++ b/samples/client/petstore/java/retrofit2-play26/pom.xml
@@ -292,7 +292,7 @@
2.9.10.1
2.9.10
2.6.7
- 0.2.0
+ 0.2.1
2.5.0
1.4.0
1.0.1
diff --git a/samples/client/petstore/java/vertx/pom.xml b/samples/client/petstore/java/vertx/pom.xml
index d7e3842ebc5..9e0c3bd8a4a 100644
--- a/samples/client/petstore/java/vertx/pom.xml
+++ b/samples/client/petstore/java/vertx/pom.xml
@@ -268,7 +268,7 @@
1.5.22
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
4.12
diff --git a/samples/client/petstore/java/webclient/build.gradle b/samples/client/petstore/java/webclient/build.gradle
index dc82478f47a..101096e85e6 100644
--- a/samples/client/petstore/java/webclient/build.gradle
+++ b/samples/client/petstore/java/webclient/build.gradle
@@ -114,7 +114,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.10"
jackson_databind_version = "2.9.10.1"
- jackson_databind_nullable_version = "0.2.0"
+ jackson_databind_nullable_version = "0.2.1"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.12"
diff --git a/samples/client/petstore/java/webclient/pom.xml b/samples/client/petstore/java/webclient/pom.xml
index 405f509aadf..1c5a5150b35 100644
--- a/samples/client/petstore/java/webclient/pom.xml
+++ b/samples/client/petstore/java/webclient/pom.xml
@@ -124,7 +124,7 @@
5.0.8.RELEASE
2.9.10
2.9.10.1
- 0.2.0
+ 0.2.1
4.12
3.1.8.RELEASE
0.7.8.RELEASE
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 {