fix(接口定义): 修复 boolean类型使用json-schema会导致对应boolean类型转换为string

--bug=1007685 --user=赵勇 【github#7448】如果json里面存在boolean类型使用json-schema会导致对应boolean类型转换为string https://www.tapd.cn/55049933/s/1063706
This commit is contained in:
fit2-zhao 2021-11-03 16:16:56 +08:00 committed by fit2-zhao
parent b05b1a5dd3
commit 63f083f9cf
1 changed files with 10 additions and 1 deletions

View File

@ -155,7 +155,16 @@ public class JSONSchemaGenerator {
}
if (object.has("mock") && object.get("mock").getAsJsonObject() != null && StringUtils.isNotEmpty(object.get("mock").getAsJsonObject().get("mock").getAsString())) {
String value = ScriptEngineUtils.buildFunctionCallString(object.get("mock").getAsJsonObject().get("mock").toString());
concept.put(propertyName, value);
try {
if (StringUtils.isNotEmpty(value)) {
if (value.indexOf("\"") != -1) {
value = value.replaceAll("\"", "");
}
concept.put(propertyName, Boolean.valueOf(value));
}
} catch (Exception e) {
concept.put(propertyName, value);
}
}
} else if (propertyObjType.equals("array")) {
// 先设置空值