Skip to content

Commit

Permalink
fix: import dataType problem (#269)
Browse files Browse the repository at this point in the history
Co-authored-by: sunzhouyang <sunzhouyang@eolink.com>
  • Loading branch information
yZaio and sunzhouyang authored Mar 14, 2023
1 parent 6cbe019 commit bf7694d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
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

0 comments on commit bf7694d

Please sign in to comment.