mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-29 18:48:13 +08:00
fix(接口测试): swagger2.0导入错误
--user=郭雨琦 --bug=1012085 【接口测试】swagger 导入导出问题 https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001012085
This commit is contained in:
parent
0cfcdfdf73
commit
edf6458054
@ -483,7 +483,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||
private void handleBaseProperties(JsonSchemaItem item, Property value) {
|
||||
if (value instanceof StringProperty || value instanceof DateProperty || value instanceof DateTimeProperty ) {
|
||||
item.setType("string");
|
||||
} else if (value instanceof IntegerProperty) {
|
||||
} else if (value instanceof IntegerProperty || value instanceof BaseIntegerProperty) {
|
||||
item.setType("integer");
|
||||
} else if (value instanceof BooleanProperty) {
|
||||
item.setType("boolean");
|
||||
|
@ -829,15 +829,23 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||
JSONObject obj = ((JSONObject) kvs.get(key));
|
||||
property.put("type", StringUtils.isNotEmpty(obj.getString("type")) ? obj.getString("type") : "string");
|
||||
String value = obj.getString("value");
|
||||
if(StringUtils.isBlank(value)){
|
||||
if (StringUtils.isBlank(value)) {
|
||||
JSONObject mock = obj.getJSONObject("mock");
|
||||
Object mockValue = mock.get("mock");
|
||||
property.put("example", mockValue);
|
||||
}else{
|
||||
if (mock != null) {
|
||||
Object mockValue = mock.get("mock");
|
||||
property.put("example", mockValue);
|
||||
} else {
|
||||
property.put("example", value);
|
||||
}
|
||||
} else {
|
||||
property.put("example", value);
|
||||
}
|
||||
property.put("description", obj.getString("description"));
|
||||
property.put("required", obj.getString("required"));
|
||||
if (obj.getJSONObject("properties") != null) {
|
||||
JSONObject properties1 = buildFormDataSchema(obj.getJSONObject("properties"));
|
||||
property.put("properties",properties1.getJSONObject("properties"));
|
||||
}
|
||||
properties.put(key, property);
|
||||
}
|
||||
schema.put("properties", properties);
|
||||
|
Loading…
Reference in New Issue
Block a user