fix(接口测试): 修复接口定义导入导出问题

--bug=1044007 --user=王旭 【接口测试】接口定义-导出接口,再导入到其他项目,接口数据不一致 https://www.tapd.cn/55049933/s/1552359
This commit is contained in:
WangXu10 2024-07-23 14:28:05 +08:00 committed by 刘瑞斌
parent ab76f7768d
commit dee7e496d1
3 changed files with 6 additions and 7 deletions

View File

@ -9,7 +9,7 @@ public class SwaggerParams {
//对应 API 请求参数名
private String name;
//参数值
private String value;
private String example;
//参数类型可选值为 path,header,query
private String in;
private String description;

View File

@ -33,7 +33,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
response.setOpenapi("3.0.2");
//info
SwaggerInfo swaggerInfo = new SwaggerInfo();
swaggerInfo.setVersion("3.0");
swaggerInfo.setVersion("3.x");
swaggerInfo.setTitle("ms-" + project.getName());
swaggerInfo.setDescription(StringUtils.EMPTY);
swaggerInfo.setTermsOfService(StringUtils.EMPTY);
@ -107,7 +107,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
Hashtable<String, String> typeMap = new Hashtable<String, String>() {{
put("headers", "header");
put("rest", "path");
put("arguments", "query");
put("query", "query");
}};
Set<String> typeKeys = typeMap.keySet();
for (String type : typeKeys) {
@ -123,7 +123,7 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
swaggerParam.setDescription(param.optString("description"));
swaggerParam.setName(param.optString("key"));
swaggerParam.setEnable(param.optBoolean(PropertyConstant.ENABLE));
swaggerParam.setValue(param.optString("value"));
swaggerParam.setExample(param.optString("value"));
JSONObject schema = new JSONObject();
schema.put(PropertyConstant.TYPE, PropertyConstant.STRING);
swaggerParam.setSchema(JSONUtil.parseObjectNode(schema.toString()));
@ -164,11 +164,9 @@ public class Swagger3ExportParser implements ExportParser<ApiExportResponse> {
if (StringUtils.isNotBlank(responseJSONObject.optString("value"))) {
statusCodeInfo.put("description", responseJSONObject.optString("value"));
}
if (StringUtils.isNotBlank(responseJSONObject.optString("name"))) {
responseBody.put(statusCode, statusCodeInfo);
}
}
}
return responseBody;
}

View File

@ -257,6 +257,7 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
body.setBodyType(Body.BodyType.NONE.name());
}
httpResponse.setBody(body);
httpResponse.setId(IDGenerator.nextStr());
response.add(httpResponse);
});
// 判断 如果是200 默认defaultFlag为true 否则的话 随机挑一个为true