fix(接口测试): swagger2.0导入错误

--user=郭雨琦
--bug=1012085
【接口测试】swagger
导入导出问题
https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001012085
This commit is contained in:
guoyuqi 2022-04-12 15:57:47 +08:00 committed by 刘瑞斌
parent 0cfcdfdf73
commit edf6458054
2 changed files with 13 additions and 5 deletions

View File

@ -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");

View File

@ -831,13 +831,21 @@ public class Swagger3Parser extends SwaggerAbstractParser {
String value = obj.getString("value");
if (StringUtils.isBlank(value)) {
JSONObject mock = obj.getJSONObject("mock");
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);