Skip to content

toft-code/swagger-axios-ts-generator

Repository files navigation

@toft-code/swagger-axios-ts-generator

npm version

Install

$ npm install @toft-code/swagger-axios-ts-generator
$ yarn add @toft-code/swagger-axios-ts-generator

Example

Example Link

TypeScript

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',
})

CommonJS

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',
})

Other

Thanks Manweill/swagger-axios-codegen

Releases

No releases published

Packages

No packages published