fix(JSON-SCHEMA): #1006429 接口参数中有空值的话,json-schema一下,就会变成乱码
【【github#5943】接口参数中有空值的话,json-schema一下,就会变成乱码】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006429
This commit is contained in:
parent
5912800ce0
commit
c6f281b023
|
@ -49,7 +49,7 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
</el-header>
|
||||
<el-main style="padding: 5px;margin-top: 10px">
|
||||
<el-main style="padding: 5px 5px 0px 5px;margin-top: 10px">
|
||||
<el-container>
|
||||
<el-aside width="60%" class="count-number-show" style="margin-bottom: 0px;margin-top: 0px">
|
||||
<el-container style="height: 50px;margin-top: 10px">
|
||||
|
|
|
@ -51,15 +51,20 @@ class Convert {
|
|||
// root节点基本信息
|
||||
let result = this._value2object(this._object, this._option.$id, "", true);
|
||||
if (this._object.length > 0) {
|
||||
// 创建items对象的基本信息
|
||||
let objectItem = this._object[0]
|
||||
result["items"] = this._value2object(objectItem, `#/items`, 'items');
|
||||
if (isObject(objectItem) && !isEmpty(objectItem)) {
|
||||
// 递归遍历
|
||||
let objectItemSchema = this._json2schema(objectItem, `#/items`);
|
||||
// 合并对象
|
||||
result["items"] = Object.assign(result["items"], objectItemSchema);
|
||||
let itemArr = [];
|
||||
for(let index = 0; index < this._object.length;index ++){
|
||||
// 创建items对象的基本信息
|
||||
let objectItem = this._object[index]
|
||||
let item = this._value2object(objectItem, `#/items`, 'items');
|
||||
if (isObject(objectItem) && !isEmpty(objectItem)) {
|
||||
// 递归遍历
|
||||
let objectItemSchema = this._json2schema(objectItem, `#/items`);
|
||||
// 合并对象
|
||||
item = Object.assign(item, objectItemSchema);
|
||||
}
|
||||
itemArr.push(item);
|
||||
}
|
||||
result["items"] = itemArr;
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -111,15 +116,20 @@ class Convert {
|
|||
if (isArray(element)) {
|
||||
// 针对空数组和有值的数组做不同处理
|
||||
if (element.length > 0) {
|
||||
// 如果是数组,那么就取第一项
|
||||
let elementItem = element[0];
|
||||
// 创建items对象的基本信息
|
||||
result["properties"][key]["items"] = this._value2object(elementItem, `${$id}/items`, key + 'items');
|
||||
// 判断第一项是否是对象,且对象属性不为空
|
||||
if (isObject(elementItem) && !isEmpty(elementItem)) {
|
||||
// 新增的properties才合并进来
|
||||
result["properties"][key]["items"] = Object.assign(result["properties"][key]["items"], this._json2schema(elementItem, `${$id}/items`));
|
||||
// 是数组
|
||||
let itemArr = [];
|
||||
for(let index = 0; index < element.length;index ++){
|
||||
let elementItem = element[index];
|
||||
// 创建items对象的基本信息
|
||||
let item = this._value2object(elementItem, `${$id}/items`, key + 'items');
|
||||
// 判断第一项是否是对象,且对象属性不为空
|
||||
if (isObject(elementItem) && !isEmpty(elementItem)) {
|
||||
// 新增的properties才合并进来
|
||||
item = Object.assign(item, this._json2schema(elementItem, `${$id}/items`));
|
||||
}
|
||||
itemArr.push(item);
|
||||
}
|
||||
result["properties"][key]["items"] = itemArr;
|
||||
}
|
||||
} else {
|
||||
// 不是数组,递归遍历获取,然后合并对象属性
|
||||
|
|
Loading…
Reference in New Issue