Skip to content

Commit c6c287b

Browse files
committed
Fixes
1 parent 3b54379 commit c6c287b

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/ApiClient.mustache

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ import tools.jackson.databind.json.JsonMapper;
1616
{{/useJackson3}}
1717
import java.time.OffsetDateTime;
1818
import {{jacksonPackage}}.core.type.TypeReference;
19-
import {{jacksonPackage}}.core.JsonProcessingException;
19+
{{^useJackson3}}
20+
import com.fasterxml.jackson.core.JsonProcessingException;
21+
{{/useJackson3}}
22+
{{#useJackson3}}
23+
import tools.jackson.core.JacksonException;
24+
{{/useJackson3}}
2025
{{#openApiNullable}}
2126
{{^useJackson3}}
2227
import org.openapitools.jackson.nullable.JsonNullableModule;
@@ -576,7 +581,16 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
576581
public ApiClient setDateFormat(DateFormat dateFormat) {
577582
this.dateFormat = dateFormat;
578583
// Also set the date format for model (de)serialization with Date properties.
584+
{{^useJackson3}}
579585
this.objectMapper.setDateFormat((DateFormat) dateFormat.clone());
586+
{{/useJackson3}}
587+
{{#useJackson3}}
588+
if (this.objectMapper instanceof JsonMapper) {
589+
this.objectMapper = ((JsonMapper) this.objectMapper).rebuild().defaultDateFormat((DateFormat) dateFormat.clone()).build();
590+
} else {
591+
throw new UnsupportedOperationException("setDateFormat is only supported when objectMapper is a JsonMapper instance");
592+
}
593+
{{/useJackson3}}
580594
return this;
581595
}
582596

@@ -826,7 +840,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
826840
if (isJsonMime(mimeType)) {
827841
try {
828842
return new StringEntity(objectMapper.writeValueAsString(obj), contentType.withCharset(StandardCharsets.UTF_8));
829-
} catch (JsonProcessingException e) {
843+
} catch ({{^useJackson3}}JsonProcessingException{{/useJackson3}}{{#useJackson3}}JacksonException{{/useJackson3}} e) {
830844
throw new ApiException(e);
831845
}
832846
} else if (mimeType.equals(ContentType.MULTIPART_FORM_DATA.getMimeType())) {

modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/build.gradle.mustache

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ext {
138138
jakarta_annotation_version = "1.3.5"
139139
httpclient_version = "5.1.3"
140140
jodatime_version = "2.9.9"
141-
junit_version = "4.13.2"
141+
junit_version = "5.10.2"
142142
}
143143

144144
dependencies {
@@ -171,5 +171,10 @@ dependencies {
171171
{{/joda}}
172172
{{/useJackson3}}
173173
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
174-
testImplementation "junit:junit:$junit_version"
174+
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
175+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
176+
}
177+
178+
test {
179+
useJUnitPlatform()
175180
}

0 commit comments

Comments
 (0)