forked from loafle/openapi-generator-original
[JAVA: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON (#18811)
* Partially revert "replace deprecated ISO8601Utils with StdDateFormat (#17052)" This partially reverts commit 76560e34c9aacd9d7593ac45bd204e2edf38abd9, namely anything related to generators and samples using GSON instead of Jackson. Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat are not being reverted. * Test for default serialization library fallback * Convert repetitive tests to parameterized test * Add regression test for #18515 * [FEIGN] Only include <jackson-databind-version> property in pom.xml when required * [RETROFIT2] Only include jackson-databind in gradle file when actually required * [FEIGN] Don't include jackson dep's in sbt file when GSON is selected * [FEIGN] Don't include jackson dep's in gradle file when GSON is selected * DRY refactor JavaClientCodegen test code, increase readability - use fluent assertions - use helper method newTempFolder() - use Java 9 static factory methods for maps - don't declare variables that are only used once - group declarations and usages - use non-blocking java.nio.file API wherever possible * Regenerate samples
This commit is contained in:
parent
051abb82dc
commit
ed2aad6756
@ -17,35 +17,23 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.online;
|
package org.openapitools.codegen.online;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
|
||||||
|
import com.fasterxml.jackson.databind.util.ISO8601Utils;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.FieldPosition;
|
import java.text.FieldPosition;
|
||||||
import java.text.ParsePosition;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class RFC3339DateFormat extends DateFormat {
|
|
||||||
|
public class RFC3339DateFormat extends ISO8601DateFormat {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
|
|
||||||
|
// Same as ISO8601DateFormat but serializing milliseconds.
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||||
String value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
String value = ISO8601Utils.format(date, true);
|
||||||
toAppendTo.append(value);
|
toAppendTo.append(value);
|
||||||
return toAppendTo;
|
return toAppendTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date parse(String source, ParsePosition pos) {
|
|
||||||
return sdf.parse(source, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -33,14 +33,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -57,11 +54,6 @@ public class JSON {
|
|||||||
{{/jsr310}}
|
{{/jsr310}}
|
||||||
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -469,7 +461,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -479,7 +471,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -504,7 +496,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -523,7 +515,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,10 @@ test {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.6.11"
|
swagger_annotations_version = "1.6.11"
|
||||||
|
{{#jackson}}
|
||||||
jackson_version = "2.17.1"
|
jackson_version = "2.17.1"
|
||||||
jackson_databind_version = "2.17.1"
|
jackson_databind_version = "2.17.1"
|
||||||
|
{{/jackson}}
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
jackson_databind_nullable_version = "0.2.6"
|
jackson_databind_nullable_version = "0.2.6"
|
||||||
{{/openApiNullable}}
|
{{/openApiNullable}}
|
||||||
@ -118,20 +120,24 @@ dependencies {
|
|||||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
implementation "io.github.openfeign:feign-core:$feign_version"
|
implementation "io.github.openfeign:feign-core:$feign_version"
|
||||||
|
{{#jackson}}
|
||||||
implementation "io.github.openfeign:feign-jackson:$feign_version"
|
implementation "io.github.openfeign:feign-jackson:$feign_version"
|
||||||
|
{{/jackson}}
|
||||||
implementation "io.github.openfeign:feign-slf4j:$feign_version"
|
implementation "io.github.openfeign:feign-slf4j:$feign_version"
|
||||||
implementation "io.github.openfeign:feign-okhttp:$feign_version"
|
implementation "io.github.openfeign:feign-okhttp:$feign_version"
|
||||||
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
|
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
{{#jackson}}
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
{{#openApiNullable}}
|
|
||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
|
||||||
{{/openApiNullable}}
|
|
||||||
{{#joda}}
|
{{#joda}}
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
|
{{/jackson}}
|
||||||
|
{{#openApiNullable}}
|
||||||
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
|
{{/openApiNullable}}
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
|
@ -12,15 +12,19 @@ lazy val root = (project in file(".")).
|
|||||||
"io.swagger" % "swagger-annotations" % "1.6.11" % "compile",
|
"io.swagger" % "swagger-annotations" % "1.6.11" % "compile",
|
||||||
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
|
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
|
||||||
"io.github.openfeign" % "feign-core" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-core" % "10.12" % "compile",
|
||||||
|
{{#jackson}}
|
||||||
"io.github.openfeign" % "feign-jackson" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-jackson" % "10.12" % "compile",
|
||||||
|
{{/jackson}}
|
||||||
"io.github.openfeign" % "feign-slf4j" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-slf4j" % "10.12" % "compile",
|
||||||
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
|
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
|
||||||
"io.github.openfeign" % "feign-okhttp" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-okhttp" % "10.12" % "compile",
|
||||||
|
{{#jackson}}
|
||||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.17.1" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-core" % "2.17.1" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.17.1" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.17.1" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1" % "compile",
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.17.1" % "compile",
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.17.1" % "compile",
|
||||||
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.15.2" % "compile",
|
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.15.2" % "compile",
|
||||||
|
{{/jackson}}
|
||||||
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
|
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
|
||||||
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
||||||
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
||||||
|
@ -393,6 +393,7 @@
|
|||||||
<feign-form-version>3.8.0</feign-form-version>
|
<feign-form-version>3.8.0</feign-form-version>
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
{{/jackson}}
|
{{/jackson}}
|
||||||
{{#gson}}
|
{{#gson}}
|
||||||
<gson-version>2.10.1</gson-version>
|
<gson-version>2.10.1</gson-version>
|
||||||
@ -400,7 +401,6 @@
|
|||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
{{/openApiNullable}}
|
{{/openApiNullable}}
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
{{#useJakartaEe}}
|
{{#useJakartaEe}}
|
||||||
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
|
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
|
||||||
{{/useJakartaEe}}
|
{{/useJakartaEe}}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -27,16 +27,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -59,11 +57,6 @@ public class JSON {
|
|||||||
{{/jsr310}}
|
{{/jsr310}}
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -466,7 +459,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -476,7 +469,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -501,7 +494,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -520,7 +513,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -271,11 +271,6 @@
|
|||||||
<version>${gson-fire-version}</version>
|
<version>${gson-fire-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/gson}}
|
{{/gson}}
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
<!-- JSON processing: jackson -->
|
<!-- JSON processing: jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -286,6 +281,10 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>jackson-databind-nullable</artifactId>
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
@ -352,9 +351,9 @@
|
|||||||
{{#joda}}
|
{{#joda}}
|
||||||
<jodatime-version>2.10.5</jodatime-version>
|
<jodatime-version>2.10.5</jodatime-version>
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
{{/jackson}}
|
{{/jackson}}
|
||||||
{{#useJakartaEe}}
|
{{#useJakartaEe}}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -32,14 +32,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -54,11 +51,6 @@ public class JSON {
|
|||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
{{/jsr310}}
|
{{/jsr310}}
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
{{#models}}{{#model}}{{#discriminator}} .registerTypeSelector({{classname}}.class, new TypeSelector() {
|
{{#models}}{{#model}}{{#discriminator}} .registerTypeSelector({{classname}}.class, new TypeSelector() {
|
||||||
@ -370,7 +362,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -380,7 +372,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -406,7 +398,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -425,7 +417,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,9 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.3.0"
|
retrofit_version = "2.3.0"
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
jackson_version = "2.17.1"
|
jackson_version = "2.17.1"
|
||||||
|
jackson_databind_version = "2.17.1"
|
||||||
javax_ws_rs_api_version = "2.1.1"
|
javax_ws_rs_api_version = "2.1.1"
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
jackson_databind_nullable_version = "0.2.6"
|
jackson_databind_nullable_version = "0.2.6"
|
||||||
@ -154,13 +154,13 @@ dependencies {
|
|||||||
implementation "com.squareup.retrofit2:converter-jackson:$retrofit_version"
|
implementation "com.squareup.retrofit2:converter-jackson:$retrofit_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
implementation "javax.ws.rs:javax.ws.rs-api:$javax_ws_rs_api_version"
|
implementation "javax.ws.rs:javax.ws.rs-api:$javax_ws_rs_api_version"
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
{{/openApiNullable}}
|
{{/openApiNullable}}
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
{{/jackson}}
|
{{/jackson}}
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -211,11 +211,6 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-annotations-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
@ -305,6 +300,11 @@
|
|||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson-databind-version}</version>
|
||||||
|
</dependency>
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
@ -344,6 +344,11 @@
|
|||||||
<artifactId>play-ahc-ws_2.12</artifactId>
|
<artifactId>play-ahc-ws_2.12</artifactId>
|
||||||
<version>${play-version}</version>
|
<version>${play-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
<version>${beanvalidation-version}</version>
|
||||||
|
</dependency>
|
||||||
{{/usePlayWS}}
|
{{/usePlayWS}}
|
||||||
{{#parcelableModel}}
|
{{#parcelableModel}}
|
||||||
<!-- Needed for Parcelable support-->
|
<!-- Needed for Parcelable support-->
|
||||||
@ -377,8 +382,8 @@
|
|||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
{{/gson}}
|
{{/gson}}
|
||||||
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
{{#jackson}}
|
{{#jackson}}
|
||||||
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
{{#openApiNullable}}
|
{{#openApiNullable}}
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -102,8 +102,6 @@ test {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.6.11"
|
swagger_annotations_version = "1.6.11"
|
||||||
jackson_version = "2.17.1"
|
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
jackson_databind_nullable_version = "0.2.6"
|
jackson_databind_nullable_version = "0.2.6"
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
feign_version = "10.12"
|
feign_version = "10.12"
|
||||||
@ -116,15 +114,10 @@ dependencies {
|
|||||||
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
implementation "io.github.openfeign:feign-core:$feign_version"
|
implementation "io.github.openfeign:feign-core:$feign_version"
|
||||||
implementation "io.github.openfeign:feign-jackson:$feign_version"
|
|
||||||
implementation "io.github.openfeign:feign-slf4j:$feign_version"
|
implementation "io.github.openfeign:feign-slf4j:$feign_version"
|
||||||
implementation "io.github.openfeign:feign-okhttp:$feign_version"
|
implementation "io.github.openfeign:feign-okhttp:$feign_version"
|
||||||
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
|
implementation "io.github.openfeign.form:feign-form:$feign_form_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
|
@ -12,15 +12,9 @@ lazy val root = (project in file(".")).
|
|||||||
"io.swagger" % "swagger-annotations" % "1.6.11" % "compile",
|
"io.swagger" % "swagger-annotations" % "1.6.11" % "compile",
|
||||||
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
|
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
|
||||||
"io.github.openfeign" % "feign-core" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-core" % "10.12" % "compile",
|
||||||
"io.github.openfeign" % "feign-jackson" % "10.12" % "compile",
|
|
||||||
"io.github.openfeign" % "feign-slf4j" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-slf4j" % "10.12" % "compile",
|
||||||
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
|
"io.github.openfeign.form" % "feign-form" % "3.8.0" % "compile",
|
||||||
"io.github.openfeign" % "feign-okhttp" % "10.12" % "compile",
|
"io.github.openfeign" % "feign-okhttp" % "10.12" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.17.1" % "compile",
|
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.17.1" % "compile",
|
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1" % "compile",
|
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.17.1" % "compile",
|
|
||||||
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.15.2" % "compile",
|
|
||||||
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
|
"com.github.scribejava" % "scribejava-core" % "8.0.0" % "compile",
|
||||||
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
||||||
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
||||||
|
@ -304,7 +304,6 @@
|
|||||||
<feign-form-version>3.8.0</feign-form-version>
|
<feign-form-version>3.8.0</feign-form-version>
|
||||||
<gson-version>2.10.1</gson-version>
|
<gson-version>2.10.1</gson-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<junit-version>5.10.0</junit-version>
|
<junit-version>5.10.0</junit-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -338,7 +331,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -348,7 +341,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -392,7 +385,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -342,7 +335,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -352,7 +345,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -377,7 +370,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -396,7 +389,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -333,7 +326,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -343,7 +336,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -368,7 +361,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -387,7 +380,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -334,7 +327,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -344,7 +337,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -369,7 +362,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -388,7 +381,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ dependencies {
|
|||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
implementation "com.github.scribejava:scribejava-core:$scribejava_version"
|
||||||
implementation "com.brsanthu:migbase64:2.2"
|
implementation "com.brsanthu:migbase64:2.2"
|
||||||
|
@ -319,8 +319,8 @@
|
|||||||
<feign-version>13.2.1</feign-version>
|
<feign-version>13.2.1</feign-version>
|
||||||
<feign-form-version>3.8.0</feign-form-version>
|
<feign-form-version>3.8.0</feign-form-version>
|
||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<junit-version>5.10.0</junit-version>
|
<junit-version>5.10.0</junit-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -378,7 +371,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -388,7 +381,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -413,7 +406,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -432,7 +425,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -338,7 +331,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -348,7 +341,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -392,7 +385,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -413,7 +406,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -423,7 +416,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -448,7 +441,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -467,7 +460,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -338,7 +331,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -348,7 +341,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -392,7 +385,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -340,7 +333,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -350,7 +343,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -375,7 +368,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -394,7 +387,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -413,7 +406,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -423,7 +416,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -448,7 +441,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -467,7 +460,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -338,7 +331,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -348,7 +341,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -392,7 +385,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -338,7 +331,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -348,7 +341,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -373,7 +366,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -392,7 +385,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -305,11 +305,6 @@
|
|||||||
<artifactId>jackson-databind-nullable</artifactId>
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
<version>${jackson-databind-nullable-version}</version>
|
<version>${jackson-databind-nullable-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>jsr311-api</artifactId>
|
<artifactId>jsr311-api</artifactId>
|
||||||
@ -350,7 +345,6 @@
|
|||||||
<gson-version>2.10.1</gson-version>
|
<gson-version>2.10.1</gson-version>
|
||||||
<commons-lang3-version>3.13.0</commons-lang3-version>
|
<commons-lang3-version>3.13.0</commons-lang3-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
<jackson-databind-version>2.16.0</jackson-databind-version>
|
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<junit-version>5.10.0</junit-version>
|
<junit-version>5.10.0</junit-version>
|
||||||
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
|
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -31,16 +31,14 @@ import java.io.StringReader;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A JSON utility class
|
* A JSON utility class
|
||||||
@ -57,11 +55,6 @@ public class JSON {
|
|||||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -562,7 +555,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -572,7 +565,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -597,7 +590,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -616,7 +609,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -227,11 +227,6 @@
|
|||||||
<artifactId>rest-assured</artifactId>
|
<artifactId>rest-assured</artifactId>
|
||||||
<version>${rest-assured.version}</version>
|
<version>${rest-assured.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- JSON processing: jackson -->
|
<!-- JSON processing: jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
@ -241,6 +236,10 @@
|
|||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>jackson-databind-nullable</artifactId>
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
@ -281,8 +280,8 @@
|
|||||||
<rest-assured.version>5.3.2</rest-assured.version>
|
<rest-assured.version>5.3.2</rest-assured.version>
|
||||||
<gson-version>2.10.1</gson-version>
|
<gson-version>2.10.1</gson-version>
|
||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<jackson-version>2.17.1</jackson-version>
|
<jackson-version>2.17.1</jackson-version>
|
||||||
|
<jackson-databind-version>2.17.1</jackson-databind-version>
|
||||||
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<beanvalidation-version>3.0.2</beanvalidation-version>
|
<beanvalidation-version>3.0.2</beanvalidation-version>
|
||||||
|
@ -226,11 +226,6 @@
|
|||||||
<artifactId>gson-fire</artifactId>
|
<artifactId>gson-fire</artifactId>
|
||||||
<version>${gson-fire-version}</version>
|
<version>${gson-fire-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okio</groupId>
|
<groupId>com.squareup.okio</groupId>
|
||||||
<artifactId>okio</artifactId>
|
<artifactId>okio</artifactId>
|
||||||
@ -262,7 +257,6 @@
|
|||||||
<rest-assured.version>5.3.2</rest-assured.version>
|
<rest-assured.version>5.3.2</rest-assured.version>
|
||||||
<gson-version>2.10.1</gson-version>
|
<gson-version>2.10.1</gson-version>
|
||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<beanvalidation-version>3.0.2</beanvalidation-version>
|
<beanvalidation-version>3.0.2</beanvalidation-version>
|
||||||
<okio-version>3.6.0</okio-version>
|
<okio-version>3.6.0</okio-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -35,14 +35,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -53,11 +50,6 @@ public class JSON {
|
|||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
@ -380,7 +372,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -390,7 +382,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -415,7 +407,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -434,7 +426,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.3.0"
|
retrofit_version = "2.3.0"
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
jackson_version = "2.17.1"
|
jackson_version = "2.17.1"
|
||||||
|
jackson_databind_version = "2.17.1"
|
||||||
javax_ws_rs_api_version = "2.1.1"
|
javax_ws_rs_api_version = "2.1.1"
|
||||||
jackson_databind_nullable_version = "0.2.6"
|
jackson_databind_nullable_version = "0.2.6"
|
||||||
play_version = "2.6.7"
|
play_version = "2.6.7"
|
||||||
@ -125,10 +125,10 @@ dependencies {
|
|||||||
implementation "com.squareup.retrofit2:converter-jackson:$retrofit_version"
|
implementation "com.squareup.retrofit2:converter-jackson:$retrofit_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
|
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
||||||
implementation "javax.ws.rs:javax.ws.rs-api:$javax_ws_rs_api_version"
|
implementation "javax.ws.rs:javax.ws.rs-api:$javax_ws_rs_api_version"
|
||||||
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
|
||||||
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -204,11 +204,6 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-annotations-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
@ -252,6 +247,11 @@
|
|||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>${jackson-databind-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>jackson-databind-nullable</artifactId>
|
<artifactId>jackson-databind-nullable</artifactId>
|
||||||
@ -277,6 +277,11 @@
|
|||||||
<artifactId>play-ahc-ws_2.12</artifactId>
|
<artifactId>play-ahc-ws_2.12</artifactId>
|
||||||
<version>${play-version}</version>
|
<version>${play-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
<version>${beanvalidation-version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.annotation</groupId>
|
<groupId>jakarta.annotation</groupId>
|
||||||
<artifactId>jakarta.annotation-api</artifactId>
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.3.0"
|
retrofit_version = "2.3.0"
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
@ -116,7 +115,6 @@ dependencies {
|
|||||||
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
||||||
}
|
}
|
||||||
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -204,11 +204,6 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-annotations-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
@ -267,7 +262,6 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<retrofit-version>2.5.0</retrofit-version>
|
<retrofit-version>2.5.0</retrofit-version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -34,14 +34,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -50,11 +47,6 @@ public class JSON {
|
|||||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
.registerTypeSelector(Animal.class, new TypeSelector() {
|
.registerTypeSelector(Animal.class, new TypeSelector() {
|
||||||
@ -293,7 +285,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -303,7 +295,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -329,7 +321,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -348,7 +340,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.3.0"
|
retrofit_version = "2.3.0"
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
@ -119,7 +118,6 @@ dependencies {
|
|||||||
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
||||||
}
|
}
|
||||||
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -204,11 +204,6 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-annotations-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
@ -277,7 +272,6 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<retrofit-version>2.5.0</retrofit-version>
|
<retrofit-version>2.5.0</retrofit-version>
|
||||||
<rxjava-version>2.1.1</rxjava-version>
|
<rxjava-version>2.1.1</rxjava-version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -34,14 +34,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -50,11 +47,6 @@ public class JSON {
|
|||||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
.registerTypeSelector(Animal.class, new TypeSelector() {
|
.registerTypeSelector(Animal.class, new TypeSelector() {
|
||||||
@ -293,7 +285,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -303,7 +295,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -329,7 +321,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -348,7 +340,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
ext {
|
ext {
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
retrofit_version = "2.3.0"
|
retrofit_version = "2.3.0"
|
||||||
jackson_databind_version = "2.17.1"
|
|
||||||
jakarta_annotation_version = "1.3.5"
|
jakarta_annotation_version = "1.3.5"
|
||||||
swagger_annotations_version = "1.5.22"
|
swagger_annotations_version = "1.5.22"
|
||||||
junit_version = "4.13.2"
|
junit_version = "4.13.2"
|
||||||
@ -119,7 +118,6 @@ dependencies {
|
|||||||
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
|
||||||
}
|
}
|
||||||
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
implementation "io.gsonfire:gson-fire:$json_fire_version"
|
||||||
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
|
|
||||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -204,11 +204,6 @@
|
|||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
<version>${swagger-annotations-version}</version>
|
<version>${swagger-annotations-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
<version>${jackson-databind-version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- @Nullable annotation -->
|
<!-- @Nullable annotation -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
@ -277,7 +272,6 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<gson-fire-version>1.9.0</gson-fire-version>
|
<gson-fire-version>1.9.0</gson-fire-version>
|
||||||
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
<swagger-annotations-version>1.6.3</swagger-annotations-version>
|
||||||
<jackson-databind-version>2.17.1</jackson-databind-version>
|
|
||||||
<retrofit-version>2.5.0</retrofit-version>
|
<retrofit-version>2.5.0</retrofit-version>
|
||||||
<rxjava-version>3.0.4</rxjava-version>
|
<rxjava-version>3.0.4</rxjava-version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
package org.openapitools.client;
|
package org.openapitools.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.util.ISO8601Utils;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -34,14 +34,11 @@ import java.text.ParseException;
|
|||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class JSON {
|
public class JSON {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
@ -50,11 +47,6 @@ public class JSON {
|
|||||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
|
|
||||||
private static final StdDateFormat sdf = new StdDateFormat()
|
|
||||||
.withTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
|
|
||||||
.withColonInTimeZone(true);
|
|
||||||
private static final DateTimeFormatter dtf = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
|
||||||
|
|
||||||
public static GsonBuilder createGson() {
|
public static GsonBuilder createGson() {
|
||||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||||
.registerTypeSelector(Animal.class, new TypeSelector() {
|
.registerTypeSelector(Animal.class, new TypeSelector() {
|
||||||
@ -293,7 +285,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return new java.sql.Date(dateFormat.parse(date).getTime());
|
return new java.sql.Date(dateFormat.parse(date).getTime());
|
||||||
}
|
}
|
||||||
return new java.sql.Date(sdf.parse(date).getTime());
|
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
@ -303,7 +295,7 @@ public class JSON {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.util.Date type
|
* Gson TypeAdapter for java.util.Date type
|
||||||
* If the dateFormat is null, DateTimeFormatter will be used.
|
* If the dateFormat is null, ISO8601Utils will be used.
|
||||||
*/
|
*/
|
||||||
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
public static class DateTypeAdapter extends TypeAdapter<Date> {
|
||||||
|
|
||||||
@ -329,7 +321,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
value = dateFormat.format(date);
|
value = dateFormat.format(date);
|
||||||
} else {
|
} else {
|
||||||
value = date.toInstant().atOffset(ZoneOffset.UTC).format(dtf);
|
value = ISO8601Utils.format(date, true);
|
||||||
}
|
}
|
||||||
out.value(value);
|
out.value(value);
|
||||||
}
|
}
|
||||||
@ -348,7 +340,7 @@ public class JSON {
|
|||||||
if (dateFormat != null) {
|
if (dateFormat != null) {
|
||||||
return dateFormat.parse(date);
|
return dateFormat.parse(date);
|
||||||
}
|
}
|
||||||
return sdf.parse(date);
|
return ISO8601Utils.parse(date, new ParsePosition(0));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new JsonParseException(e);
|
throw new JsonParseException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user