fix(接口测试): json-schema数组类型解析有误
This commit is contained in:
parent
e1c38e87d4
commit
54c102aad3
|
@ -51,7 +51,7 @@ public class JsonSchemaItem {
|
|||
* 当 type 为array 时,使用该值
|
||||
*/
|
||||
@Valid
|
||||
private JsonSchemaItem items;
|
||||
private List<JsonSchemaItem> items;
|
||||
/**
|
||||
* 参数属性
|
||||
* 当 type 为 object 时,使用该值
|
||||
|
@ -126,7 +126,7 @@ public class JsonSchemaItem {
|
|||
if (type.equals(PropertyConstant.OBJECT)) {
|
||||
this.properties = new LinkedHashMap<>();
|
||||
} else if (type.equals(PropertyConstant.ARRAY)) {
|
||||
this.items = new JsonSchemaItem();
|
||||
this.items = List.of();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
|
|||
JsonSchemaItem arrayItem = new JsonSchemaItem();
|
||||
arrayItem.setId(IDGenerator.nextStr());
|
||||
arrayItem.setType(PropertyConstant.ARRAY);
|
||||
arrayItem.setItems(new JsonSchemaItem());
|
||||
arrayItem.setItems(List.of());
|
||||
yield arrayItem;
|
||||
}
|
||||
yield isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema, true) :
|
||||
|
@ -712,7 +712,7 @@ public class Swagger3Parser extends ApiImportAbstractParser<ApiDefinitionImport>
|
|||
}
|
||||
|
||||
JsonSchemaItem itemsJsonSchema = parseProperty(itemsSchema, onlyOnce);
|
||||
jsonSchemaArray.setItems(itemsJsonSchema);
|
||||
jsonSchemaArray.setItems(List.of(itemsJsonSchema));
|
||||
jsonSchemaArray.setMaxItems(arraySchema.getMaxItems());
|
||||
jsonSchemaArray.setMinItems(arraySchema.getMinItems());
|
||||
return jsonSchemaArray;
|
||||
|
|
|
@ -772,12 +772,17 @@ public class ApiDefinitionImportService {
|
|||
}
|
||||
}
|
||||
if (jsonSchema != null && StringUtils.equals(jsonSchema.getType(), PropertyConstant.ARRAY)) {
|
||||
JsonSchemaItem items = jsonSchema.getItems();
|
||||
JsonSchemaItem importItems = importJsonSchema.getItems();
|
||||
if (items != null && importItems != null) {
|
||||
if (!jsonSchemaIsSame(items, importItems)) {
|
||||
List<JsonSchemaItem> jsonSchemaItems = jsonSchema.getItems();
|
||||
List<JsonSchemaItem> importJsonSchemaItems = importJsonSchema.getItems();
|
||||
if (jsonSchemaItems != null && importJsonSchemaItems != null) {
|
||||
if (jsonSchemaItems.size() != importJsonSchemaItems.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < jsonSchemaItems.size(); i++) {
|
||||
if (!jsonSchemaIsSame(jsonSchemaItems.get(i), importJsonSchemaItems.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return same;
|
||||
|
|
Loading…
Reference in New Issue