From ecb6413cc6d1a247f9c4b5966aeb654d373d6794 Mon Sep 17 00:00:00 2001 From: "huoyong.msb" Date: Mon, 8 Feb 2021 11:11:26 +0800 Subject: [PATCH] feat: fix swagger import bug --- src/service/migrate.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/service/migrate.ts b/src/service/migrate.ts index 07ff749..641b5b4 100644 --- a/src/service/migrate.ts +++ b/src/service/migrate.ts @@ -492,10 +492,10 @@ export default class MigrateService { domain = 'http://' + domain } domain = domain.substring(0, domain.indexOf('/', domain.indexOf('.'))) - let result = await rp(`${domain}/api/queryRAPModel.do?projectId=${projectId}`, { + const response = await rp(`${domain}/api/queryRAPModel.do?projectId=${projectId}`, { json: false, }) - result = JSON.parse(result) + result = JSON.parse(response) // result = unescape(result.modelJSON) result = result.modelJSON @@ -513,11 +513,11 @@ export default class MigrateService { method: string, apiInfo: any, ): Promise { - let { definitions } = swagger + let { definitions = {} } = swagger const result = [] definitions = JSON.parse(JSON.stringify(definitions)) // 防止接口之间数据处理相互影响 - if (method === 'get' || method === 'GET') { + if (Array.isArray(parameters) && method === 'get' || method === 'GET') { parse( parameters.filter(item => item.in !== 'body') || [], 'root',