Merge branch 'master' into v1.6

This commit is contained in:
BugKing 2020-12-31 13:39:02 +08:00
commit d191dd36bd
10 changed files with 51 additions and 25 deletions

View File

@ -1,9 +1,9 @@
---
name: Bug 提交
name: BUG 提交
about: 提交产品缺陷帮助我们更好的改进
title: "[BUG]"
labels: bug
assignees: ''
assignees: AgAngle
---

View File

@ -11,4 +11,4 @@ assignees: ''
**请描述你建议的实现方案**
**请描述你建议的实现方案**

View File

@ -3,9 +3,8 @@ name: 问题咨询
about: 提出针对本项目安装部署、使用及其他方面的相关问题
title: "[QUESTION]"
labels: question
assignees: 'wangzhen-fit2cloud'
assignees: wangzhen-fit2cloud
---
**请描述您的问题.**

14
.github/ISSUE_TEMPLATE/v1.6.1-issue.md vendored Normal file
View File

@ -0,0 +1,14 @@
---
name: v1.6.1 问题
about: 提交关于 v1.6.1 的缺陷与建议赢取Lv同款鼠标垫马克杯文化衫
title: "[v1.6.1]"
labels: v1.6.1
assignees: luty2018
---
**问题/需求描述**
简要描述您碰到的问题或您面临的需求
**截图**
如果有截图,请附上截图.

View File

@ -4,12 +4,7 @@ on:
push:
branches:
- master
- v1*
pull_request:
branches:
- master
- v1*
- v1*
workflow_dispatch:
jobs:

View File

@ -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");
}

View File

@ -142,10 +142,10 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
}
protected void addCookie(List<KeyValue> headers, String key, String value) {
addCookie(headers, key, value, "");
addCookie(headers, key, value, "", "", true);
}
protected void addCookie(List<KeyValue> headers, String key, String value, String description) {
protected void addCookie(List<KeyValue> 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<KeyValue> headers, String key, String value) {
addHeader(headers, key, value, "");
addHeader(headers, key, value, "", "", true);
}
protected void addHeader(List<KeyValue> headers, String key, String value, String description) {
protected void addHeader(List<KeyValue> 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));
}
}
}

View File

@ -41,7 +41,9 @@ public class MsParser extends ApiImportAbstractParser {
List<ApiDefinitionResult> 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);

View File

@ -166,12 +166,14 @@ public class Swagger2Parser extends ApiImportAbstractParser {
private void parseCookieParameters(Parameter parameter, List<KeyValue> 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<KeyValue> 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<String, Response> responses) {
@ -299,7 +301,8 @@ public class Swagger2Parser extends ApiImportAbstractParser {
private void parseFormDataParameters(FormParameter parameter, Body body) {
List<KeyValue> 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<KeyValue> 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()));
}
}

View File

@ -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<KeyValue> 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<KeyValue> 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<String> refSet, Map<String, String> 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;