apifox-api 0.0.14 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -12
- package/assets/apifox-module-id.jpg +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@ npm install -g apifox-api
|
|
|
17
17
|
- **projectId**:Apifox 项目设置 → 基本设置 → 项目 ID
|
|
18
18
|
- **Access Token**:Apifox 账号设置 → API 访问令牌,新建一个个人令牌
|
|
19
19
|
|
|
20
|
+
> 想让所有项目共享同一个 token?拿到 Access Token 后,运行 `apifox-api config set-auth-key <token>` 设一个全局默认 auth key,之后每个项目 `init` 就不用再带 `--authKey`。
|
|
21
|
+
|
|
20
22
|
### 2. 绑定当前工作目录
|
|
21
23
|
|
|
22
24
|
在你的业务项目根目录运行:
|
|
@@ -31,6 +33,10 @@ apifox-api init <projectId> --authKey <your-access-token>
|
|
|
31
33
|
apifox-api init <projectId> --moduleIds 5,8,12 --authKey <your-access-token>
|
|
32
34
|
```
|
|
33
35
|
|
|
36
|
+
> 不确定 moduleId 在哪获取?在 Apifox 项目里,**项目设置 → 模块管理**可以看到每个模块的数字 ID:
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
34
40
|
绑定信息写入全局注册表 `~/.apifox-api.json`(以工作目录为 key,一台机器可同时绑定多个项目)。`init` 会立即拉取每个 module 的 OpenAPI 快照并缓存到当前目录的 `.cache/apifox-api/` 下。
|
|
35
41
|
|
|
36
42
|
> 不想把 token 写进文件?省略 `--authKey`,改用 `APIFOX_AUTH_KEY` 环境变量(运行时 env 优先于文件中的值)。重新 `init` 同一目录会覆盖旧绑定并打印 before/after。
|
|
@@ -65,12 +71,14 @@ apifox-api get GET /orders/{id}
|
|
|
65
71
|
|
|
66
72
|
一个 Apifox 项目可包含多个模块。`init --moduleIds` 绑定你关心的模块:
|
|
67
73
|
|
|
68
|
-
- **单 module
|
|
69
|
-
- **多 module
|
|
70
|
-
- `search` 和 `get`
|
|
74
|
+
- **单 module**(如 `--moduleIds 5`):自动作为当前 module,无需切换,也不生成 `.current-module`。
|
|
75
|
+
- **多 module**(如 `--moduleIds 5,8,12`):`init` 在绑定根生成 `.current-module` 文件标记当前 module(默认指向第一个)。
|
|
76
|
+
- `search` 和 `get` 只在**当前 module** 的快照内工作,不跨 module 混搜。
|
|
71
77
|
- 临时只查一次别的 module:加 `--moduleId N`。
|
|
72
78
|
- 不传 `--moduleIds`:使用项目的默认模块。
|
|
73
79
|
|
|
80
|
+
> **多 module 项目重点**:`.current-module` 决定了 `search` / `get` 读哪个 module 的快照。切换当前 module 用 `apifox-api module <id>`;如果该文件缺失或指向无效 module,运行时会报错提示你先选一个。
|
|
81
|
+
|
|
74
82
|
## 认证
|
|
75
83
|
|
|
76
84
|
Apifox Auth Key 用于访问 Apifox 的 OpenAPI 导出 API,是 CLI 拉取接口数据所必需的凭证。它的来源有以下 3 级优先级(从高到低):
|
|
@@ -93,13 +101,6 @@ APIFOX_MCP_OPENAPI_TTL_MS=86400000
|
|
|
93
101
|
|
|
94
102
|
读取时若远程刷新失败,会回退到同 token 的过期缓存并附带警告;显式 `refresh` 永不回退,远程失败即报错。
|
|
95
103
|
|
|
96
|
-
## 从旧版(apifox-mcp MCP server)迁移
|
|
97
|
-
|
|
98
|
-
旧版是 MCP server + 工作区 `.apifox-mcp.json`。升级后:
|
|
99
|
-
|
|
100
|
-
- 在业务项目根目录运行 `apifox-api init <projectId> --authKey <token>`,会自动检测并迁移旧 `.apifox-mcp.json` 中的 `projectId`。
|
|
101
|
-
- 旧文件 `.apifox-mcp.json` 不再生效,建议手动删除。
|
|
102
|
-
|
|
103
104
|
## 开发
|
|
104
105
|
|
|
105
106
|
```bash
|
|
@@ -109,6 +110,14 @@ bunx tsc --noEmit
|
|
|
109
110
|
bun run build
|
|
110
111
|
```
|
|
111
112
|
|
|
112
|
-
## AI
|
|
113
|
+
## AI Agent Skill
|
|
114
|
+
|
|
115
|
+
提供一份 Cursor / Claude Code agent skill,教 AI 如何驱动本 CLI:先 `search` 找接口、再用 Operation Key(HTTP method + path)`get` 生成类型,以及多 module 项目如何切换当前 module。
|
|
116
|
+
|
|
117
|
+
安装到你的项目(需要先全局装好本 CLI):
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx skills add akirousnow/apifox-api-skill --skill apifox-api
|
|
121
|
+
```
|
|
113
122
|
|
|
114
|
-
|
|
123
|
+
装好后,在 Cursor / Claude Code 里直接对 AI 说"找接口"、"生成接口类型"即可自动触发。skill 源码见 [akirousnow/apifox-api-skill](https://github.com/akirousnow/apifox-api-skill)。
|
|
Binary file
|