[Java] Threetenbp dates support (#4029)

* [feign] add threetenbp support for feign clients

* [okhttp] add threetenbp support for okhttp clients

* [jersey] add threetenbp support for jersey clients

* [retrofit2] add threetenbp support for retrofit2 clients

* [spring] add threetenbp support for spring generators

* add a workaround in tests for a bug in the petstore

The petstore doesn't manage fractional digits of dates correctly when there are less than 3
This commit is contained in:
Christophe Bornet 2016-11-04 10:55:16 +01:00 committed by wing328
parent c1e6f00242
commit 70d93883cf
336 changed files with 6397 additions and 1821 deletions

View File

@ -28,6 +28,6 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson-parcelableModel -DhideGenerationTimestamp=true,parcelableModel=true"
rm -rf samples/client/petstore/java/okhttp-gson/src/main
find samples/client/petstore/java/okhttp-gson -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
rm -rf samples/client/petstore/java/okhttp-gson-parcelableModel/src/main
find samples/client/petstore/java/okhttp-gson-parcelableModel -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags

View File

@ -26,7 +26,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit -DhideGenerationTimestamp=true"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit -DhideGenerationTimestamp=true,dateLibrary=joda"
echo "Removing files and folders under samples/client/petstore/java/retrofit/src/main"
rm -rf samples/client/petstore/java/retrofit/src/main

View File

@ -47,7 +47,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
public static final String DATE_LIBRARY = "dateLibrary";
public static final String SUPPORT_JAVA6 = "supportJava6";
protected String dateLibrary = "joda";
protected String dateLibrary = "threetenbp";
protected String invokerPackage = "io.swagger";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-java";
@ -126,10 +126,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
Map<String, String> dateOptions = new HashMap<String, String>();
dateOptions.put("java8", "Java 8 native");
dateOptions.put("java8", "Java 8 native JSR310 (preferred for jdk 1.8+)");
dateOptions.put("threetenbp", "Backport of JSR310 (preferred for jdk < 1.8)");
dateOptions.put("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)");
dateOptions.put("joda", "Joda");
dateOptions.put("legacy", "Legacy java.util.Date");
dateOptions.put("joda", "Joda (for legacy app only)");
dateOptions.put("legacy", "Legacy java.util.Date (if you really have a good reason not to use threetenbp");
dateLibrary.setEnum(dateOptions);
cliOptions.add(dateLibrary);
@ -261,21 +262,26 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
// used later in recursive import in postProcessingModels
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
if(additionalProperties.containsKey(DATE_LIBRARY)) {
if (additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary(additionalProperties.get("dateLibrary").toString());
additionalProperties.put(dateLibrary, "true");
}
if("joda".equals(dateLibrary)) {
if ("threetenbp".equals(dateLibrary)) {
additionalProperties.put("threetenbp", "true");
additionalProperties.put("jsr310", "true");
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "OffsetDateTime");
importMapping.put("LocalDate", "org.threeten.bp.LocalDate");
importMapping.put("OffsetDateTime", "org.threeten.bp.OffsetDateTime");
} else if ("joda".equals(dateLibrary)) {
additionalProperties.put("joda", "true");
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "DateTime");
importMapping.put("LocalDate", "org.joda.time.LocalDate");
importMapping.put("DateTime", "org.joda.time.DateTime");
}
else if (dateLibrary.startsWith("java8")) {
} else if (dateLibrary.startsWith("java8")) {
additionalProperties.put("java8", "true");
additionalProperties.put("jsr310", "true");
typeMapping.put("date", "LocalDate");
importMapping.put("LocalDate", "java.time.LocalDate");
if ("java8-localdatetime".equals(dateLibrary)) {
@ -285,6 +291,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
typeMapping.put("DateTime", "OffsetDateTime");
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
}
} else {
additionalProperties.put("legacyDates", "true");
}
}

View File

@ -162,8 +162,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen implements BeanValida
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
}
if (additionalProperties.containsKey("jackson") ) {
if (additionalProperties.containsKey("jackson")) {
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
if ("threetenbp".equals(dateLibrary)) {
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
}
}
}

View File

@ -84,6 +84,19 @@ public class SpringCodegen extends AbstractJavaCodegen {
@Override
public void processOpts() {
// Process java8 option before common java ones to change the default dateLibrary to java8.
if (additionalProperties.containsKey(JAVA_8)) {
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
}
if (this.java8) {
additionalProperties.put("javaVersion", "1.8");
additionalProperties.put("jdk8", "true");
if (!additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary("java8");
}
}
super.processOpts();
// clear model and api doc template as this codegen
@ -112,10 +125,6 @@ public class SpringCodegen extends AbstractJavaCodegen {
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
}
if (additionalProperties.containsKey(JAVA_8)) {
this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString()));
}
if (additionalProperties.containsKey(ASYNC)) {
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
}
@ -177,6 +186,15 @@ public class SpringCodegen extends AbstractJavaCodegen {
}
}
if ("threetenbp".equals(dateLibrary)) {
supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java"));
if (library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_CLOUD_LIBRARY)) {
supportingFiles.add(new SupportingFile("jacksonConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "JacksonConfiguration.java"));
}
}
if (this.java8) {
additionalProperties.put("javaVersion", "1.8");
additionalProperties.put("jdk8", "true");
@ -230,7 +248,7 @@ public class SpringCodegen extends AbstractJavaCodegen {
basePath = basePath.substring(0, pos);
}
if (basePath == "") {
if (basePath.equals("")) {
basePath = "default";
} else {
co.subresourceOperation = !co.path.isEmpty();

View File

@ -1,14 +1,21 @@
{{>licenseInfo}}
package {{invokerPackage}};
{{#threetenbp}}
import org.threeten.bp.*;
{{/threetenbp}}
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
{{#joda}}
import com.fasterxml.jackson.datatype.joda.JodaModule;
{{/joda}}
{{#java8}}
import com.fasterxml.jackson.datatype.jsr310.*;
{{/java8}}
{{^java8}}
import com.fasterxml.jackson.datatype.joda.*;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
{{/java8}}
{{#threetenbp}}
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
{{/threetenbp}}
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.sun.jersey.api.client.Client;
@ -70,12 +77,19 @@ public class ApiClient {
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
{{#joda}}
objectMapper.registerModule(new JodaModule());
{{/joda}}
{{#java8}}
objectMapper.registerModule(new JavaTimeModule());
{{/java8}}
{{^java8}}
objectMapper.registerModule(new JodaModule());
{{/java8}}
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
{{/threetenbp}}
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
dateFormat = ApiClient.buildDefaultDateFormat();

View File

@ -0,0 +1,232 @@
package {{invokerPackage}};
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
import org.threeten.bp.DateTimeException;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZonedDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.Temporal;
import org.threeten.bp.temporal.TemporalAccessor;
import java.io.IOException;
import java.math.BigDecimal;
/**
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
*
* @author Nick Williams
*/
public class CustomInstantDeserializer<T extends Temporal>
extends ThreeTenDateTimeDeserializerBase<T> {
private static final long serialVersionUID = 1L;
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
Instant.class, DateTimeFormatter.ISO_INSTANT,
new Function<TemporalAccessor, Instant>() {
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
return Instant.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, Instant>() {
@Override
public Instant apply(FromIntegerArguments a) {
return Instant.ofEpochMilli(a.value);
}
},
new Function<FromDecimalArguments, Instant>() {
@Override
public Instant apply(FromDecimalArguments a) {
return Instant.ofEpochSecond(a.integer, a.fraction);
}
},
null
);
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
new Function<TemporalAccessor, OffsetDateTime>() {
@Override
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
return OffsetDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromDecimalArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
@Override
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
}
}
);
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
new Function<TemporalAccessor, ZonedDateTime>() {
@Override
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
return ZonedDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromIntegerArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromDecimalArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
@Override
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
return zonedDateTime.withZoneSameInstant(zoneId);
}
}
);
protected final Function<FromIntegerArguments, T> fromMilliseconds;
protected final Function<FromDecimalArguments, T> fromNanoseconds;
protected final Function<TemporalAccessor, T> parsedToValue;
protected final BiFunction<T, ZoneId, T> adjust;
protected CustomInstantDeserializer(Class<T> supportedType,
DateTimeFormatter parser,
Function<TemporalAccessor, T> parsedToValue,
Function<FromIntegerArguments, T> fromMilliseconds,
Function<FromDecimalArguments, T> fromNanoseconds,
BiFunction<T, ZoneId, T> adjust) {
super(supportedType, parser);
this.parsedToValue = parsedToValue;
this.fromMilliseconds = fromMilliseconds;
this.fromNanoseconds = fromNanoseconds;
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
@Override
public T apply(T t, ZoneId zoneId) {
return t;
}
} : adjust;
}
@SuppressWarnings("unchecked")
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
super((Class<T>) base.handledType(), f);
parsedToValue = base.parsedToValue;
fromMilliseconds = base.fromMilliseconds;
fromNanoseconds = base.fromNanoseconds;
adjust = base.adjust;
}
@Override
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
if (dtf == _formatter) {
return this;
}
return new CustomInstantDeserializer<T>(this, dtf);
}
@Override
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
//string values have to be adjusted to the configured TZ.
switch (parser.getCurrentTokenId()) {
case JsonTokenId.ID_NUMBER_FLOAT: {
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return fromNanoseconds.apply(new FromDecimalArguments(
seconds, nanoseconds, getZone(context)));
}
case JsonTokenId.ID_NUMBER_INT: {
long timestamp = parser.getLongValue();
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
return this.fromNanoseconds.apply(new FromDecimalArguments(
timestamp, 0, this.getZone(context)
));
}
return this.fromMilliseconds.apply(new FromIntegerArguments(
timestamp, this.getZone(context)
));
}
case JsonTokenId.ID_STRING: {
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
if (string.endsWith("+0000")) {
string = string.substring(0, string.length() - 5) + "Z";
}
T value;
try {
TemporalAccessor acc = _formatter.parse(string);
value = parsedToValue.apply(acc);
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
return adjust.apply(value, this.getZone(context));
}
} catch (DateTimeException e) {
throw _peelDTE(e);
}
return value;
}
}
throw context.mappingException("Expected type float, integer, or string.");
}
private ZoneId getZone(DeserializationContext context) {
// Instants are always in UTC, so don't waste compute cycles
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
}
private static class FromIntegerArguments {
public final long value;
public final ZoneId zoneId;
private FromIntegerArguments(long value, ZoneId zoneId) {
this.value = value;
this.zoneId = zoneId;
}
}
private static class FromDecimalArguments {
public final long integer;
public final int fraction;
public final ZoneId zoneId;
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
this.integer = integer;
this.fraction = fraction;
this.zoneId = zoneId;
}
}
}

View File

@ -107,7 +107,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.8"
jackson_version = "2.7.5"
jackson_version = "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jersey_version = "1.19.1"
jodatime_version = "2.9.4"
junit_version = "4.12"
@ -121,13 +121,15 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
{{/joda}}
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
{{^java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
compile "joda-time:joda-time:$jodatime_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
{{/java8}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
{{/threetenbp}}
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"
}

View File

@ -5,16 +5,22 @@ import java.util.Map;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
{{#threetenbp}}
import org.threeten.bp.*;
{{/threetenbp}}
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
{{^java8}}
{{#joda}}
import com.fasterxml.jackson.datatype.joda.JodaModule;
{{/java8}}
{{/joda}}
{{#java8}}
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
{{/java8}}
{{#threetenbp}}
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
{{/threetenbp}}
import feign.Feign;
import feign.RequestInterceptor;
@ -137,12 +143,19 @@ public class ApiClient {
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setDateFormat(new RFC3339DateFormat());
{{^java8}}
{{#joda}}
objectMapper.registerModule(new JodaModule());
{{/java8}}
{{/joda}}
{{#java8}}
objectMapper.registerModule(new JavaTimeModule());
{{/java8}}
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
{{/threetenbp}}
return objectMapper;
}

View File

@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.9"
jackson_version = "2.7.5"
jackson_version = "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
feign_version = "8.17.0"
junit_version = "4.12"
oltu_version = "1.0.1"
@ -109,7 +109,15 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}:$jackson_version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
{{/joda}}
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
{{/java8}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
{{/threetenbp}}
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"

View File

@ -13,10 +13,18 @@ lazy val root = (project in file(".")).
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
"com.netflix.feign" % "feign-slf4j" % "8.16.0" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5" % "compile",
{{/joda}}
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5" % "compile",
{{/java8}}
{{#threetenbp}}
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
{{/threetenbp}}
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
"com.brsanthu" % "migbase64" % "2.2" % "compile",
"junit" % "junit" % "4.12" % "test",

View File

@ -142,11 +142,27 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}</artifactId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/joda}}
{{#java8}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/java8}}
{{#threetenbp}}
<dependency>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/threetenbp}}
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
@ -167,7 +183,7 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.9</swagger-core-version>
<feign-version>8.17.0</feign-version>
<jackson-version>2.7.5</jackson-version>
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
<junit-version>4.12</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<oltu-version>1.0.1</oltu-version>

View File

@ -1,13 +1,19 @@
package {{invokerPackage}};
{{#threetenbp}}
import org.threeten.bp.*;
{{/threetenbp}}
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
{{#java8}}
import com.fasterxml.jackson.datatype.jsr310.*;
{{/java8}}
{{^java8}}
import com.fasterxml.jackson.datatype.joda.*;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
{{/java8}}
{{#joda}}
import com.fasterxml.jackson.datatype.joda.JodaModule;
{{/joda}}
{{#threetenbp}}
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
{{/threetenbp}}
import java.text.DateFormat;
@ -28,9 +34,16 @@ public class JSON implements ContextResolver<ObjectMapper> {
{{#java8}}
mapper.registerModule(new JavaTimeModule());
{{/java8}}
{{^java8}}
{{#joda}}
mapper.registerModule(new JodaModule());
{{/java8}}
{{/joda}}
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
mapper.registerModule(module);
{{/threetenbp}}
}
/**

View File

@ -108,9 +108,6 @@ ext {
swagger_annotations_version = "1.5.8"
jackson_version = "2.7.5"
jersey_version = "2.22.2"
{{^java8}}
jodatime_version = "2.9.4"
{{/java8}}
{{#supportJava6}}
commons_io_version=2.5
commons_lang3_version=3.5
@ -126,17 +123,19 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
{{/joda}}
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
{{^java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
compile "joda-time:joda-time:$jodatime_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
{{/java8}}
{{#supportJava6}}
compile "commons-io:commons-io:$commons_io_version"
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/supportJava6}}
{{#threetenbp}}
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
{{/threetenbp}}
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"
}

View File

@ -13,16 +13,18 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.core" % "jersey-client" % "2.22.2",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.22.2",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.22.2",
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
{{#joda}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5" % "compile",
{{/joda}}
{{#java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5",
{{/java8}}
{{^java8}}
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5",
"joda-time" % "joda-time" % "2.9.4",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5" % "compile",
{{/java8}}
{{#threetenbp}}
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
{{/threetenbp}}
"com.brsanthu" % "migbase64" % "2.2",
{{#supportJava6}}
"org.apache.commons" % "commons-lang3" % "3.5",

View File

@ -157,6 +157,13 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/joda}}
{{#java8}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
@ -164,18 +171,13 @@
<version>${jackson-version}</version>
</dependency>
{{/java8}}
{{^java8}}
{{#threetenbp}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
{{/java8}}
{{/threetenbp}}
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
@ -208,14 +210,11 @@
<properties>
<swagger-core-version>1.5.9</swagger-core-version>
<jersey-version>2.22.2</jersey-version>
<jackson-version>2.7.5</jackson-version>
{{^java8}}
<jodatime-version>2.9.4</jodatime-version>
{{/java8}}
{{#supportJava6}}
<commons_io_version>2.5</commons_io_version>
<commons_lang3_version>3.5</commons_lang3_version>
{{/supportJava6}}
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>
</properties>

View File

@ -13,6 +13,11 @@ import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
{{/joda}}
{{#threetenbp}}
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
{{/threetenbp}}
import javax.net.ssl.*;
import java.io.File;
@ -210,7 +215,7 @@ public class ApiClient {
}
{{/joda}}
{{#java8}}
{{#jsr310}}
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat);
return this;
@ -221,7 +226,7 @@ public class ApiClient {
return this;
}
{{/java8}}
{{/jsr310}}
public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson);
return this;
@ -427,7 +432,7 @@ public class ApiClient {
public String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#java8}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/java8}}) {
} else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) {
//Serialize to json string and remove the " enclosing characters
String jsonStr = json.serialize(param);
return jsonStr.substring(1, jsonStr.length() - 1);

View File

@ -15,6 +15,11 @@ import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
{{/joda}}
{{#threetenbp}}
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
{{/threetenbp}}
import java.io.IOException;
import java.io.StringReader;
@ -38,10 +43,10 @@ public class JSON {
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
{{/joda}}
{{#java8}}
{{#jsr310}}
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
{{/java8}}
{{/jsr310}}
public JSON() {
gson = new GsonBuilder()
@ -51,10 +56,10 @@ public class JSON {
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
{{/joda}}
{{#java8}}
{{#jsr310}}
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
{{/java8}}
{{/jsr310}}
.create();
}
@ -215,7 +220,7 @@ public class JSON {
}
{{/joda}}
{{#java8}}
{{#jsr310}}
/**
* Gson TypeAdapter for JSR310 OffsetDateTime type
*/
@ -311,7 +316,7 @@ public class JSON {
return this;
}
{{/java8}}
{{/jsr310}}
/**
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used

View File

@ -98,8 +98,11 @@ dependencies {
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.6.2'
{{^java8}}
{{#joda}}
compile 'joda-time:joda-time:2.9.3'
{{/java8}}
{{/joda}}
{{#threetenbp}}
compile 'org.threeten:threetenbp:1.3.2'
{{/threetenbp}}
testCompile 'junit:junit:4.12'
}

View File

@ -13,9 +13,12 @@ lazy val root = (project in file(".")).
"com.squareup.okhttp" % "okhttp" % "2.7.5",
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
"com.google.code.gson" % "gson" % "2.6.2",
{{^java8}}
{{#joda}}
"joda-time" % "joda-time" % "2.9.3" % "compile",
{{/java8}}
{{/joda}}
{{#threetenbp}}
"org.threeten" % "threetenbp" % "1.3.2" % "compile",
{{/threetenbp}}
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)

View File

@ -124,14 +124,21 @@
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
{{^java8}}
{{#joda}}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
{{/java8}}
{{#useBeanValidation}}
{{/joda}}
{{#threetenbp}}
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>${threetenbp-version}</version>
</dependency>
{{/threetenbp}}
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
@ -139,7 +146,7 @@
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
{{/useBeanValidation}}
<!-- test dependencies -->
<dependency>
@ -156,9 +163,14 @@
<swagger-core-version>1.5.9</swagger-core-version>
<okhttp-version>2.7.5</okhttp-version>
<gson-version>2.6.2</gson-version>
{{#joda}}
<jodatime-version>2.9.3</jodatime-version>
{{/joda}}
{{#threetenbp}}
<threetenbp-version>1.3.2</threetenbp-version>
{{/threetenbp}}
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>

View File

@ -11,6 +11,9 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
{{#joda}}
import org.joda.time.format.DateTimeFormatter;
{{/joda}}
{{#threetenbp}}
import org.threeten.bp.format.DateTimeFormatter;
{{/threetenbp}}
import retrofit2.Converter;
import retrofit2.Retrofit;
{{#useRxJava}}
@ -156,7 +159,7 @@ public class ApiClient {
}
{{/joda}}
{{#java8}}
{{#jsr310}}
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
this.json.setOffsetDateTimeFormat(dateFormat);
return this;
@ -167,7 +170,7 @@ public class ApiClient {
return this;
}
{{/java8}}
{{/jsr310}}
/**
* Helper method to configure the first api key found

View File

@ -15,6 +15,11 @@ import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
{{/joda}}
{{#threetenbp}}
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
{{/threetenbp}}
import java.io.IOException;
import java.io.StringReader;
@ -37,10 +42,10 @@ public class JSON {
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
{{/joda}}
{{#java8}}
{{#jsr310}}
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
{{/java8}}
{{/jsr310}}
public JSON() {
gson = new GsonBuilder()
@ -50,10 +55,10 @@ public class JSON {
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
{{/joda}}
{{#java8}}
{{#jsr310}}
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
{{/java8}}
{{/jsr310}}
.create();
}
@ -171,7 +176,7 @@ public class JSON {
}
{{/joda}}
{{#java8}}
{{#jsr310}}
/**
* Gson TypeAdapter for JSR310 OffsetDateTime type
*/
@ -267,7 +272,7 @@ public class JSON {
return this;
}
{{/java8}}
{{/jsr310}}
/**
* Gson TypeAdapter for java.sql.Date type
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used

View File

@ -101,9 +101,12 @@ ext {
{{#useRxJava}}
rx_java_version = "1.1.3"
{{/useRxJava}}
{{^java8}}
{{#joda}}
jodatime_version = "2.9.3"
{{/java8}}
{{/joda}}
{{#threetenbp}}
threetenbp_version = "1.3.2"
{{/threetenbp}}
}
dependencies {
@ -116,9 +119,12 @@ dependencies {
{{/useRxJava}}
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
{{^java8}}
compile "joda-time:joda-time:$jodatime_version"
{{/java8}}
{{#joda}}
compile 'joda-time:joda-time:$jodatime_version'
{{/joda}}
{{#threetenbp}}
compile 'org.threeten:threetenbp:$threetenbp_version'
{{/threetenbp}}
testCompile "junit:junit:$junit_version"
}

View File

@ -18,9 +18,12 @@ lazy val root = (project in file(".")).
{{/useRxJava}}
"io.swagger" % "swagger-annotations" % "1.5.8" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
{{^java8}}
{{#joda}}
"joda-time" % "joda-time" % "2.9.3" % "compile",
{{/java8}}
{{/joda}}
{{#threetenbp}}
"org.threeten" % "threetenbp" % "1.3.2" % "compile",
{{/threetenbp}}
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"
)

View File

@ -129,13 +129,20 @@
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>${oltu-version}</version>
</dependency>
{{^java8}}
{{#joda}}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
{{/java8}}
{{/joda}}
{{#threetenbp}}
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>${threetenbp-version}</version>
</dependency>
{{/threetenbp}}
{{#useRxJava}}
<dependency>
<groupId>io.reactivex</groupId>
@ -167,9 +174,12 @@
{{#useRxJava}}
<rxjava-version>1.1.6</rxjava-version>
{{/useRxJava}}
{{^java8}}
<jodatime-version>2.9.4</jodatime-version>
{{/java8}}
{{#joda}}
<jodatime-version>2.9.3</jodatime-version>
{{/joda}}
{{#threetenbp}}
<threetenbp-version>1.3.2</threetenbp-version>
{{/threetenbp}}
<oltu-version>1.0.1</oltu-version>
<junit-version>4.12</junit-version>
</properties>

View File

@ -154,6 +154,13 @@
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-version}</version>
</dependency>
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/joda}}
{{#java8}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
@ -161,18 +168,13 @@
<version>${jackson-version}</version>
</dependency>
{{/java8}}
{{^java8}}
{{#threetenbp}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
{{/java8}}
{{/threetenbp}}
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
@ -215,14 +217,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<jersey-version>1.19.1</jersey-version>
<jackson-version>2.7.5</jackson-version>
{{^java8}}
<jodatime-version>2.9.4</jodatime-version>
{{/java8}}
{{#supportJava6}}
<commons_io_version>2.5</commons_io_version>
<commons_lang3_version>3.5</commons_lang3_version>
{{/supportJava6}}
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>
</properties>

View File

@ -0,0 +1,232 @@
package {{configPackage}};
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
import org.threeten.bp.DateTimeException;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZonedDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.Temporal;
import org.threeten.bp.temporal.TemporalAccessor;
import java.io.IOException;
import java.math.BigDecimal;
/**
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
*
* @author Nick Williams
*/
public class CustomInstantDeserializer<T extends Temporal>
extends ThreeTenDateTimeDeserializerBase<T> {
private static final long serialVersionUID = 1L;
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
Instant.class, DateTimeFormatter.ISO_INSTANT,
new Function<TemporalAccessor, Instant>() {
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
return Instant.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, Instant>() {
@Override
public Instant apply(FromIntegerArguments a) {
return Instant.ofEpochMilli(a.value);
}
},
new Function<FromDecimalArguments, Instant>() {
@Override
public Instant apply(FromDecimalArguments a) {
return Instant.ofEpochSecond(a.integer, a.fraction);
}
},
null
);
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
new Function<TemporalAccessor, OffsetDateTime>() {
@Override
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
return OffsetDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromDecimalArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
@Override
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
}
}
);
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
new Function<TemporalAccessor, ZonedDateTime>() {
@Override
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
return ZonedDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromIntegerArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromDecimalArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
@Override
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
return zonedDateTime.withZoneSameInstant(zoneId);
}
}
);
protected final Function<FromIntegerArguments, T> fromMilliseconds;
protected final Function<FromDecimalArguments, T> fromNanoseconds;
protected final Function<TemporalAccessor, T> parsedToValue;
protected final BiFunction<T, ZoneId, T> adjust;
protected CustomInstantDeserializer(Class<T> supportedType,
DateTimeFormatter parser,
Function<TemporalAccessor, T> parsedToValue,
Function<FromIntegerArguments, T> fromMilliseconds,
Function<FromDecimalArguments, T> fromNanoseconds,
BiFunction<T, ZoneId, T> adjust) {
super(supportedType, parser);
this.parsedToValue = parsedToValue;
this.fromMilliseconds = fromMilliseconds;
this.fromNanoseconds = fromNanoseconds;
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
@Override
public T apply(T t, ZoneId zoneId) {
return t;
}
} : adjust;
}
@SuppressWarnings("unchecked")
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
super((Class<T>) base.handledType(), f);
parsedToValue = base.parsedToValue;
fromMilliseconds = base.fromMilliseconds;
fromNanoseconds = base.fromNanoseconds;
adjust = base.adjust;
}
@Override
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
if (dtf == _formatter) {
return this;
}
return new CustomInstantDeserializer<T>(this, dtf);
}
@Override
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
//string values have to be adjusted to the configured TZ.
switch (parser.getCurrentTokenId()) {
case JsonTokenId.ID_NUMBER_FLOAT: {
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return fromNanoseconds.apply(new FromDecimalArguments(
seconds, nanoseconds, getZone(context)));
}
case JsonTokenId.ID_NUMBER_INT: {
long timestamp = parser.getLongValue();
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
return this.fromNanoseconds.apply(new FromDecimalArguments(
timestamp, 0, this.getZone(context)
));
}
return this.fromMilliseconds.apply(new FromIntegerArguments(
timestamp, this.getZone(context)
));
}
case JsonTokenId.ID_STRING: {
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
if (string.endsWith("+0000")) {
string = string.substring(0, string.length() - 5) + "Z";
}
T value;
try {
TemporalAccessor acc = _formatter.parse(string);
value = parsedToValue.apply(acc);
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
return adjust.apply(value, this.getZone(context));
}
} catch (DateTimeException e) {
throw _peelDTE(e);
}
return value;
}
}
throw context.mappingException("Expected type float, integer, or string.");
}
private ZoneId getZone(DeserializationContext context) {
// Instants are always in UTC, so don't waste compute cycles
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
}
private static class FromIntegerArguments {
public final long value;
public final ZoneId zoneId;
private FromIntegerArguments(long value, ZoneId zoneId) {
this.value = value;
this.zoneId = zoneId;
}
}
private static class FromDecimalArguments {
public final long integer;
public final int fraction;
public final ZoneId zoneId;
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
this.integer = integer;
this.fraction = fraction;
this.zoneId = zoneId;
}
}
}

View File

@ -0,0 +1,23 @@
package {{configPackage}};
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZonedDateTime;
@Configuration
public class JacksonConfiguration {
@Bean
@ConditionalOnMissingBean(ThreeTenModule.class)
ThreeTenModule threeTenModule() {
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
return module;
}
}

View File

@ -62,16 +62,20 @@
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
{{/java8}}
{{^java8}}
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
{{/joda}}
{{#threetenbp}}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.6.4</version>
</dependency>
{{/java8}}
{{/threetenbp}}
</dependencies>
</project>

View File

@ -0,0 +1,23 @@
package {{configPackage}};
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZonedDateTime;
@Configuration
public class JacksonConfiguration {
@Bean
@ConditionalOnMissingBean(ThreeTenModule.class)
ThreeTenModule threeTenModule() {
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
return module;
}
}

View File

@ -57,17 +57,21 @@
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
{{/java8}}
{{^java8}}
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
{{/joda}}
{{#threetenbp}}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.6.4</version>
</dependency>
{{/java8}}
{{/threetenbp}}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -93,32 +93,42 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
{{#java8}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/java8}}
{{^java8}}
{{#joda}}
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/joda}}
{{#threetenbp}}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
{{/java8}}
{{/threetenbp}}
<dependency>
<groupId>junit</groupId>
@ -140,8 +150,8 @@
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<springfox-version>2.4.0</springfox-version>
<jackson-version>2.4.5</jackson-version>
<springfox-version>2.6.0</springfox-version>
<jackson-version>2.6.4</jackson-version>
<spring-version>4.2.5.RELEASE</spring-version>
</properties>
</project>

View File

@ -2,6 +2,9 @@ package {{configPackage}};
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
{{#threetenbp}}
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
{{/threetenbp}}
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@ -12,6 +15,11 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
{{#threetenbp}}
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZonedDateTime;
{{/threetenbp}}
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.List;
@ -62,8 +70,15 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat( new RFC3339DateFormat())
.dateFormat(new RFC3339DateFormat())
.build();
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
{{/threetenbp}}
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
super.configureMessageConverters(converters);
}

View File

@ -36,10 +36,14 @@ public class SwaggerDocumentationConfig {
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
{{/java8}}
{{^java8}}
{{#joda}}
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
{{/java8}}
{{/joda}}
{{#threetenbp}}
.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
{{/threetenbp}}
.apiInfo(apiInfo());
}

View File

@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.9"
jackson_version = "2.7.5"
jackson_version = "2.6.4"
feign_version = "8.17.0"
junit_version = "4.12"
oltu_version = "1.0.1"
@ -106,10 +106,7 @@ dependencies {
compile "com.netflix.feign:feign-core:$feign_version"
compile "com.netflix.feign:feign-jackson:$feign_version"
compile "com.netflix.feign:feign-slf4j:$feign_version"
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"

View File

@ -13,10 +13,7 @@ lazy val root = (project in file(".")).
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
"com.netflix.feign" % "feign-slf4j" % "8.16.0" % "compile",
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5" % "compile",
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
"com.brsanthu" % "migbase64" % "2.2" % "compile",
"junit" % "junit" % "4.12" % "test",

View File

@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -128,23 +128,8 @@
<!-- JSON processing: jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
@ -167,7 +152,7 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.9</swagger-core-version>
<feign-version>8.17.0</feign-version>
<jackson-version>2.7.5</jackson-version>
<jackson-version>2.6.4</jackson-version>
<junit-version>4.12</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<oltu-version>1.0.1</oltu-version>

View File

@ -5,11 +5,14 @@ import java.util.Map;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZonedDateTime;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
import feign.Feign;
import feign.RequestInterceptor;
@ -133,7 +136,11 @@ public class ApiClient {
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setDateFormat(new RFC3339DateFormat());
objectMapper.registerModule(new JodaModule());
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
return objectMapper;
}

View File

@ -0,0 +1,232 @@
package io.swagger.client;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
import org.threeten.bp.DateTimeException;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZonedDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.Temporal;
import org.threeten.bp.temporal.TemporalAccessor;
import java.io.IOException;
import java.math.BigDecimal;
/**
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
*
* @author Nick Williams
*/
public class CustomInstantDeserializer<T extends Temporal>
extends ThreeTenDateTimeDeserializerBase<T> {
private static final long serialVersionUID = 1L;
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
Instant.class, DateTimeFormatter.ISO_INSTANT,
new Function<TemporalAccessor, Instant>() {
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
return Instant.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, Instant>() {
@Override
public Instant apply(FromIntegerArguments a) {
return Instant.ofEpochMilli(a.value);
}
},
new Function<FromDecimalArguments, Instant>() {
@Override
public Instant apply(FromDecimalArguments a) {
return Instant.ofEpochSecond(a.integer, a.fraction);
}
},
null
);
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
new Function<TemporalAccessor, OffsetDateTime>() {
@Override
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
return OffsetDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromDecimalArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
@Override
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
}
}
);
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
new Function<TemporalAccessor, ZonedDateTime>() {
@Override
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
return ZonedDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromIntegerArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromDecimalArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
@Override
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
return zonedDateTime.withZoneSameInstant(zoneId);
}
}
);
protected final Function<FromIntegerArguments, T> fromMilliseconds;
protected final Function<FromDecimalArguments, T> fromNanoseconds;
protected final Function<TemporalAccessor, T> parsedToValue;
protected final BiFunction<T, ZoneId, T> adjust;
protected CustomInstantDeserializer(Class<T> supportedType,
DateTimeFormatter parser,
Function<TemporalAccessor, T> parsedToValue,
Function<FromIntegerArguments, T> fromMilliseconds,
Function<FromDecimalArguments, T> fromNanoseconds,
BiFunction<T, ZoneId, T> adjust) {
super(supportedType, parser);
this.parsedToValue = parsedToValue;
this.fromMilliseconds = fromMilliseconds;
this.fromNanoseconds = fromNanoseconds;
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
@Override
public T apply(T t, ZoneId zoneId) {
return t;
}
} : adjust;
}
@SuppressWarnings("unchecked")
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
super((Class<T>) base.handledType(), f);
parsedToValue = base.parsedToValue;
fromMilliseconds = base.fromMilliseconds;
fromNanoseconds = base.fromNanoseconds;
adjust = base.adjust;
}
@Override
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
if (dtf == _formatter) {
return this;
}
return new CustomInstantDeserializer<T>(this, dtf);
}
@Override
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
//string values have to be adjusted to the configured TZ.
switch (parser.getCurrentTokenId()) {
case JsonTokenId.ID_NUMBER_FLOAT: {
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return fromNanoseconds.apply(new FromDecimalArguments(
seconds, nanoseconds, getZone(context)));
}
case JsonTokenId.ID_NUMBER_INT: {
long timestamp = parser.getLongValue();
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
return this.fromNanoseconds.apply(new FromDecimalArguments(
timestamp, 0, this.getZone(context)
));
}
return this.fromMilliseconds.apply(new FromIntegerArguments(
timestamp, this.getZone(context)
));
}
case JsonTokenId.ID_STRING: {
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
if (string.endsWith("+0000")) {
string = string.substring(0, string.length() - 5) + "Z";
}
T value;
try {
TemporalAccessor acc = _formatter.parse(string);
value = parsedToValue.apply(acc);
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
return adjust.apply(value, this.getZone(context));
}
} catch (DateTimeException e) {
throw _peelDTE(e);
}
return value;
}
}
throw context.mappingException("Expected type float, integer, or string.");
}
private ZoneId getZone(DeserializationContext context) {
// Instants are always in UTC, so don't waste compute cycles
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
}
private static class FromIntegerArguments {
public final long value;
public final ZoneId zoneId;
private FromIntegerArguments(long value, ZoneId zoneId) {
this.value = value;
this.zoneId = zoneId;
}
}
private static class FromDecimalArguments {
public final long integer;
public final int fraction;
public final ZoneId zoneId;
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
this.integer = integer;
this.fraction = fraction;
this.zoneId = zoneId;
}
}
}

View File

@ -1,4 +1,4 @@
/**
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*

View File

@ -3,9 +3,9 @@ package io.swagger.client.api;
import io.swagger.client.ApiClient;
import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.LocalDate;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.HashMap;
@ -46,6 +46,7 @@ public interface FakeApi extends ApiClient.Api {
* @param date None (optional)
* @param dateTime None (optional)
* @param password None (optional)
* @param paramCallback None (optional)
* @return void
*/
@RequestLine("POST /fake")
@ -53,7 +54,7 @@ public interface FakeApi extends ApiClient.Api {
"Content-type: application/xml; charset&#x3D;utf-8",
"Accept: application/xml; charset&#x3D;utf-8,application/json; charset&#x3D;utf-8",
})
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") byte[] binary, @Param("date") LocalDate date, @Param("dateTime") DateTime dateTime, @Param("password") String password);
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") byte[] binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback);
/**
* To test enum parameters

View File

@ -0,0 +1,29 @@
package io.swagger.client.api;
import io.swagger.client.ApiClient;
import io.swagger.client.model.Client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import feign.*;
public interface FakeclassnametagsApi extends ApiClient.Api {
/**
* To test class name in snake case
*
* @param body client model (required)
* @return Client
*/
@RequestLine("PATCH /fake_classname_test")
@Headers({
"Content-type: application/json",
"Accept: application/json",
})
Client testClassname(Client body);
}

View File

@ -34,12 +34,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* AdditionalPropertiesClass
*/
public class AdditionalPropertiesClass {
public class AdditionalPropertiesClass {
@JsonProperty("map_property")
private Map<String, String> mapProperty = new HashMap<String, String>();
@ -132,5 +131,6 @@ public class AdditionalPropertiesClass {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Animal
*/
public class Animal {
public class Animal {
@JsonProperty("className")
private String className = null;
@ -119,5 +118,6 @@ public class Animal {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -30,12 +30,11 @@ import io.swagger.client.model.Animal;
import java.util.ArrayList;
import java.util.List;
/**
* AnimalFarm
*/
public class AnimalFarm extends ArrayList<Animal> {
public class AnimalFarm extends ArrayList<Animal> {
@Override
public boolean equals(java.lang.Object o) {
@ -72,5 +71,6 @@ public class AnimalFarm extends ArrayList<Animal> {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -34,12 +34,11 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* ArrayOfArrayOfNumberOnly
*/
public class ArrayOfArrayOfNumberOnly {
public class ArrayOfArrayOfNumberOnly {
@JsonProperty("ArrayArrayNumber")
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<List<BigDecimal>>();
@ -104,5 +103,6 @@ public class ArrayOfArrayOfNumberOnly {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -34,12 +34,11 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* ArrayOfNumberOnly
*/
public class ArrayOfNumberOnly {
public class ArrayOfNumberOnly {
@JsonProperty("ArrayNumber")
private List<BigDecimal> arrayNumber = new ArrayList<BigDecimal>();
@ -104,5 +103,6 @@ public class ArrayOfNumberOnly {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -34,12 +34,11 @@ import io.swagger.client.model.ReadOnlyFirst;
import java.util.ArrayList;
import java.util.List;
/**
* ArrayTest
*/
public class ArrayTest {
public class ArrayTest {
@JsonProperty("array_of_string")
private List<String> arrayOfString = new ArrayList<String>();
@ -160,5 +159,6 @@ public class ArrayTest {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.client.model.Animal;
/**
* Cat
*/
public class Cat extends Animal {
public class Cat extends Animal {
@JsonProperty("declawed")
private Boolean declawed = null;
@ -98,5 +97,6 @@ public class Cat extends Animal {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Category
*/
public class Category {
public class Category {
@JsonProperty("id")
private Long id = null;
@ -119,5 +118,6 @@ public class Category {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Client
*/
public class Client {
public class Client {
@JsonProperty("client")
private String client = null;
@ -96,5 +95,6 @@ public class Client {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.client.model.Animal;
/**
* Dog
*/
public class Dog extends Animal {
public class Dog extends Animal {
@JsonProperty("breed")
private String breed = null;
@ -98,5 +97,6 @@ public class Dog extends Animal {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -33,12 +33,11 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
/**
* EnumArrays
*/
public class EnumArrays {
public class EnumArrays {
/**
* Gets or Sets justSymbol
*/
@ -186,5 +185,6 @@ public class EnumArrays {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -27,7 +27,6 @@ package io.swagger.client.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonCreator;
/**

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* EnumTest
*/
public class EnumTest {
public class EnumTest {
/**
* Gets or Sets enumString
*/
@ -232,5 +231,6 @@ public class EnumTest {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -32,15 +32,14 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.UUID;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
/**
* FormatTest
*/
public class FormatTest {
public class FormatTest {
@JsonProperty("integer")
private Integer integer = null;
@ -72,7 +71,7 @@ public class FormatTest {
private LocalDate date = null;
@JsonProperty("dateTime")
private DateTime dateTime = null;
private OffsetDateTime dateTime = null;
@JsonProperty("uuid")
private UUID uuid = null;
@ -270,7 +269,7 @@ public class FormatTest {
this.date = date;
}
public FormatTest dateTime(DateTime dateTime) {
public FormatTest dateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -280,11 +279,11 @@ public class FormatTest {
* @return dateTime
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getDateTime() {
public OffsetDateTime getDateTime() {
return dateTime;
}
public void setDateTime(DateTime dateTime) {
public void setDateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
}
@ -386,5 +385,6 @@ public class FormatTest {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* HasOnlyReadOnly
*/
public class HasOnlyReadOnly {
public class HasOnlyReadOnly {
@JsonProperty("bar")
private String bar = null;
@ -101,5 +100,6 @@ public class HasOnlyReadOnly {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -34,12 +34,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* MapTest
*/
public class MapTest {
public class MapTest {
@JsonProperty("map_map_of_string")
private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, String>>();
@ -162,5 +161,6 @@ public class MapTest {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -35,19 +35,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.joda.time.DateTime;
import org.threeten.bp.OffsetDateTime;
/**
* MixedPropertiesAndAdditionalPropertiesClass
*/
public class MixedPropertiesAndAdditionalPropertiesClass {
public class MixedPropertiesAndAdditionalPropertiesClass {
@JsonProperty("uuid")
private UUID uuid = null;
@JsonProperty("dateTime")
private DateTime dateTime = null;
private OffsetDateTime dateTime = null;
@JsonProperty("map")
private Map<String, Animal> map = new HashMap<String, Animal>();
@ -70,7 +69,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
this.uuid = uuid;
}
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -80,11 +79,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
* @return dateTime
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getDateTime() {
public OffsetDateTime getDateTime() {
return dateTime;
}
public void setDateTime(DateTime dateTime) {
public void setDateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
}
@ -153,5 +152,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Model for testing model name starting with number
*/
@ApiModel(description = "Model for testing model name starting with number")
public class Model200Response {
public class Model200Response {
@JsonProperty("name")
private Integer name = null;
@ -120,5 +119,6 @@ public class Model200Response {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* ModelApiResponse
*/
public class ModelApiResponse {
public class ModelApiResponse {
@JsonProperty("code")
private Integer code = null;
@ -142,5 +141,6 @@ public class ModelApiResponse {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Model for testing reserved words
*/
@ApiModel(description = "Model for testing reserved words")
public class ModelReturn {
public class ModelReturn {
@JsonProperty("return")
private Integer _return = null;
@ -97,5 +96,6 @@ public class ModelReturn {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Model for testing model name same as property name
*/
@ApiModel(description = "Model for testing model name same as property name")
public class Name {
public class Name {
@JsonProperty("name")
private Integer name = null;
@ -148,5 +147,6 @@ public class Name {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
/**
* NumberOnly
*/
public class NumberOnly {
public class NumberOnly {
@JsonProperty("JustNumber")
private BigDecimal justNumber = null;
@ -97,5 +96,6 @@ public class NumberOnly {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -30,14 +30,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;
import org.threeten.bp.OffsetDateTime;
/**
* Order
*/
public class Order {
public class Order {
@JsonProperty("id")
private Long id = null;
@ -48,7 +47,7 @@ public class Order {
private Integer quantity = null;
@JsonProperty("shipDate")
private DateTime shipDate = null;
private OffsetDateTime shipDate = null;
/**
* Order Status
@ -142,7 +141,7 @@ public class Order {
this.quantity = quantity;
}
public Order shipDate(DateTime shipDate) {
public Order shipDate(OffsetDateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ -152,11 +151,11 @@ public class Order {
* @return shipDate
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getShipDate() {
public OffsetDateTime getShipDate() {
return shipDate;
}
public void setShipDate(DateTime shipDate) {
public void setShipDate(OffsetDateTime shipDate) {
this.shipDate = shipDate;
}
@ -244,5 +243,6 @@ public class Order {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -35,12 +35,11 @@ import io.swagger.client.model.Tag;
import java.util.ArrayList;
import java.util.List;
/**
* Pet
*/
public class Pet {
public class Pet {
@JsonProperty("id")
private Long id = null;
@ -257,5 +256,6 @@ public class Pet {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* ReadOnlyFirst
*/
public class ReadOnlyFirst {
public class ReadOnlyFirst {
@JsonProperty("bar")
private String bar = null;
@ -110,5 +109,6 @@ public class ReadOnlyFirst {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* SpecialModelName
*/
public class SpecialModelName {
public class SpecialModelName {
@JsonProperty("$special[property.name]")
private Long specialPropertyName = null;
@ -96,5 +95,6 @@ public class SpecialModelName {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Tag
*/
public class Tag {
public class Tag {
@JsonProperty("id")
private Long id = null;
@ -119,5 +118,6 @@ public class Tag {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* User
*/
public class User {
public class User {
@JsonProperty("id")
private Long id = null;
@ -257,5 +256,6 @@ public class User {
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,9 +1,10 @@
package io.swagger.client.api;
import io.swagger.client.ApiClient;
import org.joda.time.LocalDate;
import io.swagger.client.model.Client;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.LocalDate;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
@ -25,6 +26,19 @@ public class FakeApiTest {
}
/**
* To test \&quot;client\&quot; model
*
*
*/
@Test
public void testClientModelTest() {
Client body = null;
// Client response = api.testClientModel(body);
// TODO: test validations
}
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*
@ -34,17 +48,39 @@ public class FakeApiTest {
public void testEndpointParametersTest() {
BigDecimal number = null;
Double _double = null;
String string = null;
String patternWithoutDelimiter = null;
byte[] _byte = null;
Integer integer = null;
Integer int32 = null;
Long int64 = null;
Float _float = null;
String string = null;
byte[] binary = null;
LocalDate date = null;
DateTime dateTime = null;
OffsetDateTime dateTime = null;
String password = null;
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
String paramCallback = null;
// api.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
// TODO: test validations
}
/**
* To test enum parameters
*
*
*/
@Test
public void testEnumParametersTest() {
List<String> enumFormStringArray = null;
String enumFormString = null;
List<String> enumHeaderStringArray = null;
String enumHeaderString = null;
List<String> enumQueryStringArray = null;
String enumQueryString = null;
BigDecimal enumQueryInteger = null;
Double enumQueryDouble = null;
// api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
// TODO: test validations
}

View File

@ -0,0 +1,39 @@
package io.swagger.client.api;
import io.swagger.client.ApiClient;
import io.swagger.client.model.Client;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* API tests for FakeclassnametagsApi
*/
public class FakeclassnametagsApiTest {
private FakeclassnametagsApi api;
@Before
public void setup() {
api = new ApiClient().buildClient(FakeclassnametagsApi.class);
}
/**
* To test class name in snake case
*
*
*/
@Test
public void testClassnameTest() {
Client body = null;
// Client response = api.testClassname(body);
// TODO: test validations
}
}

View File

@ -3,7 +3,6 @@ package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiClient;
import io.swagger.client.api.*;
import io.swagger.client.model.*;
import java.io.BufferedWriter;
@ -11,14 +10,15 @@ import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.*;
import static org.junit.Assert.*;
public class PetApiTest {
ApiClient apiClient;
PetApi api;
private ApiClient apiClient;
private PetApi api;
@Before
public void setup() {
@ -71,7 +71,7 @@ public class PetApiTest {
api.updatePet(pet);
List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
List<Pet> pets = api.findPetsByStatus(Collections.singletonList("available"));
assertNotNull(pets);
boolean found = false;
@ -91,7 +91,7 @@ public class PetApiTest {
pet.setName("monster");
pet.setStatus(Pet.StatusEnum.AVAILABLE);
List<Tag> tags = new ArrayList<Tag>();
List<Tag> tags = new ArrayList<>();
Tag tag1 = new Tag();
tag1.setName("friendly");
tags.add(tag1);
@ -99,7 +99,7 @@ public class PetApiTest {
api.updatePet(pet);
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
List<Pet> pets = api.findPetsByTags(Collections.singletonList("friendly"));
assertNotNull(pets);
boolean found = false;
@ -135,7 +135,7 @@ public class PetApiTest {
api.deletePet(fetched.getId(), null);
try {
fetched = api.getPetById(fetched.getId());
api.getPetById(fetched.getId());
fail("expected an error");
} catch (Exception e) {
// assertEquals(404, e.getCode());
@ -166,7 +166,7 @@ public class PetApiTest {
assertTrue(pet1.hashCode() == pet1.hashCode());
pet2.setName("really-happy");
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
pet2.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
assertFalse(pet1.equals(pet2));
assertFalse(pet2.equals(pet1));
assertFalse(pet1.hashCode() == (pet2.hashCode()));
@ -174,7 +174,7 @@ public class PetApiTest {
assertTrue(pet2.hashCode() == pet2.hashCode());
pet1.setName("really-happy");
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
pet1.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
@ -192,7 +192,7 @@ public class PetApiTest {
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.AVAILABLE);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
List<String> photos = Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2");
pet.setPhotoUrls(photos);
return pet;

View File

@ -11,15 +11,16 @@ import java.lang.reflect.Field;
import java.util.Map;
import org.junit.*;
import org.threeten.bp.OffsetDateTime;
import static org.junit.Assert.*;
public class StoreApiTest {
ApiClient apiClient;
StoreApi api;
private StoreApi api;
@Before
public void setup() {
apiClient = new ApiClient();
ApiClient apiClient = new ApiClient();
api = apiClient.buildClient(StoreApi.class);
}
@ -38,7 +39,7 @@ public class StoreApiTest {
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertEquals(order.getShipDate().toInstant(), fetched.getShipDate().toInstant());
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
}
@Test
@ -61,9 +62,10 @@ public class StoreApiTest {
private Order createOrder() {
Order order = new Order();
order.setPetId(new Long(200));
order.setQuantity(new Integer(13));
order.setShipDate(org.joda.time.DateTime.now());
order.setPetId(200L);
order.setQuantity(13);
//Ensure 3 fractional digits because of a bug in the petstore server
order.setShipDate(OffsetDateTime.now().withNano(123000000));
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);

View File

@ -3,7 +3,6 @@ package io.swagger.client.api;
import io.swagger.TestUtils;
import io.swagger.client.ApiClient;
import io.swagger.client.api.*;
import io.swagger.client.model.*;
import java.util.Arrays;
@ -12,12 +11,11 @@ import org.junit.*;
import static org.junit.Assert.*;
public class UserApiTest {
ApiClient apiClient;
UserApi api;
private UserApi api;
@Before
public void setup() {
apiClient = new ApiClient();
ApiClient apiClient = new ApiClient();
api = apiClient.buildClient(UserApi.class);
}
@ -38,7 +36,7 @@ public class UserApiTest {
User user2 = createUser();
user2.setUsername("user" + user2.getId());
api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
api.createUsersWithArrayInput(Arrays.asList(user1, user2));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());
@ -51,7 +49,7 @@ public class UserApiTest {
User user2 = createUser();
user2.setUsername("user" + user2.getId());
api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
api.createUsersWithListInput(Arrays.asList(user1, user2));
User fetched = api.getUserByName(user1.getUsername());
assertEquals(user1.getId(), fetched.getId());

View File

@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
ext {
swagger_annotations_version = "1.5.8"
jackson_version = "2.7.5"
jackson_version = "2.6.4"
jersey_version = "1.19.1"
jodatime_version = "2.9.4"
junit_version = "4.12"
@ -109,8 +109,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
compile "joda-time:joda-time:$jodatime_version"
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"
}

View File

@ -88,7 +88,7 @@ Float _float = 3.4F; // Float | None
String string = "string_example"; // String | None
byte[] binary = B; // byte[] | None
LocalDate date = new LocalDate(); // LocalDate | None
DateTime dateTime = new DateTime(); // DateTime | None
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {
@ -114,7 +114,7 @@ Name | Type | Description | Notes
**string** | **String**| None | [optional]
**binary** | **byte[]**| None | [optional]
**date** | **LocalDate**| None | [optional]
**dateTime** | **DateTime**| None | [optional]
**dateTime** | **OffsetDateTime**| None | [optional]
**password** | **String**| None | [optional]
**paramCallback** | **String**| None | [optional]

View File

@ -0,0 +1,52 @@
# FakeclassnametagsApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](FakeclassnametagsApi.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
<a name="testClassname"></a>
# **testClassname**
> Client testClassname(body)
To test class name in snake case
### Example
```java
// Import classes:
//import io.swagger.client.ApiException;
//import io.swagger.client.api.FakeclassnametagsApi;
FakeclassnametagsApi apiInstance = new FakeclassnametagsApi();
Client body = new Client(); // Client | client model
try {
Client result = apiInstance.testClassname(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeclassnametagsApi#testClassname");
e.printStackTrace();
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
### Return type
[**Client**](Client.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -14,7 +14,7 @@ Name | Type | Description | Notes
**_byte** | **byte[]** | |
**binary** | **byte[]** | | [optional]
**date** | [**LocalDate**](LocalDate.md) | |
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
**uuid** | [**UUID**](UUID.md) | | [optional]
**password** | **String** | |

View File

@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | [**UUID**](UUID.md) | | [optional]
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
**map** | [**Map&lt;String, Animal&gt;**](Animal.md) | | [optional]

View File

@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **Long** | | [optional]
**petId** | **Long** | | [optional]
**quantity** | **Integer** | | [optional]
**shipDate** | [**DateTime**](DateTime.md) | | [optional]
**shipDate** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional]
**complete** | **Boolean** | | [optional]

View File

@ -149,15 +149,10 @@
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
@ -178,8 +173,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<jersey-version>1.19.1</jersey-version>
<jackson-version>2.7.5</jackson-version>
<jodatime-version>2.9.4</jodatime-version>
<jackson-version>2.6.4</jackson-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>
</properties>

View File

@ -24,9 +24,11 @@
package io.swagger.client;
import org.threeten.bp.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.joda.*;
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.sun.jersey.api.client.Client;
@ -88,7 +90,11 @@ public class ApiClient {
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.registerModule(new JodaModule());
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
dateFormat = ApiClient.buildDefaultDateFormat();

View File

@ -0,0 +1,232 @@
package io.swagger.client;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
import com.fasterxml.jackson.datatype.threetenbp.function.Function;
import org.threeten.bp.DateTimeException;
import org.threeten.bp.Instant;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZonedDateTime;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.temporal.Temporal;
import org.threeten.bp.temporal.TemporalAccessor;
import java.io.IOException;
import java.math.BigDecimal;
/**
* Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
* Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
*
* @author Nick Williams
*/
public class CustomInstantDeserializer<T extends Temporal>
extends ThreeTenDateTimeDeserializerBase<T> {
private static final long serialVersionUID = 1L;
public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
Instant.class, DateTimeFormatter.ISO_INSTANT,
new Function<TemporalAccessor, Instant>() {
@Override
public Instant apply(TemporalAccessor temporalAccessor) {
return Instant.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, Instant>() {
@Override
public Instant apply(FromIntegerArguments a) {
return Instant.ofEpochMilli(a.value);
}
},
new Function<FromDecimalArguments, Instant>() {
@Override
public Instant apply(FromDecimalArguments a) {
return Instant.ofEpochSecond(a.integer, a.fraction);
}
},
null
);
public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
new Function<TemporalAccessor, OffsetDateTime>() {
@Override
public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
return OffsetDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromIntegerArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, OffsetDateTime>() {
@Override
public OffsetDateTime apply(FromDecimalArguments a) {
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
@Override
public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
}
}
);
public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
new Function<TemporalAccessor, ZonedDateTime>() {
@Override
public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
return ZonedDateTime.from(temporalAccessor);
}
},
new Function<FromIntegerArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromIntegerArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
}
},
new Function<FromDecimalArguments, ZonedDateTime>() {
@Override
public ZonedDateTime apply(FromDecimalArguments a) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
}
},
new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
@Override
public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
return zonedDateTime.withZoneSameInstant(zoneId);
}
}
);
protected final Function<FromIntegerArguments, T> fromMilliseconds;
protected final Function<FromDecimalArguments, T> fromNanoseconds;
protected final Function<TemporalAccessor, T> parsedToValue;
protected final BiFunction<T, ZoneId, T> adjust;
protected CustomInstantDeserializer(Class<T> supportedType,
DateTimeFormatter parser,
Function<TemporalAccessor, T> parsedToValue,
Function<FromIntegerArguments, T> fromMilliseconds,
Function<FromDecimalArguments, T> fromNanoseconds,
BiFunction<T, ZoneId, T> adjust) {
super(supportedType, parser);
this.parsedToValue = parsedToValue;
this.fromMilliseconds = fromMilliseconds;
this.fromNanoseconds = fromNanoseconds;
this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
@Override
public T apply(T t, ZoneId zoneId) {
return t;
}
} : adjust;
}
@SuppressWarnings("unchecked")
protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
super((Class<T>) base.handledType(), f);
parsedToValue = base.parsedToValue;
fromMilliseconds = base.fromMilliseconds;
fromNanoseconds = base.fromNanoseconds;
adjust = base.adjust;
}
@Override
protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
if (dtf == _formatter) {
return this;
}
return new CustomInstantDeserializer<T>(this, dtf);
}
@Override
public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
//NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
//string values have to be adjusted to the configured TZ.
switch (parser.getCurrentTokenId()) {
case JsonTokenId.ID_NUMBER_FLOAT: {
BigDecimal value = parser.getDecimalValue();
long seconds = value.longValue();
int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
return fromNanoseconds.apply(new FromDecimalArguments(
seconds, nanoseconds, getZone(context)));
}
case JsonTokenId.ID_NUMBER_INT: {
long timestamp = parser.getLongValue();
if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
return this.fromNanoseconds.apply(new FromDecimalArguments(
timestamp, 0, this.getZone(context)
));
}
return this.fromMilliseconds.apply(new FromIntegerArguments(
timestamp, this.getZone(context)
));
}
case JsonTokenId.ID_STRING: {
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
if (string.endsWith("+0000")) {
string = string.substring(0, string.length() - 5) + "Z";
}
T value;
try {
TemporalAccessor acc = _formatter.parse(string);
value = parsedToValue.apply(acc);
if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
return adjust.apply(value, this.getZone(context));
}
} catch (DateTimeException e) {
throw _peelDTE(e);
}
return value;
}
}
throw context.mappingException("Expected type float, integer, or string.");
}
private ZoneId getZone(DeserializationContext context) {
// Instants are always in UTC, so don't waste compute cycles
return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
}
private static class FromIntegerArguments {
public final long value;
public final ZoneId zoneId;
private FromIntegerArguments(long value, ZoneId zoneId) {
this.value = value;
this.zoneId = zoneId;
}
}
private static class FromDecimalArguments {
public final long integer;
public final int fraction;
public final ZoneId zoneId;
private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
this.integer = integer;
this.fraction = fraction;
this.zoneId = zoneId;
}
}
}

View File

@ -33,9 +33,9 @@ import io.swagger.client.model.*;
import io.swagger.client.Pair;
import io.swagger.client.model.Client;
import org.joda.time.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.LocalDate;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import java.util.ArrayList;
@ -123,7 +123,7 @@ public class FakeApi {
* @param paramCallback None (optional)
* @throws ApiException if fails to make API call
*/
public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, DateTime dateTime, String password, String paramCallback) throws ApiException {
public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'number' is set

View File

@ -0,0 +1,104 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client.api;
import com.sun.jersey.api.client.GenericType;
import io.swagger.client.ApiException;
import io.swagger.client.ApiClient;
import io.swagger.client.Configuration;
import io.swagger.client.model.*;
import io.swagger.client.Pair;
import io.swagger.client.model.Client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FakeclassnametagsApi {
private ApiClient apiClient;
public FakeclassnametagsApi() {
this(Configuration.getDefaultApiClient());
}
public FakeclassnametagsApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* To test class name in snake case
*
* @param body client model (required)
* @return Client
* @throws ApiException if fails to make API call
*/
public Client testClassname(Client body) throws ApiException {
Object localVarPostBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException(400, "Missing the required parameter 'body' when calling testClassname");
}
// create path and map variables
String localVarPath = "/fake_classname_test".replaceAll("\\{format\\}","json");
// query params
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = {
"application/json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"application/json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
}

View File

@ -32,8 +32,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.UUID;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
/**
* FormatTest
@ -71,7 +71,7 @@ public class FormatTest {
private LocalDate date = null;
@JsonProperty("dateTime")
private DateTime dateTime = null;
private OffsetDateTime dateTime = null;
@JsonProperty("uuid")
private UUID uuid = null;
@ -269,7 +269,7 @@ public class FormatTest {
this.date = date;
}
public FormatTest dateTime(DateTime dateTime) {
public FormatTest dateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -279,11 +279,11 @@ public class FormatTest {
* @return dateTime
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getDateTime() {
public OffsetDateTime getDateTime() {
return dateTime;
}
public void setDateTime(DateTime dateTime) {
public void setDateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -35,7 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.joda.time.DateTime;
import org.threeten.bp.OffsetDateTime;
/**
* MixedPropertiesAndAdditionalPropertiesClass
@ -46,7 +46,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
private UUID uuid = null;
@JsonProperty("dateTime")
private DateTime dateTime = null;
private OffsetDateTime dateTime = null;
@JsonProperty("map")
private Map<String, Animal> map = new HashMap<String, Animal>();
@ -69,7 +69,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
this.uuid = uuid;
}
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ -79,11 +79,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
* @return dateTime
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getDateTime() {
public OffsetDateTime getDateTime() {
return dateTime;
}
public void setDateTime(DateTime dateTime) {
public void setDateTime(OffsetDateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;
import org.threeten.bp.OffsetDateTime;
/**
* Order
@ -47,7 +47,7 @@ public class Order {
private Integer quantity = null;
@JsonProperty("shipDate")
private DateTime shipDate = null;
private OffsetDateTime shipDate = null;
/**
* Order Status
@ -141,7 +141,7 @@ public class Order {
this.quantity = quantity;
}
public Order shipDate(DateTime shipDate) {
public Order shipDate(OffsetDateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ -151,11 +151,11 @@ public class Order {
* @return shipDate
**/
@ApiModelProperty(example = "null", value = "")
public DateTime getShipDate() {
public OffsetDateTime getShipDate() {
return shipDate;
}
public void setShipDate(DateTime shipDate) {
public void setShipDate(OffsetDateTime shipDate) {
this.shipDate = shipDate;
}

View File

@ -0,0 +1,61 @@
/*
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.swagger.client.api;
import io.swagger.client.ApiException;
import io.swagger.client.model.Client;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* API tests for FakeclassnametagsApi
*/
public class FakeclassnametagsApiTest {
private final FakeclassnametagsApi api = new FakeclassnametagsApi();
/**
* To test class name in snake case
*
*
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void testClassnameTest() throws ApiException {
Client body = null;
// Client response = api.testClassname(body);
// TODO: test validations
}
}

View File

@ -2,22 +2,17 @@ package io.swagger.client.api;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.datatype.joda.*;
import io.swagger.TestUtils;
import io.swagger.client.*;
import io.swagger.client.api.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import org.junit.*;
import static org.junit.Assert.*;
@ -144,7 +139,7 @@ public class PetApiTest {
api.updatePet(pet);
List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
List<Pet> pets = api.findPetsByStatus(Collections.singletonList("available"));
assertNotNull(pets);
boolean found = false;
@ -172,7 +167,7 @@ public class PetApiTest {
api.updatePet(pet);
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
List<Pet> pets = api.findPetsByTags(Collections.singletonList("friendly"));
assertNotNull(pets);
boolean found = false;
@ -239,7 +234,7 @@ public class PetApiTest {
assertTrue(pet1.hashCode() == pet1.hashCode());
pet2.setName("really-happy");
pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
pet2.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
assertFalse(pet1.equals(pet2));
assertFalse(pet2.equals(pet1));
assertFalse(pet1.hashCode() == (pet2.hashCode()));
@ -247,7 +242,7 @@ public class PetApiTest {
assertTrue(pet2.hashCode() == pet2.hashCode());
pet1.setName("really-happy");
pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}));
pet1.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
assertTrue(pet1.equals(pet2));
assertTrue(pet2.equals(pet1));
assertTrue(pet1.hashCode() == pet2.hashCode());
@ -265,13 +260,13 @@ public class PetApiTest {
pet.setCategory(category);
pet.setStatus(Pet.StatusEnum.AVAILABLE);
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
List<String> photos = Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2");
pet.setPhotoUrls(photos);
return pet;
}
private String serializeJson(Object o) {
/*private String serializeJson(Object o) {
if (mapper == null) {
mapper = createObjectMapper();
}
@ -302,5 +297,5 @@ public class PetApiTest {
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.registerModule(new JodaModule());
return mapper;
}
}*/
}

View File

@ -4,8 +4,6 @@ import io.swagger.TestUtils;
import io.swagger.client.ApiException;
import io.swagger.client.*;
import io.swagger.client.api.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
@ -13,13 +11,13 @@ import java.lang.reflect.Field;
import java.util.Map;
import java.text.SimpleDateFormat;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.*;
import org.threeten.bp.OffsetDateTime;
import static org.junit.Assert.*;
public class StoreApiTest {
StoreApi api = null;
private StoreApi api = null;
@Before
public void setup() {
@ -61,7 +59,7 @@ public class StoreApiTest {
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
}
@Test
@ -84,9 +82,10 @@ public class StoreApiTest {
private Order createOrder() {
Order order = new Order();
order.setPetId(new Long(200));
order.setQuantity(new Integer(13));
order.setShipDate(DateTime.now());
order.setPetId(200L);
order.setQuantity(13);
//Ensure 3 fractional digits because of a bug in the petstore server
order.setShipDate(OffsetDateTime.now().withNano(123000000));
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);

View File

@ -107,7 +107,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version",
compile "com.brsanthu:migbase64:2.2"
testCompile "junit:junit:$junit_version"
}

View File

@ -13,10 +13,10 @@ lazy val root = (project in file(".")).
"org.glassfish.jersey.core" % "jersey-client" % "2.22.2",
"org.glassfish.jersey.media" % "jersey-media-multipart" % "2.22.2",
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.22.2",
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5",
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5" % "compile",
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5" % "compile",
"com.brsanthu" % "migbase64" % "2.2",
"junit" % "junit" % "4.12" % "test",
"com.novocode" % "junit-interface" % "0.10" % "test"

View File

@ -54,7 +54,7 @@ No authorization required
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password)
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -90,8 +90,9 @@ byte[] binary = B; // byte[] | None
LocalDate date = new LocalDate(); // LocalDate | None
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {
apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password);
apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEndpointParameters");
e.printStackTrace();
@ -115,6 +116,7 @@ Name | Type | Description | Notes
**date** | **LocalDate**| None | [optional]
**dateTime** | **OffsetDateTime**| None | [optional]
**password** | **String**| None | [optional]
**paramCallback** | **String**| None | [optional]
### Return type

View File

@ -0,0 +1,52 @@
# FakeclassnametagsApi
All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](FakeclassnametagsApi.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
<a name="testClassname"></a>
# **testClassname**
> Client testClassname(body)
To test class name in snake case
### Example
```java
// Import classes:
//import io.swagger.client.ApiException;
//import io.swagger.client.api.FakeclassnametagsApi;
FakeclassnametagsApi apiInstance = new FakeclassnametagsApi();
Client body = new Client(); // Client | client model
try {
Client result = apiInstance.testClassname(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeclassnametagsApi#testClassname");
e.printStackTrace();
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Client**](Client.md)| client model |
### Return type
[**Client**](Client.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -39,7 +39,6 @@ import java.io.File;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -70,14 +69,7 @@ public class ApiClient {
json = new JSON();
httpClient = buildHttpClient(debugging);
// Use RFC3339 format for date and datetime.
// See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
// Use UTC as the default time zone.
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.json.setDateFormat((DateFormat) dateFormat.clone());
this.dateFormat = new RFC3339DateFormat();
// Set default User-Agent.
setUserAgent("Swagger-Codegen/1.0.0/java");

Some files were not shown because too many files have changed in this diff Show More