diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index 8239da1fd6bd5..bb4212335892b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -678,6 +678,8 @@ public void processOpts() { additionalProperties.remove(SERIALIZATION_LIBRARY_GSON); additionalProperties.remove(SERIALIZATION_LIBRARY_JSONB); supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java")); + supportingFiles.add(new SupportingFile("RFC3339InstantDeserializer.mustache", invokerFolder, "RFC3339InstantDeserializer.java")); + supportingFiles.add(new SupportingFile("RFC3339JavaTimeModule.mustache", invokerFolder, "RFC3339JavaTimeModule.java")); break; case SERIALIZATION_LIBRARY_GSON: additionalProperties.put(SERIALIZATION_LIBRARY_GSON, "true"); diff --git a/modules/openapi-generator/src/main/resources/Java/RFC3339InstantDeserializer.mustache b/modules/openapi-generator/src/main/resources/Java/RFC3339InstantDeserializer.mustache new file mode 100644 index 0000000000000..ec9e5b8e91c09 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/Java/RFC3339InstantDeserializer.mustache @@ -0,0 +1,74 @@ +{{>licenseInfo}} +package {{invokerPackage}}; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +{{>generatedAnnotation}} +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/Java/RFC3339JavaTimeModule.mustache b/modules/openapi-generator/src/main/resources/Java/RFC3339JavaTimeModule.mustache new file mode 100644 index 0000000000000..7cc80277a0251 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/Java/RFC3339JavaTimeModule.mustache @@ -0,0 +1,20 @@ +{{>licenseInfo}} +package {{invokerPackage}}; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +{{>generatedAnnotation}} +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache index 6a26f2d8d8b43..27a5558f1c936 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache @@ -149,6 +149,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { {{#openApiNullable}} objectMapper.registerModule(new JsonNullableModule()); {{/openApiNullable}} + objectMapper.registerModule(new RFC3339JavaTimeModule()); objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat()); dateFormat = ApiClient.buildDefaultDateFormat(); diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache index f744eec139eff..ba23b48823adf 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache @@ -187,6 +187,7 @@ public class ApiClient { {{/joda}} objectMapper.registerModule(new JavaTimeModule()); {{#openApiNullable}} + objectMapper.registerModule(new RFC3339JavaTimeModule()); JsonNullableModule jnm = new JsonNullableModule(); objectMapper.registerModule(jnm); {{/openApiNullable}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache index 8ed579473587b..bfb6d7826827f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache @@ -45,6 +45,7 @@ public class JSON implements ContextResolver { {{#openApiNullable}} .addModule(new JsonNullableModule()) {{/openApiNullable}} + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/JSON.mustache index 8ed579473587b..bfb6d7826827f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/JSON.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/JSON.mustache @@ -45,6 +45,7 @@ public class JSON implements ContextResolver { {{#openApiNullable}} .addModule(new JsonNullableModule()) {{/openApiNullable}} + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache index a641525af10a7..59f77999acb6e 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache @@ -196,6 +196,7 @@ public class ApiClient { {{#openApiNullable}} mapper.registerModule(new JsonNullableModule()); {{/openApiNullable}} + mapper.registerModule(new RFC3339JavaTimeModule()); return mapper; } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index 1bbd795f65104..326ac30a20a48 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -519,7 +519,7 @@ public void testSupportedSecuritySchemesJersey() { List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); - assertThat(files).hasSize(32); + assertThat(files).hasSize(34); validateJavaSourceFiles(files); assertThat(output.resolve("src/main/java/xyz/abcdef/api/DefaultApi.java")).content().contains( "public class DefaultApi", @@ -586,7 +586,7 @@ public void testSupportedSecuritySchemesJersey() { List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); - assertThat(files).hasSize(35); + assertThat(files).hasSize(37); validateJavaSourceFiles(files); assertThat(output.resolve("src/main/java/xyz/abcdef/api/PingApi.java")).content().contains( @@ -1389,7 +1389,7 @@ public void testRestTemplateWithFreeFormInQueryParameters() { List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); validateJavaSourceFiles(files); - assertThat(files).hasSize(35); + assertThat(files).hasSize(37); TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/ApiClient.java"), "public static String urlEncode(String s) { return URLEncoder.encode(s," + " UTF_8).replaceAll(\"\\\\+\", \"%20\"); }" @@ -1411,7 +1411,7 @@ public void testRestTemplateWithFreeFormInQueryParameters() { List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); validateJavaSourceFiles(files); - assertThat(files).hasSize(38); + assertThat(files).hasSize(40); assertThat(output.resolve("src/main/java/xyz/abcdef/api/DefaultApi.java")).content() .contains( "localVarQueryParams.addAll(ApiClient.parameterToPairs(\"since\", queryObject.getSince()));", diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/apachehttpclient/ApacheHttpClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/apachehttpclient/ApacheHttpClientCodegenTest.java index 2ecf67b896aca..bef8841d78e3d 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/apachehttpclient/ApacheHttpClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/apachehttpclient/ApacheHttpClientCodegenTest.java @@ -56,7 +56,7 @@ public void testApacheHttpClientExplodedQueryParamObject() throws IOException { DefaultGenerator generator = new DefaultGenerator(); List files = generator.opts(clientOptInput).generate(); - Assert.assertEquals(files.size(), 42); + Assert.assertEquals(files.size(), 44); validateJavaSourceFiles(files); TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/api/DefaultApi.java"), diff --git a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES index 38f10d604ab96..0e2dd5e4c522c 100644 --- a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES @@ -39,6 +39,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java index 8f64979e2a826..1a656e10e65fa 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java @@ -122,6 +122,7 @@ public ApiClient(CloseableHttpClient httpClient) { objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); objectMapper.registerModule(new JavaTimeModule()); objectMapper.registerModule(new JsonNullableModule()); + objectMapper.registerModule(new RFC3339JavaTimeModule()); objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat()); dateFormat = ApiClient.buildDefaultDateFormat(); diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..9cf9df237dc77 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..dcf93135b07e2 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/echo_api/java/native/.openapi-generator/FILES b/samples/client/echo_api/java/native/.openapi-generator/FILES index 8a16d65ff80bc..c6cddf350ae9f 100644 --- a/samples/client/echo_api/java/native/.openapi-generator/FILES +++ b/samples/client/echo_api/java/native/.openapi-generator/FILES @@ -39,6 +39,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AuthApi.java diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/ApiClient.java index 4682c2b4cdd85..7c6b3cb6744a0 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/ApiClient.java @@ -203,6 +203,7 @@ protected ObjectMapper createDefaultObjectMapper() { mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); return mapper; } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..9cf9df237dc77 --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..dcf93135b07e2 --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/echo_api/java/restclient/.openapi-generator/FILES b/samples/client/echo_api/java/restclient/.openapi-generator/FILES index 045decee44eeb..939acb947c399 100644 --- a/samples/client/echo_api/java/restclient/.openapi-generator/FILES +++ b/samples/client/echo_api/java/restclient/.openapi-generator/FILES @@ -35,6 +35,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..ab4e9b42ccf45 --- /dev/null +++ b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..0832f6ed28726 --- /dev/null +++ b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/echo_api/java/resteasy/.openapi-generator/FILES b/samples/client/echo_api/java/resteasy/.openapi-generator/FILES index 82ee0086cb7ce..9812c52b32bc5 100644 --- a/samples/client/echo_api/java/resteasy/.openapi-generator/FILES +++ b/samples/client/echo_api/java/resteasy/.openapi-generator/FILES @@ -39,6 +39,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..9cf9df237dc77 --- /dev/null +++ b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..dcf93135b07e2 --- /dev/null +++ b/samples/client/echo_api/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/echo_api/java/resttemplate/.openapi-generator/FILES b/samples/client/echo_api/java/resttemplate/.openapi-generator/FILES index f87bbe0370584..07e16f0ab7d97 100644 --- a/samples/client/echo_api/java/resttemplate/.openapi-generator/FILES +++ b/samples/client/echo_api/java/resttemplate/.openapi-generator/FILES @@ -36,6 +36,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AuthApi.java diff --git a/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..9cf9df237dc77 --- /dev/null +++ b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..dcf93135b07e2 --- /dev/null +++ b/samples/client/echo_api/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/jersey2-oneOf-Mixed/.openapi-generator/FILES b/samples/client/others/java/jersey2-oneOf-Mixed/.openapi-generator/FILES index 7f39ba0d19eae..ae2dc56a6cef6 100644 --- a/samples/client/others/java/jersey2-oneOf-Mixed/.openapi-generator/FILES +++ b/samples/client/others/java/jersey2-oneOf-Mixed/.openapi-generator/FILES @@ -24,6 +24,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/JSON.java b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/JSON.java index a51bc7d5d7ba7..1965fdd1d3570 100644 --- a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..d210507b3a6e2 --- /dev/null +++ b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Example - oneOf data type + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..8a28d6b14b2ff --- /dev/null +++ b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Example - oneOf data type + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/jersey2-oneOf-duplicates/.openapi-generator/FILES b/samples/client/others/java/jersey2-oneOf-duplicates/.openapi-generator/FILES index 7f39ba0d19eae..ae2dc56a6cef6 100644 --- a/samples/client/others/java/jersey2-oneOf-duplicates/.openapi-generator/FILES +++ b/samples/client/others/java/jersey2-oneOf-duplicates/.openapi-generator/FILES @@ -24,6 +24,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/JSON.java b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/JSON.java index a51bc7d5d7ba7..1965fdd1d3570 100644 --- a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..d210507b3a6e2 --- /dev/null +++ b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Example - oneOf data type + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..8a28d6b14b2ff --- /dev/null +++ b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Example - oneOf data type + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES b/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES index 611375d94d7ff..9078c63e26abc 100644 --- a/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES +++ b/samples/client/others/java/restclient-useAbstractionForFiles/.openapi-generator/FILES @@ -18,6 +18,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..f233ffed8b632 --- /dev/null +++ b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..8145451639aae --- /dev/null +++ b/samples/client/others/java/restclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/resttemplate-list-schema-validation/.openapi-generator/FILES b/samples/client/others/java/resttemplate-list-schema-validation/.openapi-generator/FILES index 04dcaaa7bc6de..70a643ed82ac1 100644 --- a/samples/client/others/java/resttemplate-list-schema-validation/.openapi-generator/FILES +++ b/samples/client/others/java/resttemplate-list-schema-validation/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/UserApi.java diff --git a/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..46b262aa04505 --- /dev/null +++ b/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * issue-17485 + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..d026bdf91f5eb --- /dev/null +++ b/samples/client/others/java/resttemplate-list-schema-validation/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * issue-17485 + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/resttemplate-useAbstractionForFiles/.openapi-generator/FILES b/samples/client/others/java/resttemplate-useAbstractionForFiles/.openapi-generator/FILES index 692324c1c65f7..8727facdef6bb 100644 --- a/samples/client/others/java/resttemplate-useAbstractionForFiles/.openapi-generator/FILES +++ b/samples/client/others/java/resttemplate-useAbstractionForFiles/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/ResourceApi.java diff --git a/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2faafe11c86ac --- /dev/null +++ b/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..71cea538bf054 --- /dev/null +++ b/samples/client/others/java/resttemplate-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES b/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES index 611375d94d7ff..9078c63e26abc 100644 --- a/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES +++ b/samples/client/others/java/webclient-useAbstractionForFiles/.openapi-generator/FILES @@ -18,6 +18,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2faafe11c86ac --- /dev/null +++ b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..71cea538bf054 --- /dev/null +++ b/samples/client/others/java/webclient-useAbstractionForFiles/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Response file abstraction test + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES index 5e072857db4d5..2e1470853b44a 100644 --- a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES @@ -78,6 +78,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java index 74a56d807d4ad..dca6ece870a07 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java @@ -167,6 +167,7 @@ public ApiClient(CloseableHttpClient httpClient) { objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); objectMapper.registerModule(new JavaTimeModule()); objectMapper.registerModule(new JsonNullableModule()); + objectMapper.registerModule(new RFC3339JavaTimeModule()); objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat()); dateFormat = ApiClient.buildDefaultDateFormat(); diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES b/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES index ea7aa35228106..b74e3187fdd74 100644 --- a/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/java/org/openapitools/client/ApiResponseDecoder.java src/main/java/org/openapitools/client/EncodingUtils.java src/main/java/org/openapitools/client/ParamExpander.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES index fe92d027a7afe..90879d2977f73 100644 --- a/samples/client/petstore/java/feign/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/java/org/openapitools/client/ApiResponseDecoder.java src/main/java/org/openapitools/client/EncodingUtils.java src/main/java/org/openapitools/client/ParamExpander.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java index 0b6dd9c0a89ce..d8ed8c5d99c8b 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java @@ -146,6 +146,7 @@ private ObjectMapper createObjectMapper() { objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new RFC3339DateFormat()); objectMapper.registerModule(new JavaTimeModule()); + objectMapper.registerModule(new RFC3339JavaTimeModule()); JsonNullableModule jnm = new JsonNullableModule(); objectMapper.registerModule(jnm); return objectMapper; diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/google-api-client/.openapi-generator/FILES b/samples/client/petstore/java/google-api-client/.openapi-generator/FILES index c04117ed45d41..7a8eefa7baf0c 100644 --- a/samples/client/petstore/java/google-api-client/.openapi-generator/FILES +++ b/samples/client/petstore/java/google-api-client/.openapi-generator/FILES @@ -67,6 +67,8 @@ settings.gradle src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/.openapi-generator/FILES b/samples/client/petstore/java/jersey2-java8-localdatetime/.openapi-generator/FILES index e883eed4ead91..2ac3641bce96c 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/.openapi-generator/FILES +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/.openapi-generator/FILES @@ -73,6 +73,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/JSON.java index 01ab45158d128..204e697103acb 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/jersey2-java8/.openapi-generator/FILES b/samples/client/petstore/java/jersey2-java8/.openapi-generator/FILES index e883eed4ead91..2ac3641bce96c 100644 --- a/samples/client/petstore/java/jersey2-java8/.openapi-generator/FILES +++ b/samples/client/petstore/java/jersey2-java8/.openapi-generator/FILES @@ -73,6 +73,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java index 01ab45158d128..204e697103acb 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/jersey3-oneOf/.openapi-generator/FILES b/samples/client/petstore/java/jersey3-oneOf/.openapi-generator/FILES index 627129f624e9e..b7eed46363859 100644 --- a/samples/client/petstore/java/jersey3-oneOf/.openapi-generator/FILES +++ b/samples/client/petstore/java/jersey3-oneOf/.openapi-generator/FILES @@ -25,6 +25,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java index 11072c035edb5..4cc85a22e7404 100644 --- a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..434b377e983b9 --- /dev/null +++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * dummy + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..ef71af5815f59 --- /dev/null +++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * dummy + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/jersey3/.openapi-generator/FILES b/samples/client/petstore/java/jersey3/.openapi-generator/FILES index 78d8fe209b3a8..fe5eb6cb19342 100644 --- a/samples/client/petstore/java/jersey3/.openapi-generator/FILES +++ b/samples/client/petstore/java/jersey3/.openapi-generator/FILES @@ -104,6 +104,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/JSON.java index cee50d7ad67cf..d46111ef91586 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/.openapi-generator/FILES b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/.openapi-generator/FILES index 6943768893bd7..2a68f3683bd36 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/.openapi-generator/FILES +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/User.md docs/UserApi.md pom.xml src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/api/ApiException.java src/main/java/org/openapitools/client/api/ApiExceptionMapper.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..965b49cf9d0c9 --- /dev/null +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..5f862bcd286b5 --- /dev/null +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/.openapi-generator/FILES b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/.openapi-generator/FILES index 6943768893bd7..2a68f3683bd36 100644 --- a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/.openapi-generator/FILES +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/User.md docs/UserApi.md pom.xml src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/api/ApiException.java src/main/java/org/openapitools/client/api/ApiExceptionMapper.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..965b49cf9d0c9 --- /dev/null +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..5f862bcd286b5 --- /dev/null +++ b/samples/client/petstore/java/microprofile-rest-client-3.0-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native-async/.openapi-generator/FILES b/samples/client/petstore/java/native-async/.openapi-generator/FILES index ed0ac7f107b6d..ee4301dd57067 100644 --- a/samples/client/petstore/java/native-async/.openapi-generator/FILES +++ b/samples/client/petstore/java/native-async/.openapi-generator/FILES @@ -103,6 +103,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AnotherFakeApi.java diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/ApiClient.java index b04e4299deb07..b5b7034276431 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/ApiClient.java @@ -203,6 +203,7 @@ protected ObjectMapper createDefaultObjectMapper() { mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); return mapper; } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/native-jakarta/.openapi-generator/FILES index 653168e7f550e..58add489978c4 100644 --- a/samples/client/petstore/java/native-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/native-jakarta/.openapi-generator/FILES @@ -30,6 +30,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiClient.java index 828938c91eb9e..81dc5612ea224 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiClient.java @@ -203,6 +203,7 @@ protected ObjectMapper createDefaultObjectMapper() { mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); return mapper; } diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2f99a4821814f --- /dev/null +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..5028edda37667 --- /dev/null +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/native/.openapi-generator/FILES b/samples/client/petstore/java/native/.openapi-generator/FILES index ed0ac7f107b6d..ee4301dd57067 100644 --- a/samples/client/petstore/java/native/.openapi-generator/FILES +++ b/samples/client/petstore/java/native/.openapi-generator/FILES @@ -103,6 +103,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AnotherFakeApi.java diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java index b04e4299deb07..b5b7034276431 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java @@ -203,6 +203,7 @@ protected ObjectMapper createDefaultObjectMapper() { mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new JsonNullableModule()); + mapper.registerModule(new RFC3339JavaTimeModule()); return mapper; } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/rest-assured-jackson/.openapi-generator/FILES b/samples/client/petstore/java/rest-assured-jackson/.openapi-generator/FILES index 64cd57d8760c1..cf24cc888375e 100644 --- a/samples/client/petstore/java/rest-assured-jackson/.openapi-generator/FILES +++ b/samples/client/petstore/java/rest-assured-jackson/.openapi-generator/FILES @@ -69,6 +69,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BeanValidationException.java src/main/java/org/openapitools/client/JacksonObjectMapper.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ResponseSpecBuilders.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES b/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES index 4f38a796a270f..eedafa945afdd 100644 --- a/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient-nullable-arrays/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..4add62fcab163 --- /dev/null +++ b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Minimal Example + * byte Array error in equal method + * + * The version of the OpenAPI document: v1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..16d8c29515481 --- /dev/null +++ b/samples/client/petstore/java/restclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Minimal Example + * byte Array error in equal method + * + * The version of the OpenAPI document: v1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient-swagger2/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES b/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/restclient/.openapi-generator/FILES b/samples/client/petstore/java/restclient/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/restclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/restclient/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resteasy/.openapi-generator/FILES b/samples/client/petstore/java/resteasy/.openapi-generator/FILES index 89d81862bef6d..a0214c80314a2 100644 --- a/samples/client/petstore/java/resteasy/.openapi-generator/FILES +++ b/samples/client/petstore/java/resteasy/.openapi-generator/FILES @@ -78,6 +78,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resttemplate-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-jakarta/.openapi-generator/FILES index 94e696c01b7ac..7ca742d0e6229 100644 --- a/samples/client/petstore/java/resttemplate-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-jakarta/.openapi-generator/FILES @@ -27,6 +27,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2f99a4821814f --- /dev/null +++ b/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..5028edda37667 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resttemplate-swagger1/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-swagger1/.openapi-generator/FILES index 94e696c01b7ac..7ca742d0e6229 100644 --- a/samples/client/petstore/java/resttemplate-swagger1/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-swagger1/.openapi-generator/FILES @@ -27,6 +27,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..7fe2288604bee --- /dev/null +++ b/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..d907858a352b1 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resttemplate-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-swagger2/.openapi-generator/FILES index 94e696c01b7ac..7ca742d0e6229 100644 --- a/samples/client/petstore/java/resttemplate-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-swagger2/.openapi-generator/FILES @@ -27,6 +27,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/PetApi.java diff --git a/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..7fe2288604bee --- /dev/null +++ b/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..d907858a352b1 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES index 2ee680a3d8734..27d1ae06fc6cb 100644 --- a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES @@ -75,6 +75,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AnotherFakeApi.java diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES index 2ee680a3d8734..27d1ae06fc6cb 100644 --- a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES @@ -75,6 +75,8 @@ src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/BaseApi.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/api/AnotherFakeApi.java diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/retrofit2-play26/.openapi-generator/FILES b/samples/client/petstore/java/retrofit2-play26/.openapi-generator/FILES index 49cbeaf249c90..7bc7f561ba35e 100644 --- a/samples/client/petstore/java/retrofit2-play26/.openapi-generator/FILES +++ b/samples/client/petstore/java/retrofit2-play26/.openapi-generator/FILES @@ -72,6 +72,8 @@ src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/Play26CallAdapterFactory.java src/main/java/org/openapitools/client/Play26CallFactory.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/vertx-no-nullable/.openapi-generator/FILES b/samples/client/petstore/java/vertx-no-nullable/.openapi-generator/FILES index 594a8dee889ba..5fabac90dc5ec 100644 --- a/samples/client/petstore/java/vertx-no-nullable/.openapi-generator/FILES +++ b/samples/client/petstore/java/vertx-no-nullable/.openapi-generator/FILES @@ -71,6 +71,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/vertx/.openapi-generator/FILES b/samples/client/petstore/java/vertx/.openapi-generator/FILES index bb3ea604f0637..e027fbeeb5e17 100644 --- a/samples/client/petstore/java/vertx/.openapi-generator/FILES +++ b/samples/client/petstore/java/vertx/.openapi-generator/FILES @@ -77,6 +77,8 @@ src/main/java/org/openapitools/client/Configuration.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c23190680ef5 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..34b8017b8d291 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES b/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES index 4f38a796a270f..eedafa945afdd 100644 --- a/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-nullable-arrays/.openapi-generator/FILES @@ -19,6 +19,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..86559e8017dd2 --- /dev/null +++ b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * Minimal Example + * byte Array error in equal method + * + * The version of the OpenAPI document: v1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..ec262e969d84f --- /dev/null +++ b/samples/client/petstore/java/webclient-nullable-arrays/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * Minimal Example + * byte Array error in equal method + * + * The version of the OpenAPI document: v1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES index fcdb2bc32220a..5556008560988 100644 --- a/samples/client/petstore/java/webclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES @@ -74,6 +74,8 @@ src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/.openapi-generator/FILES b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/.openapi-generator/FILES index bd814473a6e97..d159343e3ea2d 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/.openapi-generator/FILES +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/.openapi-generator/FILES @@ -23,6 +23,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java index 47f755ca904db..f6bc43c392000 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java @@ -43,6 +43,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..fba83bd40efd7 --- /dev/null +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Extension x-auth-id-alias + * This specification shows how to use x-auth-id-alias extension for API keys. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..5fd9654bcd42d --- /dev/null +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Extension x-auth-id-alias + * This specification shows how to use x-auth-id-alias extension for API keys. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/.openapi-generator/FILES b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/.openapi-generator/FILES index b3e61584f3d8b..fe75d5fe8ab5d 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/.openapi-generator/FILES @@ -26,6 +26,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/JSON.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/JSON.java index 3a30e4ce23b84..20c0a4276af97 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/JSON.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..5128a1567093e --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * test + * test + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..b61e30e01d3e3 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * test + * test + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/.openapi-generator/FILES b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/.openapi-generator/FILES index 81781f3c3a6f5..88201794d5a74 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/.openapi-generator/FILES @@ -31,6 +31,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/JSON.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/JSON.java index e75200194e33d..7a22b130feb01 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/JSON.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..7fe2288604bee --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..d907858a352b1 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/.openapi-generator/FILES b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/.openapi-generator/FILES index 81781f3c3a6f5..88201794d5a74 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/.openapi-generator/FILES @@ -31,6 +31,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/JSON.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/JSON.java index e75200194e33d..7a22b130feb01 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/JSON.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..7fe2288604bee --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..d907858a352b1 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger2/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES b/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES index 78d8fe209b3a8..fe5eb6cb19342 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES @@ -104,6 +104,8 @@ src/main/java/org/openapitools/client/JSON.java src/main/java/org/openapitools/client/JavaTimeFormatter.java src/main/java/org/openapitools/client/Pair.java src/main/java/org/openapitools/client/RFC3339DateFormat.java +src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java src/main/java/org/openapitools/client/ServerConfiguration.java src/main/java/org/openapitools/client/ServerVariable.java src/main/java/org/openapitools/client/StringUtil.java diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java index aabda5dadd915..5913c8c74c1f1 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/JSON.java @@ -44,6 +44,7 @@ public JSON() { .defaultDateFormat(new RFC3339DateFormat()) .addModule(new JavaTimeModule()) .addModule(new JsonNullableModule()) + .addModule(new RFC3339JavaTimeModule()) .build(); } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..2c5944649464e --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..75ecc1cd6b78c --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/* + * OpenAPI 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +} diff --git a/samples/server/petstore/java-microprofile/.openapi-generator/FILES b/samples/server/petstore/java-microprofile/.openapi-generator/FILES index 64572f1a20a4e..04c00069a7b83 100644 --- a/samples/server/petstore/java-microprofile/.openapi-generator/FILES +++ b/samples/server/petstore/java-microprofile/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/User.md docs/UserApi.md pom.xml src/main/java/org/openapitools/server/RFC3339DateFormat.java +src/main/java/org/openapitools/server/RFC3339InstantDeserializer.java +src/main/java/org/openapitools/server/RFC3339JavaTimeModule.java src/main/java/org/openapitools/server/api/ApiException.java src/main/java/org/openapitools/server/api/ApiExceptionMapper.java src/main/java/org/openapitools/server/api/PetApi.java diff --git a/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339InstantDeserializer.java b/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339InstantDeserializer.java new file mode 100644 index 0000000000000..852796f32a636 --- /dev/null +++ b/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339InstantDeserializer.java @@ -0,0 +1,85 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.server; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaMicroprofileServerCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true // yes, replace zero offset with Z + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false // keep zero offset and Z separate since zones explicitly supported + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339JavaTimeModule.java b/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339JavaTimeModule.java new file mode 100644 index 0000000000000..4f0efabbd4e13 --- /dev/null +++ b/samples/server/petstore/java-microprofile/src/main/java/org/openapitools/server/RFC3339JavaTimeModule.java @@ -0,0 +1,31 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.server; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaMicroprofileServerCodegen", comments = "Generator version: 7.10.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } +}