fix(接口测试): 修改swagger2文件导入媒体类型部分数据缺失问题

--bug=1023905 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001023905
This commit is contained in:
guoyuqi 2023-03-01 13:55:12 +08:00 committed by 刘瑞斌
parent 30f6a521ec
commit 1f7b1344c0
1 changed files with 10 additions and 0 deletions

View File

@ -420,6 +420,16 @@ public class Swagger2Parser extends SwaggerAbstractParser {
if (body.getType().equals(Body.JSON_STR)) { if (body.getType().equals(Body.JSON_STR)) {
body.setJsonSchema(parseSchema2JsonSchema(bodyParameter.getSchema())); body.setJsonSchema(parseSchema2JsonSchema(bodyParameter.getSchema()));
body.setFormat("JSON-SCHEMA"); body.setFormat("JSON-SCHEMA");
} else if (body.getType().equals(Body.WWW_FROM) || body.getType().equals(Body.FORM_DATA)) {
String parameterStr = parseSchema(bodyParameter.getSchema());
JSONObject jsonObject = JSONUtil.parseObject(parameterStr);
Set<String> strings = jsonObject.keySet();
List<KeyValue> kvs = new ArrayList<>();
for (String key : strings) {
KeyValue keyValue = new KeyValue(key, jsonObject.get(key).toString());
kvs.add(keyValue);
}
body.setKvs(kvs);
} else { } else {
body.setRaw(parseSchema(bodyParameter.getSchema())); body.setRaw(parseSchema(bodyParameter.getSchema()));
} }