Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
swagger-axios-codegen
Advanced tools
[![NpmVersion](https://img.shields.io/npm/v/swagger-axios-codegen.svg)](https://www.npmjs.com/package/swagger-axios-codegen) [![npm](https://img.shields.io/npm/dt/swagger-axios-codegen.svg)](https://www.npmjs.com/package/swagger-axios-codegen)
require node > v8.0.0
swagger client to use axios and typescript
it will always resolve axios.response.data
or reject axios.error
with Promise
support other support similar to axios
library, for example Fly.js, required setting ISwaggerOptions.useCustomerRequestInstance = true
yarn add swagger-axios-codegen
export interface ISwaggerOptions {
classNameSuffix?: string
methodNameMode?: 'operationId' | 'path'
outputDir?: string
fileName?: string
remoteUrl?: string
source?: any
useStaticMethod?: boolean
useCustomerRequestInstance?: boolean
}
const defaultOptions: ISwaggerOptions = {
classNameSuffix: 'Service',
methodNameMode: 'operationId',
outputDir: './service',
fileName: 'index.ts',
useStaticMethod: true,
useCustomerRequestInstance: true
}
const { codegen } = require('swagger-axios-codegen')
codegen({
methodNameMode: 'operationId',
source:require('./swagger.json')
})
const { codegen } = require('swagger-axios-codegen')
codegen({
methodNameMode: 'operationId',
remoteUrl:'You remote Url'
})
codegen({
methodNameMode: 'operationId',
remoteUrl: 'http://localhost:22742/swagger/v1/swagger.json',
outputDir: '.',
useStaticMethod:true
});
before
import { UserService } from './service'
const userService = new UserService()
await userService.GetAll();
after
import { UserService } from './service'
await UserService.GetAll();
import axios from 'axios'
import { serviceOptions } from './service'
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
});
serviceOptions.axios = instance
import YourLib from '<Your lib>'
import { serviceOptions } from './service'
serviceOptions.axios = YourLib
Welcome PR and commit issue
FAQs
A swagger client uses axios and typescript
The npm package swagger-axios-codegen receives a total of 5,911 weekly downloads. As such, swagger-axios-codegen popularity was classified as popular.
We found that swagger-axios-codegen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.