diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java index 6c61c7f394..a42a2a761f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java @@ -166,6 +166,9 @@ public class Swagger3Parser implements ImportParser { 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 implements ImportParser { private void parseWWWFormBody(JsonSchemaItem item, Body body) { WWWFormBody wwwFormBody = new WWWFormBody(); + if (item == null) { + body.setWwwFormBody(wwwFormBody); + return; + } List required = item.getRequired(); List formDataKVS = new ArrayList<>(); item.getProperties().forEach((key, value) -> { @@ -738,7 +745,7 @@ public class Swagger3Parser implements ImportParser { 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()); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/utils/JsonSchemaBuilder.java b/backend/services/api-test/src/main/java/io/metersphere/api/utils/JsonSchemaBuilder.java index 7d3c877d78..620bf76a14 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/utils/JsonSchemaBuilder.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/utils/JsonSchemaBuilder.java @@ -60,6 +60,9 @@ public class JsonSchemaBuilder { private static JsonNode generateJson(JsonNode jsonSchemaNode, Map 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); diff --git a/frontend/src/components/business/ms-common-script/ms-script-menu.vue b/frontend/src/components/business/ms-common-script/ms-script-menu.vue index b484edc8a0..6b01b1693b 100644 --- a/frontend/src/components/business/ms-common-script/ms-script-menu.vue +++ b/frontend/src/components/business/ms-common-script/ms-script-menu.vue @@ -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 ''; } diff --git a/frontend/src/components/business/ms-common-script/utils.ts b/frontend/src/components/business/ms-common-script/utils.ts index d12abb1dc5..e23b09a4ce 100644 --- a/frontend/src/components/business/ms-common-script/utils.ts +++ b/frontend/src/components/business/ms-common-script/utils.ts @@ -49,8 +49,7 @@ export const SCRIPT_MENU: CommonScriptMenu[] = [ }, { title: t('project.processor.terminationTest'), - value: 'api_stop', - command: 'api_stop', + value: 'ctx.getEngine().stopTest();', }, ];