Socket
Socket
Sign inDemoInstall

@huhm/openapi-gen

Package Overview
Dependencies
16
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @huhm/openapi-gen

[![GitHub Repo stars](https://img.shields.io/github/stars/chenshuai2144/openapi2typescript?style=social)](https://github.com/chenshuai2144/openapi2typescript) [![npm (scoped)](https://img.shields.io/npm/v/@umijs/openapi)](https://www.npmjs.com/package/@um


Version published
Maintainers
1
Created

Readme

Source

介绍

GitHub Repo stars npm (scoped) GitHub tag (latest SemVer pre-release)

根据 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.jsonscript 中添加 api: "openapi": "ts-node openapi.config.ts",

生成api

npm run openapi

参数

属性必填备注类型默认值
requestLibPath自定义请求方法路径string-
requestImportStatement自定义请求方法表达式string-
apiPrefixapi 的前缀string-
serversPath生成的文件夹的路径string-
schemaPathSwagger 2.0 或 OpenAPI 3.0 的地址string-
projectName项目名称string-
namespace命名空间名称stringAPI
mockFoldermock目录string-
enumStyle枚举样式string-literal | enumstring-literal
nullable使用null代替可选booleanfalse
dataFieldsresponse中数据字段string[]-

FAQs

Last updated on 28 Sep 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc