Skip to content

Commit

Permalink
add JavaTimeModule
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored and frantuma committed Feb 5, 2024
1 parent 7d6bad8 commit d380fbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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()));
}
}

0 comments on commit d380fbf

Please sign in to comment.