GithubHelp home page GithubHelp logo

buqiyuan / openapi2typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chenshuai2144/openapi2typescript

0.0 1.0 0.0 311 KB

一个被大范围使用的小工具

JavaScript 6.32% TypeScript 84.59% Nunjucks 9.09%

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 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[] -
isCamelCase 小驼峰命名文件和请求函数 boolean true

openapi2typescript's People

Contributors

chenshuai2144 avatar lifegit avatar wilds avatar rookie-luochao avatar scrapstation avatar liu-ya avatar slightc avatar liuyang-kevin avatar chen-kay avatar wkeylin avatar loulin avatar neverstop1024 avatar citrusjunoss avatar alioth1017 avatar bruceye2020 avatar lovewinders avatar thanhlcm90 avatar lampofaladdin avatar magic-zagan avatar stantoxt avatar ianhash avatar adokevin avatar hlouis avatar monkeykingblack avatar creampnx-x avatar cui-xxu avatar daviyang35 avatar huangjq148 avatar huhm avatar leoner avatar

Watchers

 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.