
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
smart-api-generator
Advanced tools
smart-api-generator是一个高效能的工具,专门用来自动化创建API接口及其相关文档
// npm
npm install smart-api-generator -D
// yarn
yarn add smart-api-generator -D
// pnpm
pnpm install smart-api-generator -D
1、在 package.json 中配置命令,配置文件可指定路径,如果不指定路径默认取根目录下的.api.config.js
文件
"scripts": {
......
"api": "cross-env smart-api create --config /path/to/.api.config.js"
},
2、在工程中添加配置文件·api.config.js
module.exports = {
output: './src/request',
projects: [
{
projectName: 'xxx',
basePath: 'xxx',
//...
}
]
}
3、在根目录中运行命令
npm run api
参数 | 说明 | 必填 | 类型 | 默认值 | 版本 |
---|---|---|---|---|---|
output | 接口文件输出目录 | true | string | - | 1.0.0 |
host | swagger平台地址 | false | string | https://letao.cnstrong.cn | 1.0.0 |
projects | 接口文档配置 | true | array | - | 1.0.0 |
参数 | 说明 | 必填 | 类型 | 默认值 | 版本 |
---|---|---|---|---|---|
projectName | 项目名称,对应swagger接口文档地址,如:https://letao.cnstrong.cn/letao-official-document-center/doc.html#/home 中,projectName 为 letao-official-document-center | true | string | - | 1.0.0 |
basePath | 接口统一前缀,默认会使用swagger文档中的basePath字段,如果文档与实际有差异,请手动配置 | false | string | swagger文档主页中的basePath字段 | 1.0.0 |
comment | 是否需要生成注释 | false | boolean | true | 1.0.0 |
folderName | 生成文件夹的名称 | false | string | 默认使用 projectName | 1.0.0 |
tsNotStrictInclude | 生成的ts代码时,控制请求参数/返回结果是否严格模式,req 参数部分关闭严格模式,res 返回部分关闭严格模式 | false | string[] | ['res'] | 1.1.0 |
extractResponseKeys | 对接口返回结构进行提取,应对axios拦截器对请求返回做提取的场景,如['data']则提取接口返回中的data字段作为Res,可以配置多个,返回匹配到的第一个 | false | string[] | - | 1.2.0 |
tags | 可以只生成项目下指定分类下的接口, 如: ['user'] | false | string[] | - | 1.2.0 |
extractAxiosPromise | 是否提取axios返回的data层级 | false | boolean | - | 1.2.3 |
mergeConfig |
打开,不会删除本地配置有但是接口文档中没有的接口,可以手动删除,而且新增的接口都会排列到最后面 关闭,文件的生成完全按照接口文档生成 | true | boolean | - | 1.3.0 |
FAQs
smart-api-generator是一个高效能的工具,专门用来自动化创建API接口及其相关文档
The npm package smart-api-generator receives a total of 11 weekly downloads. As such, smart-api-generator popularity was classified as not popular.
We found that smart-api-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.