forked from loafle/openapi-generator-original
[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:
parent
c1e6f00242
commit
70d93883cf
@ -28,6 +28,6 @@ fi
|
|||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
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"
|
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
|
rm -rf samples/client/petstore/java/okhttp-gson-parcelableModel/src/main
|
||||||
find samples/client/petstore/java/okhttp-gson -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
find samples/client/petstore/java/okhttp-gson-parcelableModel -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,7 +26,7 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# 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"
|
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"
|
echo "Removing files and folders under samples/client/petstore/java/retrofit/src/main"
|
||||||
rm -rf samples/client/petstore/java/retrofit/src/main
|
rm -rf samples/client/petstore/java/retrofit/src/main
|
||||||
|
@ -47,7 +47,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
public static final String DATE_LIBRARY = "dateLibrary";
|
public static final String DATE_LIBRARY = "dateLibrary";
|
||||||
public static final String SUPPORT_JAVA6 = "supportJava6";
|
public static final String SUPPORT_JAVA6 = "supportJava6";
|
||||||
|
|
||||||
protected String dateLibrary = "joda";
|
protected String dateLibrary = "threetenbp";
|
||||||
protected String invokerPackage = "io.swagger";
|
protected String invokerPackage = "io.swagger";
|
||||||
protected String groupId = "io.swagger";
|
protected String groupId = "io.swagger";
|
||||||
protected String artifactId = "swagger-java";
|
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");
|
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
|
||||||
Map<String, String> dateOptions = new HashMap<String, String>();
|
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("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)");
|
||||||
dateOptions.put("joda", "Joda");
|
dateOptions.put("joda", "Joda (for legacy app only)");
|
||||||
dateOptions.put("legacy", "Legacy java.util.Date");
|
dateOptions.put("legacy", "Legacy java.util.Date (if you really have a good reason not to use threetenbp");
|
||||||
dateLibrary.setEnum(dateOptions);
|
dateLibrary.setEnum(dateOptions);
|
||||||
|
|
||||||
cliOptions.add(dateLibrary);
|
cliOptions.add(dateLibrary);
|
||||||
@ -261,21 +262,26 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
// used later in recursive import in postProcessingModels
|
// used later in recursive import in postProcessingModels
|
||||||
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
|
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());
|
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");
|
additionalProperties.put("joda", "true");
|
||||||
typeMapping.put("date", "LocalDate");
|
typeMapping.put("date", "LocalDate");
|
||||||
typeMapping.put("DateTime", "DateTime");
|
typeMapping.put("DateTime", "DateTime");
|
||||||
|
|
||||||
importMapping.put("LocalDate", "org.joda.time.LocalDate");
|
importMapping.put("LocalDate", "org.joda.time.LocalDate");
|
||||||
importMapping.put("DateTime", "org.joda.time.DateTime");
|
importMapping.put("DateTime", "org.joda.time.DateTime");
|
||||||
}
|
} else if (dateLibrary.startsWith("java8")) {
|
||||||
else if (dateLibrary.startsWith("java8")) {
|
|
||||||
additionalProperties.put("java8", "true");
|
additionalProperties.put("java8", "true");
|
||||||
|
additionalProperties.put("jsr310", "true");
|
||||||
typeMapping.put("date", "LocalDate");
|
typeMapping.put("date", "LocalDate");
|
||||||
importMapping.put("LocalDate", "java.time.LocalDate");
|
importMapping.put("LocalDate", "java.time.LocalDate");
|
||||||
if ("java8-localdatetime".equals(dateLibrary)) {
|
if ("java8-localdatetime".equals(dateLibrary)) {
|
||||||
@ -285,6 +291,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
typeMapping.put("DateTime", "OffsetDateTime");
|
typeMapping.put("DateTime", "OffsetDateTime");
|
||||||
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
|
importMapping.put("OffsetDateTime", "java.time.OffsetDateTime");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
additionalProperties.put("legacyDates", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,8 +162,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen implements BeanValida
|
|||||||
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
|
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"));
|
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java"));
|
||||||
|
if ("threetenbp".equals(dateLibrary)) {
|
||||||
|
supportingFiles.add(new SupportingFile("CustomInstantDeserializer.mustache", invokerFolder, "CustomInstantDeserializer.java"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,19 @@ public class SpringCodegen extends AbstractJavaCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
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();
|
super.processOpts();
|
||||||
|
|
||||||
// clear model and api doc template as this codegen
|
// 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()));
|
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)) {
|
if (additionalProperties.containsKey(ASYNC)) {
|
||||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
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) {
|
if (this.java8) {
|
||||||
additionalProperties.put("javaVersion", "1.8");
|
additionalProperties.put("javaVersion", "1.8");
|
||||||
additionalProperties.put("jdk8", "true");
|
additionalProperties.put("jdk8", "true");
|
||||||
@ -230,7 +248,7 @@ public class SpringCodegen extends AbstractJavaCodegen {
|
|||||||
basePath = basePath.substring(0, pos);
|
basePath = basePath.substring(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basePath == "") {
|
if (basePath.equals("")) {
|
||||||
basePath = "default";
|
basePath = "default";
|
||||||
} else {
|
} else {
|
||||||
co.subresourceOperation = !co.path.isEmpty();
|
co.subresourceOperation = !co.path.isEmpty();
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.*;
|
||||||
|
|
||||||
|
{{/threetenbp}}
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
|
{{#joda}}
|
||||||
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
import com.fasterxml.jackson.datatype.jsr310.*;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
import com.fasterxml.jackson.datatype.joda.*;
|
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||||
|
{{/threetenbp}}
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||||
|
|
||||||
import com.sun.jersey.api.client.Client;
|
import com.sun.jersey.api.client.Client;
|
||||||
@ -70,12 +77,19 @@ public class ApiClient {
|
|||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
|
{{#joda}}
|
||||||
|
objectMapper.registerModule(new JodaModule());
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
objectMapper.registerModule(new JavaTimeModule());
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#threetenbp}}
|
||||||
objectMapper.registerModule(new JodaModule());
|
ThreeTenModule module = new ThreeTenModule();
|
||||||
{{/java8}}
|
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());
|
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||||
|
|
||||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -107,7 +107,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.5.8"
|
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"
|
jersey_version = "1.19.1"
|
||||||
jodatime_version = "2.9.4"
|
jodatime_version = "2.9.4"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
@ -121,13 +121,15 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$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.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
|
{{#joda}}
|
||||||
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
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"
|
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||||
|
{{/threetenbp}}
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -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.AuthenticationRequestBuilder;
|
||||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
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.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||||
|
{{/threetenbp}}
|
||||||
|
|
||||||
import feign.Feign;
|
import feign.Feign;
|
||||||
import feign.RequestInterceptor;
|
import feign.RequestInterceptor;
|
||||||
@ -137,12 +143,19 @@ public class ApiClient {
|
|||||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
objectMapper.setDateFormat(new RFC3339DateFormat());
|
objectMapper.setDateFormat(new RFC3339DateFormat());
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
objectMapper.registerModule(new JodaModule());
|
objectMapper.registerModule(new JodaModule());
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
objectMapper.registerModule(new JavaTimeModule());
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
{{/java8}}
|
{{/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;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.5.9"
|
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"
|
feign_version = "8.17.0"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
oltu_version = "1.0.1"
|
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-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$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 "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
|
@ -13,10 +13,18 @@ lazy val root = (project in file(".")).
|
|||||||
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
|
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
|
||||||
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
|
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
|
||||||
"com.netflix.feign" % "feign-slf4j" % "8.16.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-core" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5" % "compile",
|
"com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.7.5" % "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",
|
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
||||||
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
|
@ -142,11 +142,27 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{#joda}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<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>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>org.apache.oltu.oauth2</groupId>
|
<groupId>org.apache.oltu.oauth2</groupId>
|
||||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||||
@ -167,7 +183,7 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.9</swagger-core-version>
|
<swagger-core-version>1.5.9</swagger-core-version>
|
||||||
<feign-version>8.17.0</feign-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>
|
<junit-version>4.12</junit-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
package {{invokerPackage}};
|
package {{invokerPackage}};
|
||||||
|
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.*;
|
||||||
|
{{/threetenbp}}
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
import com.fasterxml.jackson.datatype.jsr310.*;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
import com.fasterxml.jackson.datatype.joda.*;
|
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
{{#joda}}
|
||||||
|
import com.fasterxml.jackson.datatype.joda.JodaModule;
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
|
||||||
|
{{/threetenbp}}
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
@ -28,9 +34,16 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
|||||||
{{#java8}}
|
{{#java8}}
|
||||||
mapper.registerModule(new JavaTimeModule());
|
mapper.registerModule(new JavaTimeModule());
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
mapper.registerModule(new JodaModule());
|
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}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,9 +108,6 @@ ext {
|
|||||||
swagger_annotations_version = "1.5.8"
|
swagger_annotations_version = "1.5.8"
|
||||||
jackson_version = "2.7.5"
|
jackson_version = "2.7.5"
|
||||||
jersey_version = "2.22.2"
|
jersey_version = "2.22.2"
|
||||||
{{^java8}}
|
|
||||||
jodatime_version = "2.9.4"
|
|
||||||
{{/java8}}
|
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
commons_io_version=2.5
|
commons_io_version=2.5
|
||||||
commons_lang3_version=3.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-core:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
|
||||||
|
{{#joda}}
|
||||||
|
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
|
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"
|
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
compile "commons-io:commons-io:$commons_io_version"
|
compile "commons-io:commons-io:$commons_io_version"
|
||||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||||
|
{{/threetenbp}}
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,18 @@ lazy val root = (project in file(".")).
|
|||||||
"org.glassfish.jersey.core" % "jersey-client" % "2.22.2",
|
"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-multipart" % "2.22.2",
|
||||||
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "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-core" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5",
|
"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}}
|
{{#java8}}
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5",
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5" % "compile",
|
||||||
{{/java8}}
|
|
||||||
{{^java8}}
|
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.7.5",
|
|
||||||
"joda-time" % "joda-time" % "2.9.4",
|
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile",
|
||||||
|
{{/threetenbp}}
|
||||||
"com.brsanthu" % "migbase64" % "2.2",
|
"com.brsanthu" % "migbase64" % "2.2",
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
"org.apache.commons" % "commons-lang3" % "3.5",
|
"org.apache.commons" % "commons-lang3" % "3.5",
|
||||||
|
@ -157,6 +157,13 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{#joda}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
@ -164,18 +171,13 @@
|
|||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#threetenbp}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
{{/threetenbp}}
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
<version>${jodatime-version}</version>
|
|
||||||
</dependency>
|
|
||||||
{{/java8}}
|
|
||||||
|
|
||||||
<!-- Base64 encoding that works in both JVM and Android -->
|
<!-- Base64 encoding that works in both JVM and Android -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -208,14 +210,11 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.9</swagger-core-version>
|
<swagger-core-version>1.5.9</swagger-core-version>
|
||||||
<jersey-version>2.22.2</jersey-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}}
|
{{#supportJava6}}
|
||||||
<commons_io_version>2.5</commons_io_version>
|
<commons_io_version>2.5</commons_io_version>
|
||||||
<commons_lang3_version>3.5</commons_lang3_version>
|
<commons_lang3_version>3.5</commons_lang3_version>
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
|
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -13,6 +13,11 @@ import org.joda.time.DateTime;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.LocalDate;
|
||||||
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
import org.threeten.bp.format.DateTimeFormatter;
|
||||||
|
{{/threetenbp}}
|
||||||
|
|
||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -210,7 +215,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
||||||
this.json.setOffsetDateTimeFormat(dateFormat);
|
this.json.setOffsetDateTimeFormat(dateFormat);
|
||||||
return this;
|
return this;
|
||||||
@ -221,7 +226,7 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
public ApiClient setLenientOnJson(boolean lenientOnJson) {
|
public ApiClient setLenientOnJson(boolean lenientOnJson) {
|
||||||
this.json.setLenientOnJson(lenientOnJson);
|
this.json.setLenientOnJson(lenientOnJson);
|
||||||
return this;
|
return this;
|
||||||
@ -427,7 +432,7 @@ public class ApiClient {
|
|||||||
public String parameterToString(Object param) {
|
public String parameterToString(Object param) {
|
||||||
if (param == null) {
|
if (param == null) {
|
||||||
return "";
|
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
|
//Serialize to json string and remove the " enclosing characters
|
||||||
String jsonStr = json.serialize(param);
|
String jsonStr = json.serialize(param);
|
||||||
return jsonStr.substring(1, jsonStr.length() - 1);
|
return jsonStr.substring(1, jsonStr.length() - 1);
|
||||||
|
@ -15,6 +15,11 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
{{/joda}}
|
{{/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.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
@ -38,10 +43,10 @@ public class JSON {
|
|||||||
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
|
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
|
|
||||||
public JSON() {
|
public JSON() {
|
||||||
gson = new GsonBuilder()
|
gson = new GsonBuilder()
|
||||||
@ -51,10 +56,10 @@ public class JSON {
|
|||||||
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
|
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
|
||||||
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
|
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
|
||||||
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +220,7 @@ public class JSON {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for JSR310 OffsetDateTime type
|
* Gson TypeAdapter for JSR310 OffsetDateTime type
|
||||||
*/
|
*/
|
||||||
@ -311,7 +316,7 @@ public class JSON {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.sql.Date type
|
* Gson TypeAdapter for java.sql.Date type
|
||||||
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
|
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
|
||||||
|
@ -98,8 +98,11 @@ dependencies {
|
|||||||
compile 'com.squareup.okhttp:okhttp:2.7.5'
|
compile 'com.squareup.okhttp:okhttp:2.7.5'
|
||||||
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
|
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
|
||||||
compile 'com.google.code.gson:gson:2.6.2'
|
compile 'com.google.code.gson:gson:2.6.2'
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
compile 'joda-time:joda-time:2.9.3'
|
compile 'joda-time:joda-time:2.9.3'
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
compile 'org.threeten:threetenbp:1.3.2'
|
||||||
|
{{/threetenbp}}
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,12 @@ lazy val root = (project in file(".")).
|
|||||||
"com.squareup.okhttp" % "okhttp" % "2.7.5",
|
"com.squareup.okhttp" % "okhttp" % "2.7.5",
|
||||||
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
|
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
|
||||||
"com.google.code.gson" % "gson" % "2.6.2",
|
"com.google.code.gson" % "gson" % "2.6.2",
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
"joda-time" % "joda-time" % "2.9.3" % "compile",
|
"joda-time" % "joda-time" % "2.9.3" % "compile",
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
"org.threeten" % "threetenbp" % "1.3.2" % "compile",
|
||||||
|
{{/threetenbp}}
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||||
)
|
)
|
||||||
|
@ -124,14 +124,21 @@
|
|||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>${gson-version}</version>
|
<version>${gson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>${jodatime-version}</version>
|
<version>${jodatime-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
{{#useBeanValidation}}
|
{{#threetenbp}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.threeten</groupId>
|
||||||
|
<artifactId>threetenbp</artifactId>
|
||||||
|
<version>${threetenbp-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/threetenbp}}
|
||||||
|
{{#useBeanValidation}}
|
||||||
<!-- Bean Validation API support -->
|
<!-- Bean Validation API support -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
@ -139,7 +146,7 @@
|
|||||||
<version>1.1.0.Final</version>
|
<version>1.1.0.Final</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
|
|
||||||
<!-- test dependencies -->
|
<!-- test dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -156,9 +163,14 @@
|
|||||||
<swagger-core-version>1.5.9</swagger-core-version>
|
<swagger-core-version>1.5.9</swagger-core-version>
|
||||||
<okhttp-version>2.7.5</okhttp-version>
|
<okhttp-version>2.7.5</okhttp-version>
|
||||||
<gson-version>2.6.2</gson-version>
|
<gson-version>2.6.2</gson-version>
|
||||||
|
{{#joda}}
|
||||||
<jodatime-version>2.9.3</jodatime-version>
|
<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>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -11,6 +11,9 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
|
|||||||
{{#joda}}
|
{{#joda}}
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
import org.threeten.bp.format.DateTimeFormatter;
|
||||||
|
{{/threetenbp}}
|
||||||
import retrofit2.Converter;
|
import retrofit2.Converter;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
@ -156,7 +159,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
||||||
this.json.setOffsetDateTimeFormat(dateFormat);
|
this.json.setOffsetDateTimeFormat(dateFormat);
|
||||||
return this;
|
return this;
|
||||||
@ -167,7 +170,7 @@ public class ApiClient {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to configure the first api key found
|
* Helper method to configure the first api key found
|
||||||
|
@ -15,6 +15,11 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
{{/joda}}
|
{{/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.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
@ -37,10 +42,10 @@ public class JSON {
|
|||||||
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
|
private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
|
|
||||||
public JSON() {
|
public JSON() {
|
||||||
gson = new GsonBuilder()
|
gson = new GsonBuilder()
|
||||||
@ -50,10 +55,10 @@ public class JSON {
|
|||||||
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
|
.registerTypeAdapter(DateTime.class, dateTimeTypeAdapter)
|
||||||
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
|
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
|
||||||
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +176,7 @@ public class JSON {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#jsr310}}
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for JSR310 OffsetDateTime type
|
* Gson TypeAdapter for JSR310 OffsetDateTime type
|
||||||
*/
|
*/
|
||||||
@ -267,7 +272,7 @@ public class JSON {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/java8}}
|
{{/jsr310}}
|
||||||
/**
|
/**
|
||||||
* Gson TypeAdapter for java.sql.Date type
|
* Gson TypeAdapter for java.sql.Date type
|
||||||
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
|
* If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
|
||||||
|
@ -101,9 +101,12 @@ ext {
|
|||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
rx_java_version = "1.1.3"
|
rx_java_version = "1.1.3"
|
||||||
{{/useRxJava}}
|
{{/useRxJava}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
jodatime_version = "2.9.3"
|
jodatime_version = "2.9.3"
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
threetenbp_version = "1.3.2"
|
||||||
|
{{/threetenbp}}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -116,9 +119,12 @@ dependencies {
|
|||||||
{{/useRxJava}}
|
{{/useRxJava}}
|
||||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
compile "joda-time:joda-time:$jodatime_version"
|
compile 'joda-time:joda-time:$jodatime_version'
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
compile 'org.threeten:threetenbp:$threetenbp_version'
|
||||||
|
{{/threetenbp}}
|
||||||
|
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,12 @@ lazy val root = (project in file(".")).
|
|||||||
{{/useRxJava}}
|
{{/useRxJava}}
|
||||||
"io.swagger" % "swagger-annotations" % "1.5.8" % "compile",
|
"io.swagger" % "swagger-annotations" % "1.5.8" % "compile",
|
||||||
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
"joda-time" % "joda-time" % "2.9.3" % "compile",
|
"joda-time" % "joda-time" % "2.9.3" % "compile",
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
"org.threeten" % "threetenbp" % "1.3.2" % "compile",
|
||||||
|
{{/threetenbp}}
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||||
)
|
)
|
||||||
|
@ -129,13 +129,20 @@
|
|||||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||||
<version>${oltu-version}</version>
|
<version>${oltu-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>${jodatime-version}</version>
|
<version>${jodatime-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.threeten</groupId>
|
||||||
|
<artifactId>threetenbp</artifactId>
|
||||||
|
<version>${threetenbp-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/threetenbp}}
|
||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.reactivex</groupId>
|
<groupId>io.reactivex</groupId>
|
||||||
@ -167,9 +174,12 @@
|
|||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
<rxjava-version>1.1.6</rxjava-version>
|
<rxjava-version>1.1.6</rxjava-version>
|
||||||
{{/useRxJava}}
|
{{/useRxJava}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
<jodatime-version>2.9.4</jodatime-version>
|
<jodatime-version>2.9.3</jodatime-version>
|
||||||
{{/java8}}
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
<threetenbp-version>1.3.2</threetenbp-version>
|
||||||
|
{{/threetenbp}}
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -154,6 +154,13 @@
|
|||||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{#joda}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
|
<version>${jackson-version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
@ -161,18 +168,13 @@
|
|||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#threetenbp}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
{{/threetenbp}}
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
<version>${jodatime-version}</version>
|
|
||||||
</dependency>
|
|
||||||
{{/java8}}
|
|
||||||
|
|
||||||
<!-- Base64 encoding that works in both JVM and Android -->
|
<!-- Base64 encoding that works in both JVM and Android -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -215,14 +217,11 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
<jersey-version>1.19.1</jersey-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}}
|
{{#supportJava6}}
|
||||||
<commons_io_version>2.5</commons_io_version>
|
<commons_io_version>2.5</commons_io_version>
|
||||||
<commons_lang3_version>3.5</commons_lang3_version>
|
<commons_lang3_version>3.5</commons_lang3_version>
|
||||||
{{/supportJava6}}
|
{{/supportJava6}}
|
||||||
|
<jackson-version>{{^threetenbp}}2.7.5{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}</jackson-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -62,16 +62,20 @@
|
|||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
|
<version>2.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/threetenbp}}
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -57,17 +57,21 @@
|
|||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
|
<version>2.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/threetenbp}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
@ -93,32 +93,42 @@
|
|||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>${springfox-version}</version>
|
<version>${springfox-version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${springfox-version}</version>
|
<version>${springfox-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
{{#java8}}
|
{{#java8}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-joda</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
{{/joda}}
|
||||||
|
{{#threetenbp}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
<version>2.9.4</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/java8}}
|
{{/threetenbp}}
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -140,8 +150,8 @@
|
|||||||
<slf4j-version>1.7.21</slf4j-version>
|
<slf4j-version>1.7.21</slf4j-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
<springfox-version>2.4.0</springfox-version>
|
<springfox-version>2.6.0</springfox-version>
|
||||||
<jackson-version>2.4.5</jackson-version>
|
<jackson-version>2.6.4</jackson-version>
|
||||||
<spring-version>4.2.5.RELEASE</spring-version>
|
<spring-version>4.2.5.RELEASE</spring-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
@ -2,6 +2,9 @@ package {{configPackage}};
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
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.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
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.EnableWebMvc;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
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 springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -62,8 +70,15 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
|||||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
|
||||||
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||||
.dateFormat( new RFC3339DateFormat())
|
.dateFormat(new RFC3339DateFormat())
|
||||||
.build();
|
.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));
|
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
|
||||||
super.configureMessageConverters(converters);
|
super.configureMessageConverters(converters);
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,14 @@ public class SwaggerDocumentationConfig {
|
|||||||
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
|
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
|
||||||
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
|
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
{{^java8}}
|
{{#joda}}
|
||||||
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
|
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
|
||||||
.directModelSubstitute(org.joda.time.DateTime.class, java.util.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());
|
.apiInfo(apiInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.5.9"
|
swagger_annotations_version = "1.5.9"
|
||||||
jackson_version = "2.7.5"
|
jackson_version = "2.6.4"
|
||||||
feign_version = "8.17.0"
|
feign_version = "8.17.0"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
oltu_version = "1.0.1"
|
oltu_version = "1.0.1"
|
||||||
@ -106,10 +106,7 @@ dependencies {
|
|||||||
compile "com.netflix.feign:feign-core:$feign_version"
|
compile "com.netflix.feign:feign-core:$feign_version"
|
||||||
compile "com.netflix.feign:feign-jackson:$feign_version"
|
compile "com.netflix.feign:feign-jackson:$feign_version"
|
||||||
compile "com.netflix.feign:feign-slf4j:$feign_version"
|
compile "com.netflix.feign:feign-slf4j:$feign_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$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 "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
|
@ -13,10 +13,7 @@ lazy val root = (project in file(".")).
|
|||||||
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
|
"com.netflix.feign" % "feign-core" % "8.16.0" % "compile",
|
||||||
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
|
"com.netflix.feign" % "feign-jackson" % "8.17.0" % "compile",
|
||||||
"com.netflix.feign" % "feign-slf4j" % "8.16.0" % "compile",
|
"com.netflix.feign" % "feign-slf4j" % "8.16.0" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-core" % "2.7.5" % "compile",
|
"com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "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",
|
|
||||||
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
||||||
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
"com.brsanthu" % "migbase64" % "2.2" % "compile",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
|
180
samples/client/petstore/java/feign/gradlew.bat
vendored
180
samples/client/petstore/java/feign/gradlew.bat
vendored
@ -1,90 +1,90 @@
|
|||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
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.
|
@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 DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windows variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
set CMD_LINE_ARGS=
|
set CMD_LINE_ARGS=
|
||||||
set _SKIP=2
|
set _SKIP=2
|
||||||
|
|
||||||
:win9xME_args_slurp
|
:win9xME_args_slurp
|
||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
goto execute
|
||||||
|
|
||||||
:4NT_args
|
:4NT_args
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
set CMD_LINE_ARGS=%$
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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%
|
"%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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
:omega
|
:omega
|
||||||
|
@ -128,23 +128,8 @@
|
|||||||
|
|
||||||
<!-- JSON processing: jackson -->
|
<!-- JSON processing: jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-datatype-threetenbp</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>
|
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -167,7 +152,7 @@
|
|||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.9</swagger-core-version>
|
<swagger-core-version>1.5.9</swagger-core-version>
|
||||||
<feign-version>8.17.0</feign-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>
|
<junit-version>4.12</junit-version>
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<oltu-version>1.0.1</oltu-version>
|
<oltu-version>1.0.1</oltu-version>
|
||||||
|
@ -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.AuthenticationRequestBuilder;
|
||||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
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.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
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.Feign;
|
||||||
import feign.RequestInterceptor;
|
import feign.RequestInterceptor;
|
||||||
@ -133,7 +136,11 @@ public class ApiClient {
|
|||||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
objectMapper.setDateFormat(new RFC3339DateFormat());
|
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;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Swagger Petstore
|
* 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: \" \\
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
*
|
*
|
||||||
|
@ -3,9 +3,9 @@ package io.swagger.client.api;
|
|||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
|
|
||||||
import io.swagger.client.model.Client;
|
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 java.math.BigDecimal;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -46,6 +46,7 @@ public interface FakeApi extends ApiClient.Api {
|
|||||||
* @param date None (optional)
|
* @param date None (optional)
|
||||||
* @param dateTime None (optional)
|
* @param dateTime None (optional)
|
||||||
* @param password None (optional)
|
* @param password None (optional)
|
||||||
|
* @param paramCallback None (optional)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@RequestLine("POST /fake")
|
@RequestLine("POST /fake")
|
||||||
@ -53,7 +54,7 @@ public interface FakeApi extends ApiClient.Api {
|
|||||||
"Content-type: application/xml; charset=utf-8",
|
"Content-type: application/xml; charset=utf-8",
|
||||||
"Accept: application/xml; charset=utf-8,application/json; charset=utf-8",
|
"Accept: application/xml; charset=utf-8,application/json; charset=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
|
* To test enum parameters
|
||||||
|
@ -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);
|
||||||
|
}
|
@ -34,12 +34,11 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdditionalPropertiesClass
|
* AdditionalPropertiesClass
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AdditionalPropertiesClass {
|
public class AdditionalPropertiesClass {
|
||||||
@JsonProperty("map_property")
|
@JsonProperty("map_property")
|
||||||
private Map<String, String> mapProperty = new HashMap<String, String>();
|
private Map<String, String> mapProperty = new HashMap<String, String>();
|
||||||
|
|
||||||
@ -132,5 +131,6 @@ public class AdditionalPropertiesClass {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animal
|
* Animal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Animal {
|
public class Animal {
|
||||||
@JsonProperty("className")
|
@JsonProperty("className")
|
||||||
private String className = null;
|
private String className = null;
|
||||||
|
|
||||||
@ -119,5 +118,6 @@ public class Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,11 @@ import io.swagger.client.model.Animal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AnimalFarm
|
* AnimalFarm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AnimalFarm extends ArrayList<Animal> {
|
public class AnimalFarm extends ArrayList<Animal> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(java.lang.Object o) {
|
public boolean equals(java.lang.Object o) {
|
||||||
@ -72,5 +71,6 @@ public class AnimalFarm extends ArrayList<Animal> {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,11 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayOfArrayOfNumberOnly
|
* ArrayOfArrayOfNumberOnly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ArrayOfArrayOfNumberOnly {
|
public class ArrayOfArrayOfNumberOnly {
|
||||||
@JsonProperty("ArrayArrayNumber")
|
@JsonProperty("ArrayArrayNumber")
|
||||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<List<BigDecimal>>();
|
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<List<BigDecimal>>();
|
||||||
|
|
||||||
@ -104,5 +103,6 @@ public class ArrayOfArrayOfNumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,11 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayOfNumberOnly
|
* ArrayOfNumberOnly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ArrayOfNumberOnly {
|
public class ArrayOfNumberOnly {
|
||||||
@JsonProperty("ArrayNumber")
|
@JsonProperty("ArrayNumber")
|
||||||
private List<BigDecimal> arrayNumber = new ArrayList<BigDecimal>();
|
private List<BigDecimal> arrayNumber = new ArrayList<BigDecimal>();
|
||||||
|
|
||||||
@ -104,5 +103,6 @@ public class ArrayOfNumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,11 @@ import io.swagger.client.model.ReadOnlyFirst;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArrayTest
|
* ArrayTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ArrayTest {
|
public class ArrayTest {
|
||||||
@JsonProperty("array_of_string")
|
@JsonProperty("array_of_string")
|
||||||
private List<String> arrayOfString = new ArrayList<String>();
|
private List<String> arrayOfString = new ArrayList<String>();
|
||||||
|
|
||||||
@ -160,5 +159,6 @@ public class ArrayTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.client.model.Animal;
|
import io.swagger.client.model.Animal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cat
|
* Cat
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Cat extends Animal {
|
public class Cat extends Animal {
|
||||||
@JsonProperty("declawed")
|
@JsonProperty("declawed")
|
||||||
private Boolean declawed = null;
|
private Boolean declawed = null;
|
||||||
|
|
||||||
@ -98,5 +97,6 @@ public class Cat extends Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category
|
* Category
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Category {
|
public class Category {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
@ -119,5 +118,6 @@ public class Category {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client
|
* Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
@JsonProperty("client")
|
@JsonProperty("client")
|
||||||
private String client = null;
|
private String client = null;
|
||||||
|
|
||||||
@ -96,5 +95,6 @@ public class Client {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.client.model.Animal;
|
import io.swagger.client.model.Animal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dog
|
* Dog
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Dog extends Animal {
|
public class Dog extends Animal {
|
||||||
@JsonProperty("breed")
|
@JsonProperty("breed")
|
||||||
private String breed = null;
|
private String breed = null;
|
||||||
|
|
||||||
@ -98,5 +97,6 @@ public class Dog extends Animal {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +33,11 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EnumArrays
|
* EnumArrays
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EnumArrays {
|
public class EnumArrays {
|
||||||
/**
|
/**
|
||||||
* Gets or Sets justSymbol
|
* Gets or Sets justSymbol
|
||||||
*/
|
*/
|
||||||
@ -186,5 +185,6 @@ public class EnumArrays {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ package io.swagger.client.model;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EnumTest
|
* EnumTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EnumTest {
|
public class EnumTest {
|
||||||
/**
|
/**
|
||||||
* Gets or Sets enumString
|
* Gets or Sets enumString
|
||||||
*/
|
*/
|
||||||
@ -232,5 +231,6 @@ public class EnumTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,15 +32,14 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.LocalDate;
|
||||||
import org.joda.time.LocalDate;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormatTest
|
* FormatTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FormatTest {
|
public class FormatTest {
|
||||||
@JsonProperty("integer")
|
@JsonProperty("integer")
|
||||||
private Integer integer = null;
|
private Integer integer = null;
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ public class FormatTest {
|
|||||||
private LocalDate date = null;
|
private LocalDate date = null;
|
||||||
|
|
||||||
@JsonProperty("dateTime")
|
@JsonProperty("dateTime")
|
||||||
private DateTime dateTime = null;
|
private OffsetDateTime dateTime = null;
|
||||||
|
|
||||||
@JsonProperty("uuid")
|
@JsonProperty("uuid")
|
||||||
private UUID uuid = null;
|
private UUID uuid = null;
|
||||||
@ -270,7 +269,7 @@ public class FormatTest {
|
|||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormatTest dateTime(DateTime dateTime) {
|
public FormatTest dateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -280,11 +279,11 @@ public class FormatTest {
|
|||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDateTime(DateTime dateTime) {
|
public void setDateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,5 +385,6 @@ public class FormatTest {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HasOnlyReadOnly
|
* HasOnlyReadOnly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class HasOnlyReadOnly {
|
public class HasOnlyReadOnly {
|
||||||
@JsonProperty("bar")
|
@JsonProperty("bar")
|
||||||
private String bar = null;
|
private String bar = null;
|
||||||
|
|
||||||
@ -101,5 +100,6 @@ public class HasOnlyReadOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,11 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapTest
|
* MapTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MapTest {
|
public class MapTest {
|
||||||
@JsonProperty("map_map_of_string")
|
@JsonProperty("map_map_of_string")
|
||||||
private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, 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 ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,19 +35,18 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MixedPropertiesAndAdditionalPropertiesClass
|
* MixedPropertiesAndAdditionalPropertiesClass
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MixedPropertiesAndAdditionalPropertiesClass {
|
public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||||
@JsonProperty("uuid")
|
@JsonProperty("uuid")
|
||||||
private UUID uuid = null;
|
private UUID uuid = null;
|
||||||
|
|
||||||
@JsonProperty("dateTime")
|
@JsonProperty("dateTime")
|
||||||
private DateTime dateTime = null;
|
private OffsetDateTime dateTime = null;
|
||||||
|
|
||||||
@JsonProperty("map")
|
@JsonProperty("map")
|
||||||
private Map<String, Animal> map = new HashMap<String, Animal>();
|
private Map<String, Animal> map = new HashMap<String, Animal>();
|
||||||
@ -70,7 +69,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
|
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -80,11 +79,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDateTime(DateTime dateTime) {
|
public void setDateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,5 +152,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing model name starting with number
|
* Model for testing model name starting with number
|
||||||
*/
|
*/
|
||||||
@ApiModel(description = "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")
|
@JsonProperty("name")
|
||||||
private Integer name = null;
|
private Integer name = null;
|
||||||
|
|
||||||
@ -120,5 +119,6 @@ public class Model200Response {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelApiResponse
|
* ModelApiResponse
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ModelApiResponse {
|
public class ModelApiResponse {
|
||||||
@JsonProperty("code")
|
@JsonProperty("code")
|
||||||
private Integer code = null;
|
private Integer code = null;
|
||||||
|
|
||||||
@ -142,5 +141,6 @@ public class ModelApiResponse {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing reserved words
|
* Model for testing reserved words
|
||||||
*/
|
*/
|
||||||
@ApiModel(description = "Model for testing reserved words")
|
@ApiModel(description = "Model for testing reserved words")
|
||||||
|
|
||||||
public class ModelReturn {
|
public class ModelReturn {
|
||||||
@JsonProperty("return")
|
@JsonProperty("return")
|
||||||
private Integer _return = null;
|
private Integer _return = null;
|
||||||
|
|
||||||
@ -97,5 +96,6 @@ public class ModelReturn {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,12 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing model name same as property name
|
* Model for testing model name same as property name
|
||||||
*/
|
*/
|
||||||
@ApiModel(description = "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")
|
@JsonProperty("name")
|
||||||
private Integer name = null;
|
private Integer name = null;
|
||||||
|
|
||||||
@ -148,5 +147,6 @@ public class Name {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,11 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NumberOnly
|
* NumberOnly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NumberOnly {
|
public class NumberOnly {
|
||||||
@JsonProperty("JustNumber")
|
@JsonProperty("JustNumber")
|
||||||
private BigDecimal justNumber = null;
|
private BigDecimal justNumber = null;
|
||||||
|
|
||||||
@ -97,5 +96,6 @@ public class NumberOnly {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +30,13 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Order {
|
public class Order {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ public class Order {
|
|||||||
private Integer quantity = null;
|
private Integer quantity = null;
|
||||||
|
|
||||||
@JsonProperty("shipDate")
|
@JsonProperty("shipDate")
|
||||||
private DateTime shipDate = null;
|
private OffsetDateTime shipDate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order Status
|
* Order Status
|
||||||
@ -142,7 +141,7 @@ public class Order {
|
|||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order shipDate(DateTime shipDate) {
|
public Order shipDate(OffsetDateTime shipDate) {
|
||||||
this.shipDate = shipDate;
|
this.shipDate = shipDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -152,11 +151,11 @@ public class Order {
|
|||||||
* @return shipDate
|
* @return shipDate
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getShipDate() {
|
public OffsetDateTime getShipDate() {
|
||||||
return shipDate;
|
return shipDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShipDate(DateTime shipDate) {
|
public void setShipDate(OffsetDateTime shipDate) {
|
||||||
this.shipDate = shipDate;
|
this.shipDate = shipDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,5 +243,6 @@ public class Order {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +35,11 @@ import io.swagger.client.model.Tag;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pet
|
* Pet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Pet {
|
public class Pet {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
@ -257,5 +256,6 @@ public class Pet {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReadOnlyFirst
|
* ReadOnlyFirst
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ReadOnlyFirst {
|
public class ReadOnlyFirst {
|
||||||
@JsonProperty("bar")
|
@JsonProperty("bar")
|
||||||
private String bar = null;
|
private String bar = null;
|
||||||
|
|
||||||
@ -110,5 +109,6 @@ public class ReadOnlyFirst {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SpecialModelName
|
* SpecialModelName
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SpecialModelName {
|
public class SpecialModelName {
|
||||||
@JsonProperty("$special[property.name]")
|
@JsonProperty("$special[property.name]")
|
||||||
private Long specialPropertyName = null;
|
private Long specialPropertyName = null;
|
||||||
|
|
||||||
@ -96,5 +95,6 @@ public class SpecialModelName {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag
|
* Tag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Tag {
|
public class Tag {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
@ -119,5 +118,6 @@ public class Tag {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class User {
|
public class User {
|
||||||
@JsonProperty("id")
|
@JsonProperty("id")
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
|
||||||
@ -257,5 +256,6 @@ public class User {
|
|||||||
}
|
}
|
||||||
return o.toString().replace("\n", "\n ");
|
return o.toString().replace("\n", "\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package io.swagger.client.api;
|
package io.swagger.client.api;
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
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 java.math.BigDecimal;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -25,6 +26,19 @@ public class FakeApiTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test \"client\" model
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testClientModelTest() {
|
||||||
|
Client body = null;
|
||||||
|
// Client response = api.testClientModel(body);
|
||||||
|
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
*
|
*
|
||||||
@ -34,17 +48,39 @@ public class FakeApiTest {
|
|||||||
public void testEndpointParametersTest() {
|
public void testEndpointParametersTest() {
|
||||||
BigDecimal number = null;
|
BigDecimal number = null;
|
||||||
Double _double = null;
|
Double _double = null;
|
||||||
String string = null;
|
String patternWithoutDelimiter = null;
|
||||||
byte[] _byte = null;
|
byte[] _byte = null;
|
||||||
Integer integer = null;
|
Integer integer = null;
|
||||||
Integer int32 = null;
|
Integer int32 = null;
|
||||||
Long int64 = null;
|
Long int64 = null;
|
||||||
Float _float = null;
|
Float _float = null;
|
||||||
|
String string = null;
|
||||||
byte[] binary = null;
|
byte[] binary = null;
|
||||||
LocalDate date = null;
|
LocalDate date = null;
|
||||||
DateTime dateTime = null;
|
OffsetDateTime dateTime = null;
|
||||||
String password = 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
|
// TODO: test validations
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,6 @@ package io.swagger.client.api;
|
|||||||
import io.swagger.TestUtils;
|
import io.swagger.TestUtils;
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -11,14 +10,15 @@ import java.io.File;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class PetApiTest {
|
public class PetApiTest {
|
||||||
ApiClient apiClient;
|
private ApiClient apiClient;
|
||||||
PetApi api;
|
private PetApi api;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@ -71,7 +71,7 @@ public class PetApiTest {
|
|||||||
|
|
||||||
api.updatePet(pet);
|
api.updatePet(pet);
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
|
List<Pet> pets = api.findPetsByStatus(Collections.singletonList("available"));
|
||||||
assertNotNull(pets);
|
assertNotNull(pets);
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -91,7 +91,7 @@ public class PetApiTest {
|
|||||||
pet.setName("monster");
|
pet.setName("monster");
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||||
|
|
||||||
List<Tag> tags = new ArrayList<Tag>();
|
List<Tag> tags = new ArrayList<>();
|
||||||
Tag tag1 = new Tag();
|
Tag tag1 = new Tag();
|
||||||
tag1.setName("friendly");
|
tag1.setName("friendly");
|
||||||
tags.add(tag1);
|
tags.add(tag1);
|
||||||
@ -99,7 +99,7 @@ public class PetApiTest {
|
|||||||
|
|
||||||
api.updatePet(pet);
|
api.updatePet(pet);
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
|
List<Pet> pets = api.findPetsByTags(Collections.singletonList("friendly"));
|
||||||
assertNotNull(pets);
|
assertNotNull(pets);
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -135,7 +135,7 @@ public class PetApiTest {
|
|||||||
api.deletePet(fetched.getId(), null);
|
api.deletePet(fetched.getId(), null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fetched = api.getPetById(fetched.getId());
|
api.getPetById(fetched.getId());
|
||||||
fail("expected an error");
|
fail("expected an error");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// assertEquals(404, e.getCode());
|
// assertEquals(404, e.getCode());
|
||||||
@ -166,7 +166,7 @@ public class PetApiTest {
|
|||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||||
|
|
||||||
pet2.setName("really-happy");
|
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(pet1.equals(pet2));
|
||||||
assertFalse(pet2.equals(pet1));
|
assertFalse(pet2.equals(pet1));
|
||||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
||||||
@ -174,7 +174,7 @@ public class PetApiTest {
|
|||||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
assertTrue(pet2.hashCode() == pet2.hashCode());
|
||||||
|
|
||||||
pet1.setName("really-happy");
|
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(pet1.equals(pet2));
|
||||||
assertTrue(pet2.equals(pet1));
|
assertTrue(pet2.equals(pet1));
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||||
@ -192,7 +192,7 @@ public class PetApiTest {
|
|||||||
|
|
||||||
pet.setCategory(category);
|
pet.setCategory(category);
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
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);
|
pet.setPhotoUrls(photos);
|
||||||
|
|
||||||
return pet;
|
return pet;
|
||||||
|
@ -11,15 +11,16 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class StoreApiTest {
|
public class StoreApiTest {
|
||||||
ApiClient apiClient;
|
private StoreApi api;
|
||||||
StoreApi api;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
apiClient = new ApiClient();
|
ApiClient apiClient = new ApiClient();
|
||||||
api = apiClient.buildClient(StoreApi.class);
|
api = apiClient.buildClient(StoreApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class StoreApiTest {
|
|||||||
assertEquals(order.getId(), fetched.getId());
|
assertEquals(order.getId(), fetched.getId());
|
||||||
assertEquals(order.getPetId(), fetched.getPetId());
|
assertEquals(order.getPetId(), fetched.getPetId());
|
||||||
assertEquals(order.getQuantity(), fetched.getQuantity());
|
assertEquals(order.getQuantity(), fetched.getQuantity());
|
||||||
assertEquals(order.getShipDate().toInstant(), fetched.getShipDate().toInstant());
|
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -61,9 +62,10 @@ public class StoreApiTest {
|
|||||||
|
|
||||||
private Order createOrder() {
|
private Order createOrder() {
|
||||||
Order order = new Order();
|
Order order = new Order();
|
||||||
order.setPetId(new Long(200));
|
order.setPetId(200L);
|
||||||
order.setQuantity(new Integer(13));
|
order.setQuantity(13);
|
||||||
order.setShipDate(org.joda.time.DateTime.now());
|
//Ensure 3 fractional digits because of a bug in the petstore server
|
||||||
|
order.setShipDate(OffsetDateTime.now().withNano(123000000));
|
||||||
order.setStatus(Order.StatusEnum.PLACED);
|
order.setStatus(Order.StatusEnum.PLACED);
|
||||||
order.setComplete(true);
|
order.setComplete(true);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package io.swagger.client.api;
|
|||||||
import io.swagger.TestUtils;
|
import io.swagger.TestUtils;
|
||||||
|
|
||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.model.*;
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -12,12 +11,11 @@ import org.junit.*;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class UserApiTest {
|
public class UserApiTest {
|
||||||
ApiClient apiClient;
|
private UserApi api;
|
||||||
UserApi api;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
apiClient = new ApiClient();
|
ApiClient apiClient = new ApiClient();
|
||||||
api = apiClient.buildClient(UserApi.class);
|
api = apiClient.buildClient(UserApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ public class UserApiTest {
|
|||||||
User user2 = createUser();
|
User user2 = createUser();
|
||||||
user2.setUsername("user" + user2.getId());
|
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());
|
User fetched = api.getUserByName(user1.getUsername());
|
||||||
assertEquals(user1.getId(), fetched.getId());
|
assertEquals(user1.getId(), fetched.getId());
|
||||||
@ -51,7 +49,7 @@ public class UserApiTest {
|
|||||||
User user2 = createUser();
|
User user2 = createUser();
|
||||||
user2.setUsername("user" + user2.getId());
|
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());
|
User fetched = api.getUserByName(user1.getUsername());
|
||||||
assertEquals(user1.getId(), fetched.getId());
|
assertEquals(user1.getId(), fetched.getId());
|
||||||
|
@ -95,7 +95,7 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
swagger_annotations_version = "1.5.8"
|
swagger_annotations_version = "1.5.8"
|
||||||
jackson_version = "2.7.5"
|
jackson_version = "2.6.4"
|
||||||
jersey_version = "1.19.1"
|
jersey_version = "1.19.1"
|
||||||
jodatime_version = "2.9.4"
|
jodatime_version = "2.9.4"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
@ -109,8 +109,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$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.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
|
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version",
|
||||||
compile "joda-time:joda-time:$jodatime_version"
|
|
||||||
compile "com.brsanthu:migbase64:2.2"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ Float _float = 3.4F; // Float | None
|
|||||||
String string = "string_example"; // String | None
|
String string = "string_example"; // String | None
|
||||||
byte[] binary = B; // byte[] | None
|
byte[] binary = B; // byte[] | None
|
||||||
LocalDate date = new LocalDate(); // LocalDate | 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 password = "password_example"; // String | None
|
||||||
String paramCallback = "paramCallback_example"; // String | None
|
String paramCallback = "paramCallback_example"; // String | None
|
||||||
try {
|
try {
|
||||||
@ -114,7 +114,7 @@ Name | Type | Description | Notes
|
|||||||
**string** | **String**| None | [optional]
|
**string** | **String**| None | [optional]
|
||||||
**binary** | **byte[]**| None | [optional]
|
**binary** | **byte[]**| None | [optional]
|
||||||
**date** | **LocalDate**| None | [optional]
|
**date** | **LocalDate**| None | [optional]
|
||||||
**dateTime** | **DateTime**| None | [optional]
|
**dateTime** | **OffsetDateTime**| None | [optional]
|
||||||
**password** | **String**| None | [optional]
|
**password** | **String**| None | [optional]
|
||||||
**paramCallback** | **String**| None | [optional]
|
**paramCallback** | **String**| None | [optional]
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
@ -14,7 +14,7 @@ Name | Type | Description | Notes
|
|||||||
**_byte** | **byte[]** | |
|
**_byte** | **byte[]** | |
|
||||||
**binary** | **byte[]** | | [optional]
|
**binary** | **byte[]** | | [optional]
|
||||||
**date** | [**LocalDate**](LocalDate.md) | |
|
**date** | [**LocalDate**](LocalDate.md) | |
|
||||||
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
|
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
|
||||||
**uuid** | [**UUID**](UUID.md) | | [optional]
|
**uuid** | [**UUID**](UUID.md) | | [optional]
|
||||||
**password** | **String** | |
|
**password** | **String** | |
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**uuid** | [**UUID**](UUID.md) | | [optional]
|
**uuid** | [**UUID**](UUID.md) | | [optional]
|
||||||
**dateTime** | [**DateTime**](DateTime.md) | | [optional]
|
**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
|
||||||
**map** | [**Map<String, Animal>**](Animal.md) | | [optional]
|
**map** | [**Map<String, Animal>**](Animal.md) | | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Name | Type | Description | Notes
|
|||||||
**id** | **Long** | | [optional]
|
**id** | **Long** | | [optional]
|
||||||
**petId** | **Long** | | [optional]
|
**petId** | **Long** | | [optional]
|
||||||
**quantity** | **Integer** | | [optional]
|
**quantity** | **Integer** | | [optional]
|
||||||
**shipDate** | [**DateTime**](DateTime.md) | | [optional]
|
**shipDate** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional]
|
||||||
**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional]
|
**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional]
|
||||||
**complete** | **Boolean** | | [optional]
|
**complete** | **Boolean** | | [optional]
|
||||||
|
|
||||||
|
@ -149,15 +149,10 @@
|
|||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.github.joschi.jackson</groupId>
|
||||||
<artifactId>jackson-datatype-joda</artifactId>
|
<artifactId>jackson-datatype-threetenbp</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
<version>${jodatime-version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Base64 encoding that works in both JVM and Android -->
|
<!-- Base64 encoding that works in both JVM and Android -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -178,8 +173,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
<swagger-annotations-version>1.5.8</swagger-annotations-version>
|
||||||
<jersey-version>1.19.1</jersey-version>
|
<jersey-version>1.19.1</jersey-version>
|
||||||
<jackson-version>2.7.5</jackson-version>
|
<jackson-version>2.6.4</jackson-version>
|
||||||
<jodatime-version>2.9.4</jodatime-version>
|
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.12</junit-version>
|
<junit-version>4.12</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -24,9 +24,11 @@
|
|||||||
|
|
||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
|
import org.threeten.bp.*;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
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.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||||
|
|
||||||
import com.sun.jersey.api.client.Client;
|
import com.sun.jersey.api.client.Client;
|
||||||
@ -88,7 +90,11 @@ public class ApiClient {
|
|||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.enable(DeserializationFeature.READ_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());
|
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||||
|
|
||||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,9 +33,9 @@ import io.swagger.client.model.*;
|
|||||||
import io.swagger.client.Pair;
|
import io.swagger.client.Pair;
|
||||||
|
|
||||||
import io.swagger.client.model.Client;
|
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 java.math.BigDecimal;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -123,7 +123,7 @@ public class FakeApi {
|
|||||||
* @param paramCallback None (optional)
|
* @param paramCallback None (optional)
|
||||||
* @throws ApiException if fails to make API call
|
* @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;
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
// verify the required parameter 'number' is set
|
// verify the required parameter 'number' is set
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -32,8 +32,8 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.LocalDate;
|
||||||
import org.joda.time.LocalDate;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormatTest
|
* FormatTest
|
||||||
@ -71,7 +71,7 @@ public class FormatTest {
|
|||||||
private LocalDate date = null;
|
private LocalDate date = null;
|
||||||
|
|
||||||
@JsonProperty("dateTime")
|
@JsonProperty("dateTime")
|
||||||
private DateTime dateTime = null;
|
private OffsetDateTime dateTime = null;
|
||||||
|
|
||||||
@JsonProperty("uuid")
|
@JsonProperty("uuid")
|
||||||
private UUID uuid = null;
|
private UUID uuid = null;
|
||||||
@ -269,7 +269,7 @@ public class FormatTest {
|
|||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormatTest dateTime(DateTime dateTime) {
|
public FormatTest dateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -279,11 +279,11 @@ public class FormatTest {
|
|||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDateTime(DateTime dateTime) {
|
public void setDateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MixedPropertiesAndAdditionalPropertiesClass
|
* MixedPropertiesAndAdditionalPropertiesClass
|
||||||
@ -46,7 +46,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
private UUID uuid = null;
|
private UUID uuid = null;
|
||||||
|
|
||||||
@JsonProperty("dateTime")
|
@JsonProperty("dateTime")
|
||||||
private DateTime dateTime = null;
|
private OffsetDateTime dateTime = null;
|
||||||
|
|
||||||
@JsonProperty("map")
|
@JsonProperty("map")
|
||||||
private Map<String, Animal> map = new HashMap<String, Animal>();
|
private Map<String, Animal> map = new HashMap<String, Animal>();
|
||||||
@ -69,7 +69,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
|
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -79,11 +79,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
|||||||
* @return dateTime
|
* @return dateTime
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getDateTime() {
|
public OffsetDateTime getDateTime() {
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDateTime(DateTime dateTime) {
|
public void setDateTime(OffsetDateTime dateTime) {
|
||||||
this.dateTime = dateTime;
|
this.dateTime = dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.joda.time.DateTime;
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
@ -47,7 +47,7 @@ public class Order {
|
|||||||
private Integer quantity = null;
|
private Integer quantity = null;
|
||||||
|
|
||||||
@JsonProperty("shipDate")
|
@JsonProperty("shipDate")
|
||||||
private DateTime shipDate = null;
|
private OffsetDateTime shipDate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order Status
|
* Order Status
|
||||||
@ -141,7 +141,7 @@ public class Order {
|
|||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order shipDate(DateTime shipDate) {
|
public Order shipDate(OffsetDateTime shipDate) {
|
||||||
this.shipDate = shipDate;
|
this.shipDate = shipDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -151,11 +151,11 @@ public class Order {
|
|||||||
* @return shipDate
|
* @return shipDate
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(example = "null", value = "")
|
@ApiModelProperty(example = "null", value = "")
|
||||||
public DateTime getShipDate() {
|
public OffsetDateTime getShipDate() {
|
||||||
return shipDate;
|
return shipDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShipDate(DateTime shipDate) {
|
public void setShipDate(OffsetDateTime shipDate) {
|
||||||
this.shipDate = shipDate;
|
this.shipDate = shipDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,22 +2,17 @@ package io.swagger.client.api;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.*;
|
import com.fasterxml.jackson.annotation.*;
|
||||||
import com.fasterxml.jackson.databind.*;
|
import com.fasterxml.jackson.databind.*;
|
||||||
import com.fasterxml.jackson.datatype.joda.*;
|
|
||||||
|
|
||||||
import io.swagger.TestUtils;
|
import io.swagger.TestUtils;
|
||||||
|
|
||||||
import io.swagger.client.*;
|
import io.swagger.client.*;
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.auth.*;
|
import io.swagger.client.auth.*;
|
||||||
import io.swagger.client.model.*;
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@ -144,7 +139,7 @@ public class PetApiTest {
|
|||||||
|
|
||||||
api.updatePet(pet);
|
api.updatePet(pet);
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
|
List<Pet> pets = api.findPetsByStatus(Collections.singletonList("available"));
|
||||||
assertNotNull(pets);
|
assertNotNull(pets);
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -172,7 +167,7 @@ public class PetApiTest {
|
|||||||
|
|
||||||
api.updatePet(pet);
|
api.updatePet(pet);
|
||||||
|
|
||||||
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
|
List<Pet> pets = api.findPetsByTags(Collections.singletonList("friendly"));
|
||||||
assertNotNull(pets);
|
assertNotNull(pets);
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -239,7 +234,7 @@ public class PetApiTest {
|
|||||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||||
|
|
||||||
pet2.setName("really-happy");
|
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(pet1.equals(pet2));
|
||||||
assertFalse(pet2.equals(pet1));
|
assertFalse(pet2.equals(pet1));
|
||||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
||||||
@ -247,7 +242,7 @@ public class PetApiTest {
|
|||||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
assertTrue(pet2.hashCode() == pet2.hashCode());
|
||||||
|
|
||||||
pet1.setName("really-happy");
|
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(pet1.equals(pet2));
|
||||||
assertTrue(pet2.equals(pet1));
|
assertTrue(pet2.equals(pet1));
|
||||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||||
@ -265,13 +260,13 @@ public class PetApiTest {
|
|||||||
|
|
||||||
pet.setCategory(category);
|
pet.setCategory(category);
|
||||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
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);
|
pet.setPhotoUrls(photos);
|
||||||
|
|
||||||
return pet;
|
return pet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String serializeJson(Object o) {
|
/*private String serializeJson(Object o) {
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
mapper = createObjectMapper();
|
mapper = createObjectMapper();
|
||||||
}
|
}
|
||||||
@ -302,5 +297,5 @@ public class PetApiTest {
|
|||||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule());
|
||||||
return mapper;
|
return mapper;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import io.swagger.TestUtils;
|
|||||||
|
|
||||||
import io.swagger.client.ApiException;
|
import io.swagger.client.ApiException;
|
||||||
|
|
||||||
import io.swagger.client.*;
|
|
||||||
import io.swagger.client.api.*;
|
|
||||||
import io.swagger.client.auth.*;
|
import io.swagger.client.auth.*;
|
||||||
import io.swagger.client.model.*;
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
@ -13,13 +11,13 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.DateTimeZone;
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
import org.threeten.bp.OffsetDateTime;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class StoreApiTest {
|
public class StoreApiTest {
|
||||||
StoreApi api = null;
|
private StoreApi api = null;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@ -61,7 +59,7 @@ public class StoreApiTest {
|
|||||||
assertEquals(order.getId(), fetched.getId());
|
assertEquals(order.getId(), fetched.getId());
|
||||||
assertEquals(order.getPetId(), fetched.getPetId());
|
assertEquals(order.getPetId(), fetched.getPetId());
|
||||||
assertEquals(order.getQuantity(), fetched.getQuantity());
|
assertEquals(order.getQuantity(), fetched.getQuantity());
|
||||||
assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
|
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -84,9 +82,10 @@ public class StoreApiTest {
|
|||||||
|
|
||||||
private Order createOrder() {
|
private Order createOrder() {
|
||||||
Order order = new Order();
|
Order order = new Order();
|
||||||
order.setPetId(new Long(200));
|
order.setPetId(200L);
|
||||||
order.setQuantity(new Integer(13));
|
order.setQuantity(13);
|
||||||
order.setShipDate(DateTime.now());
|
//Ensure 3 fractional digits because of a bug in the petstore server
|
||||||
|
order.setShipDate(OffsetDateTime.now().withNano(123000000));
|
||||||
order.setStatus(Order.StatusEnum.PLACED);
|
order.setStatus(Order.StatusEnum.PLACED);
|
||||||
order.setComplete(true);
|
order.setComplete(true);
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ dependencies {
|
|||||||
compile "com.fasterxml.jackson.core:jackson-core:$jackson_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-annotations:$jackson_version"
|
||||||
compile "com.fasterxml.jackson.core:jackson-databind:$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"
|
compile "com.brsanthu:migbase64:2.2"
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,10 @@ lazy val root = (project in file(".")).
|
|||||||
"org.glassfish.jersey.core" % "jersey-client" % "2.22.2",
|
"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-multipart" % "2.22.2",
|
||||||
"org.glassfish.jersey.media" % "jersey-media-json-jackson" % "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-core" % "2.7.5" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5",
|
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.5" % "compile",
|
||||||
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5",
|
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.5" % "compile",
|
||||||
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5",
|
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.7.5" % "compile",
|
||||||
"com.brsanthu" % "migbase64" % "2.2",
|
"com.brsanthu" % "migbase64" % "2.2",
|
||||||
"junit" % "junit" % "4.12" % "test",
|
"junit" % "junit" % "4.12" % "test",
|
||||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||||
|
@ -54,7 +54,7 @@ No authorization required
|
|||||||
|
|
||||||
<a name="testEndpointParameters"></a>
|
<a name="testEndpointParameters"></a>
|
||||||
# **testEndpointParameters**
|
# **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 假端點 偽のエンドポイント 가짜 엔드 포인트
|
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
|
|
||||||
@ -90,8 +90,9 @@ byte[] binary = B; // byte[] | None
|
|||||||
LocalDate date = new LocalDate(); // LocalDate | None
|
LocalDate date = new LocalDate(); // LocalDate | None
|
||||||
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
|
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
|
||||||
String password = "password_example"; // String | None
|
String password = "password_example"; // String | None
|
||||||
|
String paramCallback = "paramCallback_example"; // String | None
|
||||||
try {
|
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) {
|
} catch (ApiException e) {
|
||||||
System.err.println("Exception when calling FakeApi#testEndpointParameters");
|
System.err.println("Exception when calling FakeApi#testEndpointParameters");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -115,6 +116,7 @@ Name | Type | Description | Notes
|
|||||||
**date** | **LocalDate**| None | [optional]
|
**date** | **LocalDate**| None | [optional]
|
||||||
**dateTime** | **OffsetDateTime**| None | [optional]
|
**dateTime** | **OffsetDateTime**| None | [optional]
|
||||||
**password** | **String**| None | [optional]
|
**password** | **String**| None | [optional]
|
||||||
|
**paramCallback** | **String**| None | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
@ -1,90 +1,90 @@
|
|||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
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.
|
@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 DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo.
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation.
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windows variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
set CMD_LINE_ARGS=
|
set CMD_LINE_ARGS=
|
||||||
set _SKIP=2
|
set _SKIP=2
|
||||||
|
|
||||||
:win9xME_args_slurp
|
:win9xME_args_slurp
|
||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
goto execute
|
||||||
|
|
||||||
:4NT_args
|
:4NT_args
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
set CMD_LINE_ARGS=%$
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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%
|
"%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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
:omega
|
:omega
|
||||||
|
@ -39,7 +39,6 @@ import java.io.File;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -70,14 +69,7 @@ public class ApiClient {
|
|||||||
json = new JSON();
|
json = new JSON();
|
||||||
httpClient = buildHttpClient(debugging);
|
httpClient = buildHttpClient(debugging);
|
||||||
|
|
||||||
// Use RFC3339 format for date and datetime.
|
this.dateFormat = new RFC3339DateFormat();
|
||||||
// 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());
|
|
||||||
|
|
||||||
// Set default User-Agent.
|
// Set default User-Agent.
|
||||||
setUserAgent("Swagger-Codegen/1.0.0/java");
|
setUserAgent("Swagger-Codegen/1.0.0/java");
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user