fix(接口测试): 解决swagger导入部分属性处理问题
--user=郭雨琦 --bug=1012975 [接口测试]github#13228swagger2.0导入接口的请求参数键值均为string类型的map字典,导入MS后在请求参数中缺少这个map https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001012975
This commit is contained in:
parent
ced328afce
commit
8cacdad6c0
|
@ -303,6 +303,9 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
|||
item.setType("object");
|
||||
ModelImpl model = (ModelImpl) schema;
|
||||
item.setProperties(parseNewSchemaProperties(model, refSet));
|
||||
if(model.getAdditionalProperties()!=null){
|
||||
item.setAdditionalProperties(parseProperty(model.getAdditionalProperties(), refSet));
|
||||
}
|
||||
} else if (schema instanceof AbstractModel) {
|
||||
AbstractModel abstractModel = (AbstractModel) schema;
|
||||
item.setType("object");
|
||||
|
@ -404,6 +407,9 @@ public class Swagger2Parser extends SwaggerAbstractParser {
|
|||
if(model.getRequired()!=null){
|
||||
item.setRequired(model.getRequired());
|
||||
}
|
||||
if(model.getAdditionalProperties()!=null){
|
||||
item.setAdditionalProperties(parseProperty(model.getAdditionalProperties(), new HashSet<>()));
|
||||
}
|
||||
}
|
||||
}else if(schema instanceof AbstractModel){
|
||||
AbstractModel abstractModel = (AbstractModel) schema;
|
||||
|
|
|
@ -21,6 +21,7 @@ public class JsonSchemaItem {
|
|||
private List<JsonSchemaItem> items;
|
||||
private Map<String, Object> mock;
|
||||
private Map<String, JsonSchemaItem> properties;
|
||||
private JsonSchemaItem additionalProperties;
|
||||
private List<String> required ;
|
||||
|
||||
@JSONField(name = "$schema")
|
||||
|
|
|
@ -4,6 +4,7 @@ public class BasicConstant {
|
|||
public final static String REQUIRED = "required";
|
||||
public final static String ALL_OF = "allOf";
|
||||
public final static String PROPERTIES = "properties";
|
||||
public final static String ADDITIONAL_PROPERTIES = "additionalProperties";
|
||||
public final static String TYPE = "type";
|
||||
public final static String MS_OBJECT = "MS-OBJECT";
|
||||
public final static String ARRAY = "array";
|
||||
|
|
|
@ -54,7 +54,11 @@ public class JSONSchemaGenerator {
|
|||
JsonObject propertyObj = propertiesObj.get(propertyKey).getAsJsonObject();
|
||||
analyzeProperty(rootObj, propertyKey, propertyObj);
|
||||
}
|
||||
} else if (object.has(BasicConstant.TYPE) && object.get(BasicConstant.TYPE).getAsString().equals(BasicConstant.ARRAY)) {
|
||||
}else if (object.has(BasicConstant.ADDITIONAL_PROPERTIES)) {
|
||||
JsonObject propertiesObj = object.get(BasicConstant.ADDITIONAL_PROPERTIES).getAsJsonObject();
|
||||
analyzeProperty(rootObj, BasicConstant.ADDITIONAL_PROPERTIES, propertiesObj);
|
||||
}
|
||||
else if (object.has(BasicConstant.TYPE) && object.get(BasicConstant.TYPE).getAsString().equals(BasicConstant.ARRAY)) {
|
||||
analyzeProperty(rootObj, BasicConstant.MS_OBJECT, object);
|
||||
} else if (object.has(BasicConstant.TYPE) && !object.get(BasicConstant.TYPE).getAsString().equals(BasicConstant.OBJECT)) {
|
||||
analyzeProperty(rootObj, object.getAsString(), object);
|
||||
|
@ -94,7 +98,7 @@ public class JSONSchemaGenerator {
|
|||
}
|
||||
} else if (propertyObjType.equals(BasicConstant.STRING)) {
|
||||
// 先设置空值
|
||||
concept.put(propertyName, "");
|
||||
concept.put(propertyName,"");
|
||||
if (object.has("format")) {
|
||||
String propertyFormat = object.get("format").getAsString();
|
||||
if (propertyFormat.equals("date-time")) {
|
||||
|
|
Loading…
Reference in New Issue