diff --git a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java index 1df3fdd599..e6bea97061 100644 --- a/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java +++ b/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/ObjectMapperFactory.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; public class ObjectMapperFactory { public static ObjectMapper createJson() { @@ -28,6 +29,7 @@ protected static ObjectMapper createYaml(boolean includePathDeserializer, boolea private static ObjectMapper create(JsonFactory jsonFactory, boolean includePathDeserializer, boolean includeResponseDeserializer) { ObjectMapper mapper = new ObjectMapper(jsonFactory); + mapper.registerModule(new JavaTimeModule()); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java new file mode 100644 index 0000000000..f16d46c776 --- /dev/null +++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/ObjectMapperTest.java @@ -0,0 +1,15 @@ +package io.swagger.v3.parser; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.junit.Assert; +import org.junit.Test; + +public class ObjectMapperTest { + @Test + public void testJavaTimeModule() { + ObjectMapper mapper = ObjectMapperFactory.createJson(); + Assert.assertTrue("JavaTimeModule found?", + mapper.getRegisteredModuleIds().contains(new JavaTimeModule().getTypeId())); + } +}