fix(接口测试): json-schema预览没有过滤参数名为空的字段

--bug=1044010 --user=陈建星 【接口测试】场景详情-自定义请求-请求体json-schema格式-空子字段行也生成了数据 https://www.tapd.cn/55049933/s/1548958
This commit is contained in:
AgAngle 2024-07-16 14:39:39 +08:00 committed by 刘瑞斌
parent d516ffa1f1
commit 0f0fe1ebae
2 changed files with 2 additions and 2 deletions

View File

@ -1214,7 +1214,7 @@ public class ApiDefinitionService extends MoveNodeService {
if (item == null) {
continue;
}
if (BooleanUtils.isFalse(item.getEnable())) {
if (BooleanUtils.isFalse(item.getEnable()) || StringUtils.isBlank(key)) {
iterator.remove();
} else if (isObjectItem(jsonSchemaItem) || isArrayItem(jsonSchemaItem)) {
filterDisableItem(item);

View File

@ -1729,7 +1729,7 @@ public class ApiDefinitionControllerTests extends BaseTest {
// 校验转换是否正确
String schema = """
{"type":"object","enable":true,"properties":{"array":{"type":"array","enable":true,"items":[{"type":"string","example":"1","enable":true},{"type":"number","example":"2","enable":true}]},"string":{"type":"string","example":"stringValue","enable":true},"int":{"type":"integer","example":"1","enable":true},"num":{"type":"number","example":"1.00","enable":true},"boolean":{"type":"boolean","example":"booleanValue","enable":true},"null":{"type":"null","enable":true}}}
{"type":"object","enable":true,"properties":{"array":{"type":"array","enable":true,"items":[{"type":"string","example":"1","enable":true},{"type":"number","example":"2","enable":true}]},"string":{"type":"string","example":"stringValue","enable":true},"int":{"type":"integer","example":"1","enable":true},"num":{"type":"number","example":"1.00","enable":true},"boolean":{"type":"boolean","example":"booleanValue","enable":true},"null":{"type":"null","enable":true},"":{"type":"string","enable":true}}}
""";
String jsonResult = """
{