fix(接口测试): 修复swagger导出json格式问题
--bug=1026582 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001026582
This commit is contained in:
parent
9b81ddf56b
commit
937532c093
|
@ -526,14 +526,18 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
Schema items = ((ArraySchema) schema).getItems();
|
||||
item.setType(PropertyConstant.ARRAY);
|
||||
JsonSchemaItem arrayItem = parseSchema(items, refSet);
|
||||
Map<String, String> mock = new LinkedHashMap<>();
|
||||
Map<String, Object> mock = new LinkedHashMap<>();
|
||||
if (arrayItem != null && MapUtils.isNotEmpty(arrayItem.getProperties())) {
|
||||
arrayItem.getProperties().forEach((k, v) -> {
|
||||
mock.put(k, StringUtils.isBlank(v.getMock().get(PropertyConstant.MOCK).toString()) ? v.getType() :
|
||||
v.getMock().get(PropertyConstant.MOCK).toString());
|
||||
});
|
||||
}
|
||||
if (item.getMock() != null) {
|
||||
item.getMock().put(PropertyConstant.MOCK, JSONUtil.toJSONString(mock));
|
||||
} else {
|
||||
item.setMock(mock);
|
||||
}
|
||||
if (arrayItem != null) {
|
||||
item.getItems().add(arrayItem);
|
||||
}
|
||||
|
@ -908,9 +912,11 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
public Object getJsonSchemaValue(JSONObject item) {
|
||||
JSONObject mock = item.optJSONObject(PropertyConstant.MOCK);
|
||||
if (mock != null) {
|
||||
if (StringUtils.isNotBlank(mock.optString("mock"))) {
|
||||
Object value = mock.get(PropertyConstant.MOCK);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1046,7 +1052,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
|||
String value = obj.optString("value");
|
||||
if (StringUtils.isBlank(value)) {
|
||||
JSONObject mock = obj.optJSONObject(PropertyConstant.MOCK);
|
||||
if (mock != null) {
|
||||
if (mock != null && StringUtils.isNotBlank(mock.optString("mock"))) {
|
||||
Object mockValue = mock.get(PropertyConstant.MOCK);
|
||||
property.put("example", mockValue);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue