Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class ParamsImportComponent implements OnInit {
const combineFunc = {
overwrite: data => data,
append: (data, base) => base.concat(data),
mixin: (data, base) => pcMerge(base, data, 'paramAttr.example', 'childList', false)
mixin: (data, base) => pcMerge(base, data, ['dataType', 'paramAttr.example'], 'childList', false)
};

const endParse = (data, type) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const parseTree = (key, value): BodyParam | unknown => {
paramAttr: {
example: ''
},
dataType: ApiParamsType.string,
dataType: ApiParamsType.object,
description: '',
childList: Object.keys(value).map(it => parseTree(it, value[it]))
};
Expand Down
8 changes: 5 additions & 3 deletions src/workbench/browser/src/app/utils/pc-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface RootObject {
* @description Merge specified key
* @param {RootObject[]} baseArr baseArr
* @param {RootObject[]} newDataArr newDataArr
* @param {string} mergerKey specified key
* @param {string[]} mergerKey specified key
* @param {string} childKey childList correspondence key
* @param {boolean} childKey isChild
* @return {RootObject[]} assginArr
Expand All @@ -33,7 +33,7 @@ export interface RootObject {
export const pcMerge = (
baseArr: RootObject[],
newDataArr: RootObject[],
mergerKey: string,
mergerKey: string[],
childKey: string,
isChild: boolean
): RootObject[] => {
Expand All @@ -45,7 +45,9 @@ export const pcMerge = (
for (let ele of handleData) {
if (item.name === ele.name) {
//Assigns the specified key
ele[mergerKey] = item[mergerKey];
mergerKey.forEach(e => {
ele[e] = item[e];
});
if (item[childKey] && item[childKey].length !== 0) {
if (ele[childKey]) {
//Subtree recursion
Expand Down