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:
parent
c844632d7d
commit
9f16302337
|
@ -483,7 +483,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
||||||
private void handleBaseProperties(JsonSchemaItem item, Property value) {
|
private void handleBaseProperties(JsonSchemaItem item, Property value) {
|
||||||
if (value instanceof StringProperty || value instanceof DateProperty || value instanceof DateTimeProperty ) {
|
if (value instanceof StringProperty || value instanceof DateProperty || value instanceof DateTimeProperty ) {
|
||||||
item.setType("string");
|
item.setType("string");
|
||||||
} else if (value instanceof IntegerProperty) {
|
} else if (value instanceof IntegerProperty || value instanceof BaseIntegerProperty) {
|
||||||
item.setType("integer");
|
item.setType("integer");
|
||||||
} else if (value instanceof BooleanProperty) {
|
} else if (value instanceof BooleanProperty) {
|
||||||
item.setType("boolean");
|
item.setType("boolean");
|
||||||
|
|
|
@ -829,15 +829,23 @@ public class Swagger3Parser extends SwaggerAbstractParser {
|
||||||
JSONObject obj = ((JSONObject) kvs.get(key));
|
JSONObject obj = ((JSONObject) kvs.get(key));
|
||||||
property.put("type", StringUtils.isNotEmpty(obj.getString("type")) ? obj.getString("type") : "string");
|
property.put("type", StringUtils.isNotEmpty(obj.getString("type")) ? obj.getString("type") : "string");
|
||||||
String value = obj.getString("value");
|
String value = obj.getString("value");
|
||||||
if(StringUtils.isBlank(value)){
|
if (StringUtils.isBlank(value)) {
|
||||||
JSONObject mock = obj.getJSONObject("mock");
|
JSONObject mock = obj.getJSONObject("mock");
|
||||||
Object mockValue = mock.get("mock");
|
if (mock != null) {
|
||||||
property.put("example", mockValue);
|
Object mockValue = mock.get("mock");
|
||||||
}else{
|
property.put("example", mockValue);
|
||||||
|
} else {
|
||||||
|
property.put("example", value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
property.put("example", value);
|
property.put("example", value);
|
||||||
}
|
}
|
||||||
property.put("description", obj.getString("description"));
|
property.put("description", obj.getString("description"));
|
||||||
property.put("required", obj.getString("required"));
|
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);
|
properties.put(key, property);
|
||||||
}
|
}
|
||||||
schema.put("properties", properties);
|
schema.put("properties", properties);
|
||||||
|
|
Loading…
Reference in New Issue