Giter VIP home page Giter VIP logo

openapi2typescript's Introduction

介绍

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
apiPrefix api 的前缀 string
serversPath 生成的文件夹的路径 string
schemaPath openAPI 3.0 的地址 string
projectName 项目名称 string
namespace 命名空间名称 string
mockFolder mock目录 string

openapi2typescript's People

Contributors

chenshuai2144 avatar lifegit avatar wilds avatar liuyang-kevin avatar neverstop1024 avatar adokevin avatar huangjq148 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.