Giter VIP home page Giter VIP logo

swaggertotypescript's Introduction

自动化swagger转TypeScript工具

默认转换成js 如果要转换成ts的话 请放开这两个注释

// 如果要保存为ts格式的话 只要把这行改一下就可以了
// .replace('</childrenParams/>',operations.parameters.map((e)=>`${e.name}:${e.type}`))

<!-- 最底部 -->
// fs.writeFileSync(__dirname + '/apiCommand.ts',content + endContent)

使用说明

// 使用之前 将这个url地址 替换为自己后台swagger网站的地址
const urlAddress = '';

然后直接node api.js就会自动帮你在js目录下生成一个对应的api脚本文档

推荐将这个api文件放到自己的私有库里面
在自身的项目里面 增加一个apiCreate.js脚本文件
里面只要写一行代码 require('xxxx/api')
然后修改package在script中增加一行代码

start:node apiCreate.js && 这里你原来项目启动的脚本命令

这样做以后 在你每次项目启动之前 你的私有库里面都会生成一个apiCommand脚本 然后就�可以直接在项目中使用最新的接口函数来进行编程了

image

swaggertotypescript's People

Contributors

fangkyi02 avatar fangkyi03 avatar

Stargazers

Github蓝钻用户 avatar HuangPan avatar  avatar xubill avatar abc avatar 毛欢欢 avatar  avatar  avatar 张鹏宾 avatar CAI avatar Theo avatar

Forkers

double517

swaggertotypescript's Issues

[DepShield] (CVSS 7.5) Vulnerability due to usage of axios:0.18.0

Vulnerabilities

DepShield reports that this application's usage of axios:0.18.0 results in the following vulnerability(s):

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

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.