fix(接口测试): 修复swagger导入时间类型转换格式问题

--bug=1027227 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001027227
This commit is contained in:
guoyuqi 2023-06-27 19:02:21 +08:00 committed by fit2-zhao
parent 3d6e6c0b52
commit 48d40971c4
3 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
@ -52,6 +53,8 @@ public class JSONUtil {
// 设置JSON处理字符长度限制
objectMapper.getFactory()
.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(JSON.DEFAULT_MAX_STRING_LEN).build());
// 处理时间格式
objectMapper.registerModule(new JavaTimeModule());
}

View File

@ -299,6 +299,12 @@
<artifactId>commons-dbcp2</artifactId>
<version>${commons-dbcp2-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.15.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.io.IOException;
import java.io.InputStream;
@ -31,6 +33,8 @@ public class JsonUtils {
// 设置JSON处理字符长度限制
objectMapper.getFactory()
.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
// 处理时间格式
objectMapper.registerModule(new JavaTimeModule());
}