swagger-axios-codegen-es6
A swagger client uses axios and es6
require node > v8.0.0
it will always resolve axios.response.data
or reject axios.error
with Promise
support other similar to axios
library, for example Fly.js, required setting ISwaggerOptions.useCustomerRequestInstance = true
Example
ChangeLog
Get Started
yarn add swagger-axios-codegen
const defaultOptions: ISwaggerOptions = serviceNameSuffix: 'Service' enumNamePrefix: 'Enum' methodNameMode: 'operationId' outputDir: './service' fileName: 'index.ts' useStaticMethod: true useCustomerRequestInstance: false include:
use local swagger api json
const codegen =
use remote swagger api json
const codegen =
use static method
;
before
const userService = await userService;
after
await UserService;
use custom axios.instance
Create a service/index.js than export your generated service file with custom axios instance
//services/index.js const getAxiosInstance = { return axios;}; ProductServiceaxios = ; ;
use other library
serviceOptionsaxios = YourLib
filter service and method
let include = 'Products' // tagName 'Estimates'//tagName 'User': 'history'
Welcome PRs and commit issue
⭐⭐⭐⭐⭐