$ npm install @toft-code/swagger-axios-ts-generator
$ yarn add @toft-code/swagger-axios-ts-generator
import { generate } from '@toft-code/swagger-axios-ts-generator'
generate({
// out files path
out: './testServices',
// service name suffix
serviceNameSuffix: 'Service',
// api json url
url:
'https://raw.githubusercontent.com/toft-code/swagger-axios-ts-generator/master/test.json',
// foreach operationId
operationIdForeach: (operationId: string) => {
return operationId.match(/[a-zA-Z]+/g)?.join('') ?? operationId
},
// services/index.ts template
requestTemplateUrl:
'https://raw.githubusercontent.com/toft-tech/swagger-axios-ts-generator/master/src/template/indexAxiosTemplate.ts',
})
const { generate } = require('@toft-code/swagger-axios-ts-generator')
generate({
out: './src/testService',
url:
'https://raw.githubusercontent.com/toft-code/swagger-axios-ts-generator/master/test.json',
})