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

--user=郭雨琦
--bug=1012085
【接口测试】swagger
导入导出问题
https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001012085

Co-authored-by: guoyuqi <xiaomeinvG@126.com>
This commit is contained in:
MeterSphere Bot 2022-04-12 18:18:29 +08:00 committed by GitHub
parent c844632d7d
commit 9f16302337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -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");
if (mock != null) {
Object mockValue = mock.get("mock");
property.put("example", mockValue);
}else{
} 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);