From 65cd36c02c049cae993edef14c1ab3e0e230fa95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 1 Mar 2024 22:03:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=9F=BA=E6=9C=AC=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exts/yapi-plugin-export-postman/controller.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exts/yapi-plugin-export-postman/controller.js b/exts/yapi-plugin-export-postman/controller.js index 40d976f..e869435 100644 --- a/exts/yapi-plugin-export-postman/controller.js +++ b/exts/yapi-plugin-export-postman/controller.js @@ -66,7 +66,7 @@ class exportPostmanController extends baseController { return data; } - dealMenuOrInterface(item) { + dealMenuOrInterface(item, basePath) { // console.log(item) return { name: item.name, @@ -83,10 +83,10 @@ class exportPostmanController extends baseController { } }), url:{ - raw: `{{BaseHost}}/${it.path}`.replace(/\/+/g,"/"), + raw: `{{BaseHost}}/${basePath}/${it.path}`.replace(/\/+/g,"/"), host: ["{{BaseHost}}"], // port:"", - path: it.path.split("/").filter(it => it.length > 0) + path: (basePath + "/" + it.path).split("/").filter(it => it.length > 0) }, response:[] } @@ -139,7 +139,8 @@ class exportPostmanController extends baseController { let data = this.handleExistId(list); - // console.log("curProject", curProject) + console.log("curProject", curProject) + // console.log("list", list) let model = await convertToPostmanModel(data); tp = JSON.stringify(model, null, 2); @@ -152,7 +153,7 @@ class exportPostmanController extends baseController { } //Convert to SwaggerV2.0 (OpenAPI 2.0) async function convertToPostmanModel(list) { - + const basePath = curProject.basepath const postmanObj = { info:{ _postman_id: uid.v4(), @@ -160,7 +161,7 @@ class exportPostmanController extends baseController { schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, item:(() => { - return list.map(it => that.dealMenuOrInterface(it)) + return list.map(it => that.dealMenuOrInterface(it, basePath)) })(), paths: (() => { let apisObj = {};