forked from loafle/openapi-generator-original
Fixed serialization of date-time query parameters. (#8616)
This commit is contained in:
parent
578420cfa9
commit
6fdd8ea3da
@ -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))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user