English | 简体中文
build your axios code from swagger document (not support swagger v3)
and have good Intelligence in vscode
- create jsdoc in js
- create typing in ts
https://coppyc.github.io/api-code-builder/
yarn add -D api-code-builder
then add npm script "build:api": "api-code-builder"
to your package.json
scripts
{
"scripts": {
"build:api": "api-code-builder"
}
}
finally, run and answer some questions, enjoy it!
yarn build:api
const apiCodeBuilder = require('api-code-builder')
const docs = { /** */ } // you need to get the swagger document by yourself
const code = apiCodeBuilder.buildApi({
paths: docs.paths,
definitions: docs.definitions,
// version: 'ts',
// customResponse: 'any',
// axiosFrom: './myAxios'
})
console.log(code)
<script src="https://unpkg.com/api-code-builder@2.x/dist/main.umd.js"></script>
- a adapter from swagger to axios in running time.
- output the swagger.json file as the adapter input
- only product js + .d.ts at once then only update without js