fix(接口测试): 修复接口测试导出swagger3文件响应体内容格式错误问题
--bug=1020795 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001020795
This commit is contained in:
parent
0b3cf2a746
commit
07d3deba71
|
@ -346,7 +346,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet);
|
JsonSchemaItem jsonSchemaItem = parseSchema(schema, refSet);
|
||||||
if (jsonSchemaItem==null){
|
if (jsonSchemaItem==null){
|
||||||
jsonSchemaItem = new JsonSchemaItem();
|
jsonSchemaItem = new JsonSchemaItem();
|
||||||
if (StringUtils.isNotBlank(schema.getType())) {
|
if (schema != null && StringUtils.isNotBlank(schema.getType())) {
|
||||||
jsonSchemaItem.setType(schema.getType());
|
jsonSchemaItem.setType(schema.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Schema getSchema(Schema schema) {
|
private Schema getSchema(Schema schema) {
|
||||||
if (StringUtils.isBlank(schema.get$ref()) && StringUtils.equalsIgnoreCase(schema.getType(),"string")) {
|
if (schema != null && StringUtils.isBlank(schema.get$ref()) && StringUtils.equalsIgnoreCase(schema.getType(), "string")) {
|
||||||
ObjectSchema objectSchema = new ObjectSchema();
|
ObjectSchema objectSchema = new ObjectSchema();
|
||||||
objectSchema.setExample(schema.getExample());
|
objectSchema.setExample(schema.getExample());
|
||||||
schema = objectSchema;
|
schema = objectSchema;
|
||||||
|
@ -988,7 +988,12 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
statusCodeInfo.put("description", "");
|
statusCodeInfo.put("description", "");
|
||||||
// 返回code
|
// 返回code
|
||||||
JSONArray statusCode = response.getJSONArray("statusCode");
|
JSONArray statusCode = response.getJSONArray("statusCode");
|
||||||
responseBody.put(JSON.toJSONString(statusCode), statusCodeInfo);
|
for (int i = 0; i < statusCode.size(); i++) {
|
||||||
|
JSONObject jsonObject = statusCode.getJSONObject(i);
|
||||||
|
jsonObject.get("name");
|
||||||
|
statusCodeInfo.put("description", jsonObject.get("value"));
|
||||||
|
responseBody.put(jsonObject.get("name").toString(), statusCodeInfo);
|
||||||
|
}
|
||||||
return responseBody;
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue