fix(接口测试): 修复swagger导入失败的缺陷
--bug=1026379 --user=王孝刚 [接口测试]github#24501接口定义-Swagger 导入报“解析数据出错” https://www.tapd.cn/55049933/s/1373638
This commit is contained in:
parent
6690ea2127
commit
7436b19964
|
@ -33,6 +33,7 @@ import io.swagger.v3.parser.core.models.AuthorizationValue;
|
|||
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -616,16 +617,18 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
Schema schema = getSchema(parameter.getSchema());
|
||||
Set<String> refSet = new HashSet<>();
|
||||
JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet);
|
||||
if (MapUtils.isEmpty(jsonSchemaItem.getProperties())) {
|
||||
arguments.add(new KeyValue(queryParameter.getName(), getDefaultValue(queryParameter, jsonSchemaItem), getDefaultStringValue(queryParameter.getDescription()), parameter.getRequired(), getMin(jsonSchemaItem), getMax(jsonSchemaItem)));
|
||||
} else {
|
||||
Map<String, JsonSchemaItem> properties = jsonSchemaItem.getProperties();
|
||||
properties.forEach((key, value) -> {
|
||||
arguments.add(new KeyValue(key, getDefaultValue(queryParameter, value),
|
||||
getDefaultStringValue(value.getDescription()),
|
||||
parameter.getRequired(),
|
||||
getMin(value), getMax(value)));
|
||||
});
|
||||
if (ObjectUtils.isNotEmpty(jsonSchemaItem)) {
|
||||
if (MapUtils.isEmpty(jsonSchemaItem.getProperties())) {
|
||||
arguments.add(new KeyValue(queryParameter.getName(), getDefaultValue(queryParameter, jsonSchemaItem), getDefaultStringValue(queryParameter.getDescription()), parameter.getRequired(), getMin(jsonSchemaItem), getMax(jsonSchemaItem)));
|
||||
} else {
|
||||
Map<String, JsonSchemaItem> properties = jsonSchemaItem.getProperties();
|
||||
properties.forEach((key, value) -> {
|
||||
arguments.add(new KeyValue(key, getDefaultValue(queryParameter, value),
|
||||
getDefaultStringValue(value.getDescription()),
|
||||
parameter.getRequired(),
|
||||
getMin(value), getMax(value)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue