fix: 插件导入请求头等信息缺失
This commit is contained in:
parent
fffea1a1da
commit
0e53f0bdd2
|
@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.jetty.http.HttpMethod;
|
import org.eclipse.jetty.http.HttpMethod;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class MsParser extends ApiImportAbstractParser {
|
public class MsParser extends ApiImportAbstractParser {
|
||||||
|
|
||||||
|
@ -37,9 +38,17 @@ public class MsParser extends ApiImportAbstractParser {
|
||||||
JSONArray requestsObjects = new JSONArray();
|
JSONArray requestsObjects = new JSONArray();
|
||||||
JSONObject requestsObject = testObject.getJSONObject(scenarioName);
|
JSONObject requestsObject = testObject.getJSONObject(scenarioName);
|
||||||
requestsObject.keySet().forEach(requestName -> {
|
requestsObject.keySet().forEach(requestName -> {
|
||||||
JSONObject requestObject = requestsObject.getJSONObject(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);
|
requestObject.put("name", requestName);
|
||||||
requestObject.put("type", RequestType.HTTP);
|
|
||||||
JSONArray bodies = requestObject.getJSONArray("body");
|
JSONArray bodies = requestObject.getJSONArray("body");
|
||||||
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) {
|
if (StringUtils.equalsIgnoreCase(requestObject.getString("method"), HttpMethod.POST.name()) && bodies != null) {
|
||||||
StringBuilder bodyStr = new StringBuilder();
|
StringBuilder bodyStr = new StringBuilder();
|
||||||
|
|
Loading…
Reference in New Issue