diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index 6e93ab629d5..6ca6ce599f0 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 47f11153f73..7aa4c6d0859 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 @@ -27,23 +27,23 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache index 6e93ab629d5..6ca6ce599f0 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey3/ApiClient.mustache @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 47f11153f73..7aa4c6d0859 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 @@ -27,23 +27,23 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/ApiClient.java index 506ac25db7d..edd349531d9 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 88345206919..24317dfe36a 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index 506ac25db7d..edd349531d9 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 88345206919..24317dfe36a 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/ApiClient.java index afce13bf9fa..838ff0f11cc 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 4eece66820e..f1dc353af58 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index 09806e25e59..561f5e52190 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/extensions/x-auth-id-alias/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 3d6ba4c8e43..c6c83696217 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 @@ -19,18 +19,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java index ea922532747..730d6935f9c 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-special-characters/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 88345206919..24317dfe36a 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/ApiClient.java index 8c78e95457d..25a50c6bf66 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8-swagger1/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 88345206919..24317dfe36a 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /** diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java index ac4d6528e7a..76babaff4ac 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java @@ -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 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 variables = operationServerVariables.containsKey(operation) ? - operationServerVariables.get(operation) : serverVariables; - List serverConfigurations = operationServers.get(operation); + List serverConfigurations; + if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) { + int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue(); + Map 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 entry : cookieParams.entrySet()) { 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 88345206919..24317dfe36a 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 @@ -20,18 +20,18 @@ public class JSON implements ContextResolver { 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(); } /**