feat(apifox): 为接口查询方法添加projectId参数支持
允许在查询接口详情时指定项目ID,提高多项目环境下的灵活性
This commit is contained in:
1 parent
ae684d83b1
commit
4386beea66
2 files changed
+14
-6
No files matched your search
@@ -276,7 +276,10 @@ export class ApifoxService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApiDetailByPath(path) {
|
async getApiDetailByPath(path, projectId) {
|
||||||
|
if (projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
const apiDetails = await this.getApiDetails();
|
const apiDetails = await this.getApiDetails();
|
||||||
const apiDetail = apiDetails.find((item) => item.path === path);
|
const apiDetail = apiDetails.find((item) => item.path === path);
|
||||||
if (!apiDetail) {
|
if (!apiDetail) {
|
||||||
@@ -285,7 +288,10 @@ export class ApifoxService {
|
|||||||
return this.getApiDetailResp(apiDetail);
|
return this.getApiDetailResp(apiDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApiDetailsById(apiId) {
|
async getApiDetailsById(apiId, projectId) {
|
||||||
|
if (projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
const apiDetails = await this.getApiDetails();
|
const apiDetails = await this.getApiDetails();
|
||||||
const apiDetail = apiDetails.find((item) => item.id === apiId);
|
const apiDetail = apiDetails.find((item) => item.id === apiId);
|
||||||
if (!apiDetail) {
|
if (!apiDetail) {
|
||||||
|
|||||||
@@ -32,13 +32,14 @@ server.registerTool(
|
|||||||
description: "根据接口path获取Apifox接口定义数据",
|
description: "根据接口path获取Apifox接口定义数据",
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
path: z.string().describe("接口路径"),
|
path: z.string().describe("接口路径"),
|
||||||
|
projectId: z.number().optional().describe("Apifox项目ID"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
async ({ path }) => {
|
async ({ path, projectId }) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const apiData = await apifoxService.getApiDetailByPath(path);
|
const apiData = await apifoxService.getApiDetailByPath(path, projectId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
@@ -68,13 +69,14 @@ server.registerTool(
|
|||||||
description: "根据接口目录获取Apifox目录下所有接口定义数据",
|
description: "根据接口目录获取Apifox目录下所有接口定义数据",
|
||||||
inputSchema: z.object({
|
inputSchema: z.object({
|
||||||
folderName: z.string().describe("接口路径"),
|
folderName: z.string().describe("接口路径"),
|
||||||
|
projectId: z.number().optional().describe("Apifox项目ID"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
async ({ folderName }) => {
|
async ({ folderName, projectId }) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const apiData = await apifoxService.getApiListByFolderName(folderName);
|
const apiData = await apifoxService.getApiListByFolderName(folderName, projectId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
|
|||||||
Reference in new issue
Block a user