fix(接口测试): 修复v2版本数据无法导入的缺陷
--bug=1037505 --user=王孝刚 【接口测试】接口定义-导入接口-导入从MS导出的swagger 3.0 格式文件失败 https://www.tapd.cn/55049933/s/1478660
This commit is contained in:
parent
47e43aa847
commit
ae08ff2311
|
@ -166,6 +166,9 @@ public class Swagger3Parser<T> implements ImportParser<ApiDefinitionImport> {
|
|||
content.forEach((key, value) -> {
|
||||
setBodyData(key, value, body);
|
||||
});
|
||||
} else {
|
||||
body.setBodyType(Body.BodyType.NONE.name());
|
||||
body.setNoneBody(new NoneBody());
|
||||
}
|
||||
} else {
|
||||
body.setBodyType(Body.BodyType.NONE.name());
|
||||
|
@ -175,6 +178,10 @@ public class Swagger3Parser<T> implements ImportParser<ApiDefinitionImport> {
|
|||
|
||||
private void parseWWWFormBody(JsonSchemaItem item, Body body) {
|
||||
WWWFormBody wwwFormBody = new WWWFormBody();
|
||||
if (item == null) {
|
||||
body.setWwwFormBody(wwwFormBody);
|
||||
return;
|
||||
}
|
||||
List<String> required = item.getRequired();
|
||||
List<WWWFormKV> formDataKVS = new ArrayList<>();
|
||||
item.getProperties().forEach((key, value) -> {
|
||||
|
@ -738,7 +745,7 @@ public class Swagger3Parser<T> implements ImportParser<ApiDefinitionImport> {
|
|||
private String formatPath(String url) {
|
||||
try {
|
||||
URI urlObject = new URI(url);
|
||||
String path = StringUtils.isBlank(urlObject.getPath()) ? "/" : urlObject.getPath();
|
||||
String path = StringUtils.isBlank(urlObject.getPath()) ? url : urlObject.getPath();
|
||||
StringBuilder pathBuffer = new StringBuilder(path);
|
||||
if (StringUtils.isNotEmpty(urlObject.getQuery())) {
|
||||
pathBuffer.append("?").append(urlObject.getQuery());
|
||||
|
|
|
@ -60,6 +60,9 @@ public class JsonSchemaBuilder {
|
|||
private static JsonNode generateJson(JsonNode jsonSchemaNode, Map<String, String> processMap) {
|
||||
ObjectNode jsonNode = objectMapper.createObjectNode();
|
||||
|
||||
if (jsonSchemaNode instanceof NullNode) {
|
||||
return NullNode.getInstance();
|
||||
}
|
||||
String type = jsonSchemaNode.get(PropertyConstant.TYPE).asText();
|
||||
if (StringUtils.equals(type, PropertyConstant.OBJECT)) {
|
||||
JsonNode propertiesNode = jsonSchemaNode.get(PropertyConstant.PROPERTIES);
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
function getCustomFunction() {
|
||||
emit('insertCommonScript');
|
||||
}
|
||||
|
||||
// 从Api定义导入
|
||||
function getApiExport() {
|
||||
emit('formApiImport');
|
||||
|
@ -108,16 +109,6 @@
|
|||
headers.set('Content-type', 'application/json');
|
||||
return getCodeTemplate(innerLanguageType.value, { requestHeaders: headers });
|
||||
}
|
||||
case 'api_stop': {
|
||||
if (innerLanguageType.value === LanguageEnum.PYTHON) {
|
||||
return `
|
||||
import java
|
||||
StandardJMeterEngine = java.type('org.apache.jmeter.engine.StandardJMeterEngine')
|
||||
StandardJMeterEngine.stopThreadNow(ctx.getThread().getThreadName())
|
||||
`;
|
||||
}
|
||||
return 'ctx.getEngine().stopThreadNow(ctx.getThread().getThreadName());';
|
||||
}
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ export const SCRIPT_MENU: CommonScriptMenu[] = [
|
|||
},
|
||||
{
|
||||
title: t('project.processor.terminationTest'),
|
||||
value: 'api_stop',
|
||||
command: 'api_stop',
|
||||
value: 'ctx.getEngine().stopTest();',
|
||||
},
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue