diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java index 78304e89b0de..de12108b7694 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -1,6 +1,7 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; +import io.swagger.client.EncodingUtils; import io.swagger.client.model.Client; diff --git a/samples/client/petstore/java/jersey1/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/jersey1/docs/FakeClassnameTags123Api.md index 44b5bcd6bc83..468108b748ae 100644 --- a/samples/client/petstore/java/jersey1/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/java/jersey1/docs/FakeClassnameTags123Api.md @@ -1,6 +1,6 @@ # FakeClassnameTags123Api -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/java/jersey2-java6/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/jersey2-java6/docs/FakeClassnameTags123Api.md index 44b5bcd6bc83..468108b748ae 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/java/jersey2-java6/docs/FakeClassnameTags123Api.md @@ -1,6 +1,6 @@ # FakeClassnameTags123Api -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md b/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md index 06bed417232a..c7a3acb3cb7e 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md +++ b/samples/client/petstore/java/jersey2-java6/docs/FormatTest.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes **_byte** | **byte[]** | | **binary** | **byte[]** | | [optional] **date** | [**LocalDate**](LocalDate.md) | | -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **uuid** | [**UUID**](UUID.md) | | [optional] **password** | **String** | | diff --git a/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 349afef35a98..b12e2cd70e69 100644 --- a/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/java/jersey2-java6/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | [**UUID**](UUID.md) | | [optional] -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **map** | [**Map<String, Animal>**](Animal.md) | | [optional] diff --git a/samples/client/petstore/java/jersey2-java6/pom.xml b/samples/client/petstore/java/jersey2-java6/pom.xml index 60a3a0cd530c..87287ba2a8d1 100644 --- a/samples/client/petstore/java/jersey2-java6/pom.xml +++ b/samples/client/petstore/java/jersey2-java6/pom.xml @@ -2,9 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 io.swagger - swagger-petstore-jersey2 + swagger-petstore-jersey2-java6 jar - swagger-petstore-jersey2 + swagger-petstore-jersey2-java6 1.0.0 https://github.com/swagger-api/swagger-codegen Swagger Java diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java index a8c2ebfa2b72..208886d5bedb 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/api/FakeApi.java @@ -9,8 +9,8 @@ import javax.ws.rs.core.GenericType; import java.math.BigDecimal; import io.swagger.client.model.Client; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; import java.util.ArrayList; import java.util.HashMap; @@ -97,7 +97,7 @@ public class FakeApi { * @param paramCallback None (optional) * @throws ApiException if fails to make API call */ - public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, DateTime dateTime, String password, String paramCallback) throws ApiException { + public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'number' is set diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java index 78b6cd6b0f2c..0ed06c2934ed 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/FormatTest.java @@ -21,8 +21,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.UUID; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; /** * FormatTest @@ -60,7 +60,7 @@ public class FormatTest { private LocalDate date = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("uuid") private UUID uuid = null; @@ -258,7 +258,7 @@ public class FormatTest { this.date = date; } - public FormatTest dateTime(DateTime dateTime) { + public FormatTest dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -268,11 +268,11 @@ public class FormatTest { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 6965728b56b8..06ff5b6287f4 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * MixedPropertiesAndAdditionalPropertiesClass @@ -35,7 +35,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { private UUID uuid = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("map") private Map map = null; @@ -58,7 +58,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { this.uuid = uuid; } - public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -68,11 +68,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java index 7953b9749ff1..789c1a5ee251 100644 --- a/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2-java6/src/main/java/io/swagger/client/model/Order.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * Order @@ -36,7 +36,7 @@ public class Order { private Integer quantity = null; @JsonProperty("shipDate") - private DateTime shipDate = null; + private OffsetDateTime shipDate = null; /** * Order Status @@ -135,7 +135,7 @@ public class Order { this.quantity = quantity; } - public Order shipDate(DateTime shipDate) { + public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; } @@ -145,11 +145,11 @@ public class Order { * @return shipDate **/ @ApiModelProperty(value = "") - public DateTime getShipDate() { + public OffsetDateTime getShipDate() { return shipDate; } - public void setShipDate(DateTime shipDate) { + public void setShipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/jersey2-java8/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/jersey2-java8/docs/FakeClassnameTags123Api.md index 44b5bcd6bc83..468108b748ae 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/java/jersey2-java8/docs/FakeClassnameTags123Api.md @@ -1,6 +1,6 @@ # FakeClassnameTags123Api -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/java/jersey2/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/jersey2/docs/FakeClassnameTags123Api.md index 44b5bcd6bc83..468108b748ae 100644 --- a/samples/client/petstore/java/jersey2/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/java/jersey2/docs/FakeClassnameTags123Api.md @@ -1,6 +1,6 @@ # FakeClassnameTags123Api -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index f4a6d1c0eb36..01dcb19a0544 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -90,7 +90,7 @@ Float _float = 3.4F; // Float | None String string = "string_example"; // String | None byte[] binary = B; // byte[] | None LocalDate date = new LocalDate(); // LocalDate | None -DateTime dateTime = new DateTime(); // DateTime | None +OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None String password = "password_example"; // String | None String paramCallback = "paramCallback_example"; // String | None try { @@ -116,7 +116,7 @@ Name | Type | Description | Notes **string** | **String**| None | [optional] **binary** | **byte[]**| None | [optional] **date** | **LocalDate**| None | [optional] - **dateTime** | **DateTime**| None | [optional] + **dateTime** | **OffsetDateTime**| None | [optional] **password** | **String**| None | [optional] **paramCallback** | **String**| None | [optional] diff --git a/samples/client/petstore/java/resteasy/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/resteasy/docs/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..468108b748ae --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/FakeClassnameTags123Api.md @@ -0,0 +1,52 @@ +# FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + + +# **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.FakeClassnameTags123Api; + + +FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api(); +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 FakeClassnameTags123Api#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 + diff --git a/samples/client/petstore/java/resteasy/docs/FormatTest.md b/samples/client/petstore/java/resteasy/docs/FormatTest.md index 06bed417232a..c7a3acb3cb7e 100644 --- a/samples/client/petstore/java/resteasy/docs/FormatTest.md +++ b/samples/client/petstore/java/resteasy/docs/FormatTest.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes **_byte** | **byte[]** | | **binary** | **byte[]** | | [optional] **date** | [**LocalDate**](LocalDate.md) | | -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **uuid** | [**UUID**](UUID.md) | | [optional] **password** | **String** | | diff --git a/samples/client/petstore/java/resteasy/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/resteasy/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 349afef35a98..b12e2cd70e69 100644 --- a/samples/client/petstore/java/resteasy/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/java/resteasy/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | [**UUID**](UUID.md) | | [optional] -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **map** | [**Map<String, Animal>**](Animal.md) | | [optional] diff --git a/samples/client/petstore/java/resteasy/docs/Order.md b/samples/client/petstore/java/resteasy/docs/Order.md index a1089f5384eb..268c617d1ff1 100644 --- a/samples/client/petstore/java/resteasy/docs/Order.md +++ b/samples/client/petstore/java/resteasy/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | **Long** | | [optional] **petId** | **Long** | | [optional] **quantity** | **Integer** | | [optional] -**shipDate** | [**DateTime**](DateTime.md) | | [optional] +**shipDate** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] **complete** | **Boolean** | | [optional] diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/CustomInstantDeserializer.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/CustomInstantDeserializer.java new file mode 100644 index 000000000000..5ed8ba446ecb --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/CustomInstantDeserializer.java @@ -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 + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(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; + } + } +} diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java index 1bc9d46a7b64..60192509f52e 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java @@ -9,8 +9,8 @@ import javax.ws.rs.core.GenericType; import java.math.BigDecimal; import io.swagger.client.model.Client; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; import java.util.ArrayList; import java.util.HashMap; @@ -97,7 +97,7 @@ public class FakeApi { * @param paramCallback None (optional) * @throws ApiException if fails to make API call */ - public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, DateTime dateTime, String password, String paramCallback) throws ApiException { + public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'number' is set diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java new file mode 100644 index 000000000000..f51298081fe2 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -0,0 +1,78 @@ +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.ApiClient; +import io.swagger.client.Configuration; +import io.swagger.client.Pair; + +import javax.ws.rs.core.GenericType; + +import io.swagger.client.model.Client; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class FakeClassnameTags123Api { + private ApiClient apiClient; + + public FakeClassnameTags123Api() { + this(Configuration.getDefaultApiClient()); + } + + public FakeClassnameTags123Api(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 localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + 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 localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/FormatTest.java index c2aa5f35fed0..3897095d8402 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/FormatTest.java @@ -21,8 +21,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.UUID; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; /** * FormatTest @@ -60,7 +60,7 @@ public class FormatTest { private LocalDate date = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("uuid") private UUID uuid = null; @@ -258,7 +258,7 @@ public class FormatTest { this.date = date; } - public FormatTest dateTime(DateTime dateTime) { + public FormatTest dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -268,11 +268,11 @@ public class FormatTest { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 9cd0ca678b89..229669da93c8 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * MixedPropertiesAndAdditionalPropertiesClass @@ -35,7 +35,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { private UUID uuid = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("map") private Map map = null; @@ -58,7 +58,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { this.uuid = uuid; } - public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -68,11 +68,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/Order.java index 5ca9dcda14e8..2bed74ffa8c9 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/Order.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * Order @@ -36,7 +36,7 @@ public class Order { private Integer quantity = null; @JsonProperty("shipDate") - private DateTime shipDate = null; + private OffsetDateTime shipDate = null; /** * Order Status @@ -135,7 +135,7 @@ public class Order { this.quantity = quantity; } - public Order shipDate(DateTime shipDate) { + public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; } @@ -145,11 +145,11 @@ public class Order { * @return shipDate **/ @ApiModelProperty(value = "") - public DateTime getShipDate() { + public OffsetDateTime getShipDate() { return shipDate; } - public void setShipDate(DateTime shipDate) { + public void setShipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/resteasy/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/resteasy/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java new file mode 100644 index 000000000000..af5885aadddb --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java @@ -0,0 +1,51 @@ +/* + * 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. + */ + + +package io.swagger.client.api; + +import io.swagger.client.ApiException; +import io.swagger.client.model.Client; +import org.junit.Test; +import org.junit.Ignore; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * API tests for FakeClassnameTags123Api + */ +@Ignore +public class FakeClassnameTags123ApiTest { + + private final FakeClassnameTags123Api api = new FakeClassnameTags123Api(); + + + /** + * 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 + } + +} diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index f4a6d1c0eb36..01dcb19a0544 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -90,7 +90,7 @@ Float _float = 3.4F; // Float | None String string = "string_example"; // String | None byte[] binary = B; // byte[] | None LocalDate date = new LocalDate(); // LocalDate | None -DateTime dateTime = new DateTime(); // DateTime | None +OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None String password = "password_example"; // String | None String paramCallback = "paramCallback_example"; // String | None try { @@ -116,7 +116,7 @@ Name | Type | Description | Notes **string** | **String**| None | [optional] **binary** | **byte[]**| None | [optional] **date** | **LocalDate**| None | [optional] - **dateTime** | **DateTime**| None | [optional] + **dateTime** | **OffsetDateTime**| None | [optional] **password** | **String**| None | [optional] **paramCallback** | **String**| None | [optional] diff --git a/samples/client/petstore/java/resttemplate/docs/FakeClassnameTags123Api.md b/samples/client/petstore/java/resttemplate/docs/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..468108b748ae --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/FakeClassnameTags123Api.md @@ -0,0 +1,52 @@ +# FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + + +# **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.FakeClassnameTags123Api; + + +FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api(); +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 FakeClassnameTags123Api#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 + diff --git a/samples/client/petstore/java/resttemplate/docs/FormatTest.md b/samples/client/petstore/java/resttemplate/docs/FormatTest.md index 06bed417232a..c7a3acb3cb7e 100644 --- a/samples/client/petstore/java/resttemplate/docs/FormatTest.md +++ b/samples/client/petstore/java/resttemplate/docs/FormatTest.md @@ -14,7 +14,7 @@ Name | Type | Description | Notes **_byte** | **byte[]** | | **binary** | **byte[]** | | [optional] **date** | [**LocalDate**](LocalDate.md) | | -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **uuid** | [**UUID**](UUID.md) | | [optional] **password** | **String** | | diff --git a/samples/client/petstore/java/resttemplate/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/resttemplate/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 349afef35a98..b12e2cd70e69 100644 --- a/samples/client/petstore/java/resttemplate/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/java/resttemplate/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | [**UUID**](UUID.md) | | [optional] -**dateTime** | [**DateTime**](DateTime.md) | | [optional] +**dateTime** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **map** | [**Map<String, Animal>**](Animal.md) | | [optional] diff --git a/samples/client/petstore/java/resttemplate/docs/Order.md b/samples/client/petstore/java/resttemplate/docs/Order.md index a1089f5384eb..268c617d1ff1 100644 --- a/samples/client/petstore/java/resttemplate/docs/Order.md +++ b/samples/client/petstore/java/resttemplate/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **id** | **Long** | | [optional] **petId** | **Long** | | [optional] **quantity** | **Integer** | | [optional] -**shipDate** | [**DateTime**](DateTime.md) | | [optional] +**shipDate** | [**OffsetDateTime**](OffsetDateTime.md) | | [optional] **status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] **complete** | **Boolean** | | [optional] diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/CustomInstantDeserializer.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/CustomInstantDeserializer.java new file mode 100644 index 000000000000..5ed8ba446ecb --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/CustomInstantDeserializer.java @@ -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 + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(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; + } + } +} diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java index add04d01dee2..b948228e33b5 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java @@ -4,8 +4,8 @@ import io.swagger.client.ApiClient; import java.math.BigDecimal; import io.swagger.client.model.Client; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; import java.util.ArrayList; import java.util.HashMap; @@ -105,7 +105,7 @@ public class FakeApi { * @param paramCallback None * @throws RestClientException if an error occurs while attempting to invoke the API */ - 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 RestClientException { + 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 RestClientException { Object postBody = null; // verify the required parameter 'number' is set diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java new file mode 100644 index 000000000000..272bcc563c6a --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -0,0 +1,84 @@ +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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; + + +@Component("io.swagger.client.api.FakeClassnameTags123Api") +public class FakeClassnameTags123Api { + private ApiClient apiClient; + + public FakeClassnameTags123Api() { + this(new ApiClient()); + } + + @Autowired + public FakeClassnameTags123Api(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 + * + *

200 - successful operation + * @param body client model + * @return Client + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public Client testClassname(Client body) throws RestClientException { + Object postBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testClassname"); + } + + String path = UriComponentsBuilder.fromPath("/fake_classname_test").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { + "application/json" + }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { + "application/json" + }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } +} diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/FormatTest.java index c2aa5f35fed0..3897095d8402 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/FormatTest.java @@ -21,8 +21,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.UUID; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; /** * FormatTest @@ -60,7 +60,7 @@ public class FormatTest { private LocalDate date = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("uuid") private UUID uuid = null; @@ -258,7 +258,7 @@ public class FormatTest { this.date = date; } - public FormatTest dateTime(DateTime dateTime) { + public FormatTest dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -268,11 +268,11 @@ public class FormatTest { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 9cd0ca678b89..229669da93c8 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * MixedPropertiesAndAdditionalPropertiesClass @@ -35,7 +35,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { private UUID uuid = null; @JsonProperty("dateTime") - private DateTime dateTime = null; + private OffsetDateTime dateTime = null; @JsonProperty("map") private Map map = null; @@ -58,7 +58,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass { this.uuid = uuid; } - public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) { + public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; return this; } @@ -68,11 +68,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return dateTime **/ @ApiModelProperty(value = "") - public DateTime getDateTime() { + public OffsetDateTime getDateTime() { return dateTime; } - public void setDateTime(DateTime dateTime) { + public void setDateTime(OffsetDateTime dateTime) { this.dateTime = dateTime; } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/Order.java index 5ca9dcda14e8..2bed74ffa8c9 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/Order.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.joda.time.DateTime; +import org.threeten.bp.OffsetDateTime; /** * Order @@ -36,7 +36,7 @@ public class Order { private Integer quantity = null; @JsonProperty("shipDate") - private DateTime shipDate = null; + private OffsetDateTime shipDate = null; /** * Order Status @@ -135,7 +135,7 @@ public class Order { this.quantity = quantity; } - public Order shipDate(DateTime shipDate) { + public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; } @@ -145,11 +145,11 @@ public class Order { * @return shipDate **/ @ApiModelProperty(value = "") - public DateTime getShipDate() { + public OffsetDateTime getShipDate() { return shipDate; } - public void setShipDate(DateTime shipDate) { + public void setShipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; } diff --git a/samples/client/petstore/java/resttemplate/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java b/samples/client/petstore/java/resttemplate/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java new file mode 100644 index 000000000000..641e4fc7008a --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/io/swagger/client/api/FakeClassnameTags123ApiTest.java @@ -0,0 +1,50 @@ +/* + * 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. + */ + + +package io.swagger.client.api; + +import io.swagger.client.model.Client; +import org.junit.Test; +import org.junit.Ignore; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * API tests for FakeClassnameTags123Api + */ +@Ignore +public class FakeClassnameTags123ApiTest { + + private final FakeClassnameTags123Api api = new FakeClassnameTags123Api(); + + + /** + * To test class name in snake case + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void testClassnameTest() { + Client body = null; + Client response = api.testClassname(body); + + // TODO: test validations + } + +}