mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-02 15:00:58 +00:00
[java][jersey] Fix ALLOW_COERCION_OF_SCALARS (#14619)
* Remove dead code * Refactor containsKey before get * Minor refactor * Use JsonMapper.builder() to build ObjectMapper Fix a bug where ALLOW_COERCION_OF_SCALARS wasn't set properly. * Update samples * Oops, fix a typo
This commit is contained in:
parent
31c3a40b4c
commit
ca19fa0ef3
@ -449,9 +449,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1067,11 +1068,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1173,14 +1169,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1191,6 +1184,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1201,11 +1196,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -27,23 +27,23 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
{{#joda}}
|
||||
mapper.registerModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#openApiNullable}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
{{/openApiNullable}}
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
{{#joda}}
|
||||
.addModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#openApiNullable}}
|
||||
.addModule(new JsonNullableModule())
|
||||
{{/openApiNullable}}
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,9 +449,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1067,11 +1068,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1173,14 +1169,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1191,6 +1184,8 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1201,11 +1196,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -27,23 +27,23 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
{{#joda}}
|
||||
mapper.registerModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#openApiNullable}}
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
{{/openApiNullable}}
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
{{#joda}}
|
||||
.addModule(new JodaModule());
|
||||
{{/joda}}
|
||||
{{#openApiNullable}}
|
||||
.addModule(new JsonNullableModule())
|
||||
{{/openApiNullable}}
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,9 +372,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -988,11 +989,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1094,14 +1090,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1112,6 +1105,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1122,11 +1117,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,9 +372,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -988,11 +989,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1094,14 +1090,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1112,6 +1105,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1122,11 +1117,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,9 +456,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1072,11 +1073,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1178,14 +1174,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1196,6 +1189,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1206,11 +1201,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -384,9 +384,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -902,11 +903,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1008,14 +1004,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1026,6 +1019,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1036,11 +1031,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -19,18 +19,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,9 +329,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -847,11 +848,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -953,14 +949,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -971,6 +964,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -981,11 +976,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -356,9 +356,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -972,11 +973,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1078,14 +1074,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1096,6 +1089,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1106,11 +1101,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,9 +456,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
if (auth instanceof ApiKeyAuth) {
|
||||
String name = authEntry.getKey();
|
||||
// respect x-auth-id-alias property
|
||||
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
|
||||
if (secrets.containsKey(name)) {
|
||||
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
|
||||
name = authenticationLookup.getOrDefault(name, name);
|
||||
String secret = secrets.get(name);
|
||||
if (secret != null) {
|
||||
((ApiKeyAuth) auth).setApiKey(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1072,11 +1073,6 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
return file;
|
||||
}
|
||||
|
||||
String contentType = null;
|
||||
List<Object> contentTypes = response.getHeaders().get("Content-Type");
|
||||
if (contentTypes != null && !contentTypes.isEmpty())
|
||||
contentType = String.valueOf(contentTypes.get(0));
|
||||
|
||||
// read the entity stream multiple times
|
||||
response.bufferEntity();
|
||||
|
||||
@ -1178,14 +1174,11 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
boolean isBodyNullable)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
String targetURL;
|
||||
if (serverIndex != null && operationServers.containsKey(operation)) {
|
||||
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
|
||||
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
|
||||
operationServerVariables.get(operation) : serverVariables;
|
||||
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
|
||||
List<ServerConfiguration> serverConfigurations;
|
||||
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
|
||||
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
|
||||
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
|
||||
if (index < 0 || index >= serverConfigurations.size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format(
|
||||
@ -1196,6 +1189,8 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
} else {
|
||||
targetURL = this.basePath + path;
|
||||
}
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
|
||||
WebTarget target = httpClient.target(targetURL);
|
||||
|
||||
if (queryParams != null) {
|
||||
@ -1206,11 +1201,10 @@ public class ApiClient extends JavaTimeFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
Invocation.Builder invocationBuilder;
|
||||
Invocation.Builder invocationBuilder = target.request();
|
||||
|
||||
if (accept != null) {
|
||||
invocationBuilder = target.request().accept(accept);
|
||||
} else {
|
||||
invocationBuilder = target.request();
|
||||
invocationBuilder = invocationBuilder.accept(accept);
|
||||
}
|
||||
|
||||
for (Entry<String, String> entry : cookieParams.entrySet()) {
|
||||
|
@ -20,18 +20,18 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
private ObjectMapper mapper;
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.setDateFormat(new RFC3339DateFormat());
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
JsonNullableModule jnm = new JsonNullableModule();
|
||||
mapper.registerModule(jnm);
|
||||
mapper = JsonMapper.builder()
|
||||
.serializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
|
||||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
|
||||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
|
||||
.defaultDateFormat(new RFC3339DateFormat())
|
||||
.addModule(new JavaTimeModule())
|
||||
.addModule(new JsonNullableModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user