diff --git a/.github/ISSUE_TEMPLATE/bug---.md b/.github/ISSUE_TEMPLATE/bug.md similarity index 90% rename from .github/ISSUE_TEMPLATE/bug---.md rename to .github/ISSUE_TEMPLATE/bug.md index 25dd8e93b8..651ca6f6fb 100644 --- a/.github/ISSUE_TEMPLATE/bug---.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,9 +1,9 @@ --- -name: Bug 提交 +name: BUG 提交 about: 提交产品缺陷帮助我们更好的改进 title: "[BUG]" labels: bug -assignees: '' +assignees: AgAngle --- diff --git a/.github/ISSUE_TEMPLATE/----.md b/.github/ISSUE_TEMPLATE/feature.md similarity index 82% rename from .github/ISSUE_TEMPLATE/----.md rename to .github/ISSUE_TEMPLATE/feature.md index 4c3f7c6133..45b67d7fe3 100644 --- a/.github/ISSUE_TEMPLATE/----.md +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -11,4 +11,4 @@ assignees: '' -**请描述你建议的实现方案** +**请描述你建议的实现方案** \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index a081dc73f4..d69e3f7f52 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -3,9 +3,8 @@ name: 问题咨询 about: 提出针对本项目安装部署、使用及其他方面的相关问题 title: "[QUESTION]" labels: question -assignees: 'wangzhen-fit2cloud' +assignees: wangzhen-fit2cloud --- **请描述您的问题.** - diff --git a/.github/ISSUE_TEMPLATE/v1.6.1-issue.md b/.github/ISSUE_TEMPLATE/v1.6.1-issue.md new file mode 100644 index 0000000000..4d25616e97 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/v1.6.1-issue.md @@ -0,0 +1,14 @@ +--- +name: v1.6.1 问题 +about: 提交关于 v1.6.1 的缺陷与建议,赢取Lv同款鼠标垫!马克杯!文化衫! +title: "[v1.6.1]" +labels: v1.6.1 +assignees: luty2018 + +--- + +**问题/需求描述** +简要描述您碰到的问题或您面临的需求 + +**截图** +如果有截图,请附上截图. diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index f455ffdc38..bad86b0985 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -4,12 +4,7 @@ on: push: branches: - master - - v1* - pull_request: - branches: - - master - - v1* - + - v1* workflow_dispatch: jobs: diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java b/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java index 328517e501..06317a0745 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java @@ -40,6 +40,15 @@ public class KeyValue { this.required = true; } + public KeyValue(String name, String value, String description, String contentType, boolean required) { + this.name = name; + this.value = value; + this.description = description; + this.contentType = contentType; + this.enable = true; + this.required = required; + } + public boolean isValid() { return (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file"); } diff --git a/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java b/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java index c3b33ae0c8..1d0366f428 100644 --- a/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/ApiImportAbstractParser.java @@ -142,10 +142,10 @@ public abstract class ApiImportAbstractParser implements ApiImportParser { } protected void addCookie(List headers, String key, String value) { - addCookie(headers, key, value, ""); + addCookie(headers, key, value, "", "", true); } - protected void addCookie(List headers, String key, String value, String description) { + protected void addCookie(List headers, String key, String value, String description, String contentType, boolean required) { boolean hasCookie = false; for (KeyValue header : headers) { if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) { @@ -155,15 +155,15 @@ public abstract class ApiImportAbstractParser implements ApiImportParser { } } if (!hasCookie) { - addHeader(headers, "Cookie", key + "=" + value + ";", description); + addHeader(headers, "Cookie", key + "=" + value + ";", description, "", required); } } protected void addHeader(List headers, String key, String value) { - addHeader(headers, key, value, ""); + addHeader(headers, key, value, "", "", true); } - protected void addHeader(List headers, String key, String value, String description) { + protected void addHeader(List headers, String key, String value, String description, String contentType, boolean required) { boolean hasContentType = false; for (KeyValue header : headers) { if (StringUtils.equalsIgnoreCase(header.getName(), key)) { @@ -171,7 +171,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser { } } if (!hasContentType) { - headers.add(new KeyValue(key, value, description)); + headers.add(new KeyValue(key, value, description, contentType, required)); } } } diff --git a/backend/src/main/java/io/metersphere/api/parse/MsParser.java b/backend/src/main/java/io/metersphere/api/parse/MsParser.java index 5e768adbba..512965d760 100644 --- a/backend/src/main/java/io/metersphere/api/parse/MsParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/MsParser.java @@ -41,7 +41,9 @@ public class MsParser extends ApiImportAbstractParser { List data = apiDefinitionImport.getData(); data.forEach(apiDefinition -> { String id = UUID.randomUUID().toString(); -// apiDefinition.setModuleId(null); + if (StringUtils.isBlank(apiDefinition.getModulePath())) { + apiDefinition.setModuleId(null); + } parseModule(apiDefinition, importRequest.isSaved()); apiDefinition.setId(id); apiDefinition.setProjectId(this.projectId); diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java index 2a04cd5898..61d15ed5ce 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java @@ -166,12 +166,14 @@ public class Swagger2Parser extends ApiImportAbstractParser { private void parseCookieParameters(Parameter parameter, List headers) { CookieParameter cookieParameter = (CookieParameter) parameter; - addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription())); + addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()), + "", parameter.getRequired()); } private void parseHeaderParameters(Parameter parameter, List headers) { HeaderParameter headerParameter = (HeaderParameter) parameter; - addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription())); + addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()), + "", parameter.getRequired()); } private HttpResponse parseResponse(Map responses) { @@ -299,7 +301,8 @@ public class Swagger2Parser extends ApiImportAbstractParser { private void parseFormDataParameters(FormParameter parameter, Body body) { List keyValues = Optional.ofNullable(body.getKvs()).orElse(new ArrayList<>()); - KeyValue kv = new KeyValue(parameter.getName(), "", getDefaultStringValue(parameter.getDescription())); + KeyValue kv = new KeyValue(parameter.getName(), "", getDefaultStringValue(parameter.getDescription()), + "", parameter.getRequired()); if (StringUtils.equals(parameter.getType(), "file")) { kv.setType("file"); } @@ -309,6 +312,7 @@ public class Swagger2Parser extends ApiImportAbstractParser { private void parseQueryParameters(Parameter parameter, List arguments) { QueryParameter queryParameter = (QueryParameter) parameter; - arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()))); + arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()), + "", queryParameter.getRequired())); } } diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java index 135c6f7a28..994eb55346 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java @@ -51,7 +51,7 @@ public class Swagger3Parser extends ApiImportAbstractParser { public ApiDefinitionImport parse(String sourceStr, ApiTestImportRequest request) { SwaggerParseResult result; if (StringUtils.isNotBlank(request.getSwaggerUrl())) { - result = new OpenAPIParser().readLocation("https://petstore3.swagger.io/api/v3/openapi.json", null, null); + result = new OpenAPIParser().readLocation(request.getSwaggerUrl(), null, null); } else { result = new OpenAPIParser().readContents(sourceStr, null, null); } @@ -179,12 +179,12 @@ public class Swagger3Parser extends ApiImportAbstractParser { private void parseCookieParameters(Parameter parameter, List headers) { CookieParameter cookieParameter = (CookieParameter) parameter; - addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription())); + addCookie(headers, cookieParameter.getName(), "", getDefaultStringValue(cookieParameter.getDescription()), "", true); } private void parseHeaderParameters(Parameter parameter, List headers) { HeaderParameter headerParameter = (HeaderParameter) parameter; - addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription())); + addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()), "", true); } private HttpResponse parseResponse(ApiResponses responses) { @@ -317,6 +317,9 @@ public class Swagger3Parser extends ApiImportAbstractParser { private Object parseSchema(Schema schema, Set refSet, Map binaryKeyMap) { if (StringUtils.isNotBlank(schema.get$ref())) { + if (refSet.contains(schema.get$ref())) { + return new JSONObject(); + } refSet.add(schema.get$ref()); Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap); return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;