diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache index 8af468cfb4cf..43d97e14f196 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache @@ -87,29 +87,26 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { public ApiClient() { - this.dateFormat = createDefaultDateFormat(); - this.objectMapper = createDefaultObjectMapper(this.dateFormat); - this.restClient = buildRestClient(this.objectMapper); - this.init(); + this(null); } public ApiClient(RestClient restClient) { - this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat()); + this(restClient, createDefaultDateFormat()); } public ApiClient(ObjectMapper mapper, DateFormat format) { - this(buildRestClient(mapper.copy()), format); + this(null, mapper, format); } public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) { - this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format); + this.objectMapper = mapper.copy(); + this.restClient = Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(this.objectMapper)); + this.dateFormat = format; + this.init(); } private ApiClient(RestClient restClient, DateFormat format) { - this.restClient = restClient; - this.dateFormat = format; - this.objectMapper = createDefaultObjectMapper(format); - this.init(); + this(restClient, createDefaultObjectMapper(format), format); } public static DateFormat createDefaultDateFormat() {