fix: 插件导入请求头等信息缺失

This commit is contained in:
chenjianxing 2020-07-23 11:54:35 +08:00
parent fffea1a1da
commit 0e53f0bdd2
1 changed files with 11 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.http.HttpMethod;
import java.io.InputStream;
import java.util.Map;
public class MsParser extends ApiImportAbstractParser {
@ -37,9 +38,17 @@ public class MsParser extends ApiImportAbstractParser {
JSONArray requestsObjects = new JSONArray();
JSONObject requestsObject = testObject.getJSONObject(scenarioName);
requestsObject.keySet().forEach(requestName -> {
JSONObject requestObject = requestsObject.getJSONObject(requestName);
requestObject.put("name", requestName);
JSONObject requestObject = new JSONObject(true);
JSONObject requestTmpObject = requestsObject.getJSONObject(requestName);
//排序确保type在第一个否则转换失败
if (StringUtils.isBlank(requestTmpObject.getString("type"))) {
requestObject.put("type", RequestType.HTTP);
}
requestTmpObject.keySet().forEach(key -> {
requestObject.put(key, requestTmpObject.get(key));
});;
requestObject.put("name", requestName);
JSONArray bodies = requestObject.getJSONArray("body");
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) {
StringBuilder bodyStr = new StringBuilder();