Merge branch 'master' into v1.6
This commit is contained in:
commit
d191dd36bd
|
@ -1,9 +1,9 @@
|
||||||
---
|
---
|
||||||
name: Bug 提交
|
name: BUG 提交
|
||||||
about: 提交产品缺陷帮助我们更好的改进
|
about: 提交产品缺陷帮助我们更好的改进
|
||||||
title: "[BUG]"
|
title: "[BUG]"
|
||||||
labels: bug
|
labels: bug
|
||||||
assignees: ''
|
assignees: AgAngle
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -3,9 +3,8 @@ name: 问题咨询
|
||||||
about: 提出针对本项目安装部署、使用及其他方面的相关问题
|
about: 提出针对本项目安装部署、使用及其他方面的相关问题
|
||||||
title: "[QUESTION]"
|
title: "[QUESTION]"
|
||||||
labels: question
|
labels: question
|
||||||
assignees: 'wangzhen-fit2cloud'
|
assignees: wangzhen-fit2cloud
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**请描述您的问题.**
|
**请描述您的问题.**
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
name: v1.6.1 问题
|
||||||
|
about: 提交关于 v1.6.1 的缺陷与建议,赢取Lv同款鼠标垫!马克杯!文化衫!
|
||||||
|
title: "[v1.6.1]"
|
||||||
|
labels: v1.6.1
|
||||||
|
assignees: luty2018
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**问题/需求描述**
|
||||||
|
简要描述您碰到的问题或您面临的需求
|
||||||
|
|
||||||
|
**截图**
|
||||||
|
如果有截图,请附上截图.
|
|
@ -5,11 +5,6 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- v1*
|
- v1*
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- v1*
|
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
|
@ -40,6 +40,15 @@ public class KeyValue {
|
||||||
this.required = true;
|
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() {
|
public boolean isValid() {
|
||||||
return (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file");
|
return (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file");
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,10 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addCookie(List<KeyValue> headers, String key, String value) {
|
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;
|
boolean hasCookie = false;
|
||||||
for (KeyValue header : headers) {
|
for (KeyValue header : headers) {
|
||||||
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
|
if (StringUtils.equalsIgnoreCase("Cookie", header.getName())) {
|
||||||
|
@ -155,15 +155,15 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasCookie) {
|
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) {
|
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;
|
boolean hasContentType = false;
|
||||||
for (KeyValue header : headers) {
|
for (KeyValue header : headers) {
|
||||||
if (StringUtils.equalsIgnoreCase(header.getName(), key)) {
|
if (StringUtils.equalsIgnoreCase(header.getName(), key)) {
|
||||||
|
@ -171,7 +171,7 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasContentType) {
|
if (!hasContentType) {
|
||||||
headers.add(new KeyValue(key, value, description));
|
headers.add(new KeyValue(key, value, description, contentType, required));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class MsParser extends ApiImportAbstractParser {
|
||||||
List<ApiDefinitionResult> data = apiDefinitionImport.getData();
|
List<ApiDefinitionResult> data = apiDefinitionImport.getData();
|
||||||
data.forEach(apiDefinition -> {
|
data.forEach(apiDefinition -> {
|
||||||
String id = UUID.randomUUID().toString();
|
String id = UUID.randomUUID().toString();
|
||||||
// apiDefinition.setModuleId(null);
|
if (StringUtils.isBlank(apiDefinition.getModulePath())) {
|
||||||
|
apiDefinition.setModuleId(null);
|
||||||
|
}
|
||||||
parseModule(apiDefinition, importRequest.isSaved());
|
parseModule(apiDefinition, importRequest.isSaved());
|
||||||
apiDefinition.setId(id);
|
apiDefinition.setId(id);
|
||||||
apiDefinition.setProjectId(this.projectId);
|
apiDefinition.setProjectId(this.projectId);
|
||||||
|
|
|
@ -166,12 +166,14 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
||||||
|
|
||||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
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) {
|
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
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) {
|
private HttpResponse parseResponse(Map<String, Response> responses) {
|
||||||
|
@ -299,7 +301,8 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
||||||
|
|
||||||
private void parseFormDataParameters(FormParameter parameter, Body body) {
|
private void parseFormDataParameters(FormParameter parameter, Body body) {
|
||||||
List<KeyValue> keyValues = Optional.ofNullable(body.getKvs()).orElse(new ArrayList<>());
|
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")) {
|
if (StringUtils.equals(parameter.getType(), "file")) {
|
||||||
kv.setType("file");
|
kv.setType("file");
|
||||||
}
|
}
|
||||||
|
@ -309,6 +312,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
||||||
|
|
||||||
private void parseQueryParameters(Parameter parameter, List<KeyValue> arguments) {
|
private void parseQueryParameters(Parameter parameter, List<KeyValue> arguments) {
|
||||||
QueryParameter queryParameter = (QueryParameter) parameter;
|
QueryParameter queryParameter = (QueryParameter) parameter;
|
||||||
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription())));
|
arguments.add(new KeyValue(queryParameter.getName(), "", getDefaultStringValue(queryParameter.getDescription()),
|
||||||
|
"", queryParameter.getRequired()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
||||||
public ApiDefinitionImport parse(String sourceStr, ApiTestImportRequest request) {
|
public ApiDefinitionImport parse(String sourceStr, ApiTestImportRequest request) {
|
||||||
SwaggerParseResult result;
|
SwaggerParseResult result;
|
||||||
if (StringUtils.isNotBlank(request.getSwaggerUrl())) {
|
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 {
|
} else {
|
||||||
result = new OpenAPIParser().readContents(sourceStr, null, null);
|
result = new OpenAPIParser().readContents(sourceStr, null, null);
|
||||||
}
|
}
|
||||||
|
@ -179,12 +179,12 @@ public class Swagger3Parser extends ApiImportAbstractParser {
|
||||||
|
|
||||||
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
private void parseCookieParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
CookieParameter cookieParameter = (CookieParameter) parameter;
|
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) {
|
private void parseHeaderParameters(Parameter parameter, List<KeyValue> headers) {
|
||||||
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
HeaderParameter headerParameter = (HeaderParameter) parameter;
|
||||||
addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()));
|
addHeader(headers, headerParameter.getName(), "", getDefaultStringValue(headerParameter.getDescription()), "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpResponse parseResponse(ApiResponses responses) {
|
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) {
|
private Object parseSchema(Schema schema, Set<String> refSet, Map<String, String> binaryKeyMap) {
|
||||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||||
|
if (refSet.contains(schema.get$ref())) {
|
||||||
|
return new JSONObject();
|
||||||
|
}
|
||||||
refSet.add(schema.get$ref());
|
refSet.add(schema.get$ref());
|
||||||
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap);
|
Object propertiesResult = parseSchemaProperties(getModelByRef(schema.get$ref()), refSet, binaryKeyMap);
|
||||||
return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;
|
return propertiesResult == null ? getDefaultValueByPropertyType(schema) : propertiesResult;
|
||||||
|
|
Loading…
Reference in New Issue