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 d38af2abb69..abdea5d8f27 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 @@ -18,6 +18,10 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.Charset; import java.time.Duration; +{{#java8}} +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +{{/java8}} import java.util.Collection; import java.util.Collections; import java.util.List; @@ -57,6 +61,11 @@ public class ApiClient { if (value == null) { return ""; } + {{#java8}} + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + {{/java8}} return value.toString(); } @@ -87,7 +96,7 @@ public class ApiClient { if (name == null || name.isEmpty() || value == null) { return Collections.emptyList(); } - return Collections.singletonList(new Pair(urlEncode(name), urlEncode(value.toString()))); + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); } /** diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 04001417a82..3fd6265e636 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -216,6 +216,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } 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 c03fab20332..ce2f5a68f61 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 @@ -27,6 +27,8 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.Charset; import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -66,6 +68,9 @@ public class ApiClient { if (value == null) { return ""; } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } return value.toString(); } @@ -96,7 +101,7 @@ public class ApiClient { if (name == null || name.isEmpty() || value == null) { return Collections.emptyList(); } - return Collections.singletonList(new Pair(urlEncode(name), urlEncode(value.toString()))); + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); } /** 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 c03fab20332..ce2f5a68f61 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 @@ -27,6 +27,8 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.Charset; import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -66,6 +68,9 @@ public class ApiClient { if (value == null) { return ""; } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } return value.toString(); } @@ -96,7 +101,7 @@ public class ApiClient { if (name == null || name.isEmpty() || value == null) { return Collections.emptyList(); } - return Collections.singletonList(new Pair(urlEncode(name), urlEncode(value.toString()))); + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); } /** diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts index f84920e94e3..89b721d0c5d 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts index 533e9912b14..e04306cadcb 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts index 3e18bd1692c..c541d163bd4 100644 --- a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts index 87070cedb4c..3673659f277 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts @@ -227,6 +227,9 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } if (value instanceof Object) { return querystring(value as HTTPQuery, fullKey); } diff --git a/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java index c03fab20332..ce2f5a68f61 100644 --- a/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/ApiClient.java @@ -27,6 +27,8 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.charset.Charset; import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -66,6 +68,9 @@ public class ApiClient { if (value == null) { return ""; } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } return value.toString(); } @@ -96,7 +101,7 @@ public class ApiClient { if (name == null || name.isEmpty() || value == null) { return Collections.emptyList(); } - return Collections.singletonList(new Pair(urlEncode(name), urlEncode(value.toString()))); + return Collections.singletonList(new Pair(urlEncode(name), urlEncode(valueToString(value)))); } /**