fix(接口测试): 修复接口定义导入导出问题
--bug=1044007 --user=王旭 【接口测试】接口定义-导出接口,再导入到其他项目,接口数据不一致 https://www.tapd.cn/55049933/s/1552359
This commit is contained in:
parent
ab76f7768d
commit
dee7e496d1
|
@ -9,7 +9,7 @@ public class SwaggerParams {
|
||||||
//对应 API 请求参数名
|
//对应 API 请求参数名
|
||||||
private String name;
|
private String name;
|
||||||
//参数值
|
//参数值
|
||||||
private String value;
|
private String example;
|
||||||
//参数类型,可选值为 path,header,query 等
|
//参数类型,可选值为 path,header,query 等
|
||||||
private String in;
|
private String in;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
|
||||||
response.setOpenapi("3.0.2");
|
response.setOpenapi("3.0.2");
|
||||||
//info
|
//info
|
||||||
SwaggerInfo swaggerInfo = new SwaggerInfo();
|
SwaggerInfo swaggerInfo = new SwaggerInfo();
|
||||||
swaggerInfo.setVersion("3.0");
|
swaggerInfo.setVersion("3.x");
|
||||||
swaggerInfo.setTitle("ms-" + project.getName());
|
swaggerInfo.setTitle("ms-" + project.getName());
|
||||||
swaggerInfo.setDescription(StringUtils.EMPTY);
|
swaggerInfo.setDescription(StringUtils.EMPTY);
|
||||||
swaggerInfo.setTermsOfService(StringUtils.EMPTY);
|
swaggerInfo.setTermsOfService(StringUtils.EMPTY);
|
||||||
|
@ -107,7 +107,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
|
||||||
Hashtable<String, String> typeMap = new Hashtable<String, String>() {{
|
Hashtable<String, String> typeMap = new Hashtable<String, String>() {{
|
||||||
put("headers", "header");
|
put("headers", "header");
|
||||||
put("rest", "path");
|
put("rest", "path");
|
||||||
put("arguments", "query");
|
put("query", "query");
|
||||||
}};
|
}};
|
||||||
Set<String> typeKeys = typeMap.keySet();
|
Set<String> typeKeys = typeMap.keySet();
|
||||||
for (String type : typeKeys) {
|
for (String type : typeKeys) {
|
||||||
|
@ -123,7 +123,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
|
||||||
swaggerParam.setDescription(param.optString("description"));
|
swaggerParam.setDescription(param.optString("description"));
|
||||||
swaggerParam.setName(param.optString("key"));
|
swaggerParam.setName(param.optString("key"));
|
||||||
swaggerParam.setEnable(param.optBoolean(PropertyConstant.ENABLE));
|
swaggerParam.setEnable(param.optBoolean(PropertyConstant.ENABLE));
|
||||||
swaggerParam.setValue(param.optString("value"));
|
swaggerParam.setExample(param.optString("value"));
|
||||||
JSONObject schema = new JSONObject();
|
JSONObject schema = new JSONObject();
|
||||||
schema.put(PropertyConstant.TYPE, PropertyConstant.STRING);
|
schema.put(PropertyConstant.TYPE, PropertyConstant.STRING);
|
||||||
swaggerParam.setSchema(JSONUtil.parseObjectNode(schema.toString()));
|
swaggerParam.setSchema(JSONUtil.parseObjectNode(schema.toString()));
|
||||||
|
@ -164,11 +164,9 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
|
||||||
if (StringUtils.isNotBlank(responseJSONObject.optString("value"))) {
|
if (StringUtils.isNotBlank(responseJSONObject.optString("value"))) {
|
||||||
statusCodeInfo.put("description", responseJSONObject.optString("value"));
|
statusCodeInfo.put("description", responseJSONObject.optString("value"));
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(responseJSONObject.optString("name"))) {
|
|
||||||
responseBody.put(statusCode, statusCodeInfo);
|
responseBody.put(statusCode, statusCodeInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return responseBody;
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,7 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
|
||||||
body.setBodyType(Body.BodyType.NONE.name());
|
body.setBodyType(Body.BodyType.NONE.name());
|
||||||
}
|
}
|
||||||
httpResponse.setBody(body);
|
httpResponse.setBody(body);
|
||||||
|
httpResponse.setId(IDGenerator.nextStr());
|
||||||
response.add(httpResponse);
|
response.add(httpResponse);
|
||||||
});
|
});
|
||||||
// 判断 如果是200 默认defaultFlag为true 否则的话 随机挑一个为true
|
// 判断 如果是200 默认defaultFlag为true 否则的话 随机挑一个为true
|
||||||
|
|
Loading…
Reference in New Issue