
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
linkmore-openapi
Advanced tools
[](https://github.com/chenshuai2144/openapi2typescript) [](https://www.npmjs.com/package/@um
根据 OpenApi3 文档生成 request 请求代码。
如果你使用 umi ,你可以使用@umijs/plugin-openapi 插件。
npm i --save-dev @umijs/openapi
在项目根目录新建 openapi.config.ts
const { generateService } = require('@umijs/openapi')
generateService({
schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
serversPath: './servers',
})
在 package.json
的 script
中添加 api: "openapi": "ts-node openapi.config.ts",
生成api
npm run openapi
属性 | 必填 | 备注 | 类型 | 默认值 |
---|---|---|---|---|
requestLibPath | 否 | 自定义请求方法路径 | string | - |
requestImportStatement | 否 | 自定义请求方法表达式 | string | - |
apiPrefix | 否 | api 的前缀 | string | - |
serversPath | 否 | 生成的文件夹的路径 | string | - |
schemaPath | 否 | Swagger 2.0 或 OpenAPI 3.0 的地址 | string | - |
projectName | 否 | 项目名称 | string | - |
namespace | 否 | 命名空间名称 | string | API |
mockFolder | 否 | mock目录 | string | - |
enumStyle | 否 | 枚举样式 | string-literal | enum | string-literal |
nullable | 否 | 使用null代替可选 | boolean | false |
dataFields | 否 | response中数据字段 | string[] | - |
FAQs
[](https://github.com/chenshuai2144/openapi2typescript) [](https://www.npmjs.com/package/@um
We found that linkmore-openapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.