@@ -13,9 +13,11 @@ import org.openapitools.jackson.nullable.JsonNullableModule;
1313{ {/useJackson3} }
1414{ {#useJackson3} }
1515import com.fasterxml.jackson.annotation.JsonInclude;
16+ import tools.jackson.databind.cfg.DateTimeFeature;
17+ import tools.jackson.databind.cfg.EnumFeature;
1618import tools.jackson.databind.DeserializationFeature;
1719import tools.jackson.databind.ObjectMapper;
18- import tools.jackson.databind.SerializationFeature ;
20+ import tools.jackson.databind.json.JsonMapper ;
1921{ {/useJackson3} }
2022
2123import java.io.InputStream;
@@ -213,6 +215,7 @@ public class ApiClient {
213215 }
214216
215217 public static ObjectMapper createDefaultObjectMapper() {
218+ {{^useJackson3} }
216219 ObjectMapper mapper = new ObjectMapper();
217220 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
218221 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -221,19 +224,25 @@ public class ApiClient {
221224 mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
222225 mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
223226 mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
224- {{^useJackson3} }
225227 mapper.registerModule(new JavaTimeModule());
226- { {/useJackson3} }
227- { {^useJackson3} }
228228 { {#openApiNullable} }
229229 mapper.registerModule(new JsonNullableModule());
230230 { {/openApiNullable} }
231- { {/useJackson3} }
232- { {#useJackson3} }
233- // FIXME: JsonNullableModule is not yet available for Jackson 3
234- { {/useJackson3} }
235231 mapper.registerModule(new RFC3339JavaTimeModule());
236232 return mapper;
233+ { {/useJackson3} }
234+ { {#useJackson3} }
235+ return JsonMapper.builder()
236+ .changeDefaultPropertyInclusion(v -> v.withValueInclusion(JsonInclude.Include.NON_NULL))
237+ .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
238+ .disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE)
239+ .disable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)
240+ .enable(EnumFeature.WRITE_ENUMS_USING_TO_STRING)
241+ .enable(EnumFeature.READ_ENUMS_USING_TO_STRING)
242+ .disable(DateTimeFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
243+ .addModule(new RFC3339JavaTimeModule())
244+ .build();
245+ { {/useJackson3} }
237246 }
238247
239248 protected final String getDefaultBaseUri() {
0 commit comments