swaxios
Generate Swagger API clients with axios
Last updated 19 hours ago by bennyn .
MIT · Original npm · Tarball · package.json
$ cnpm install swaxios 
SYNC missed versions from official npm registry.

Swaxios

Swaxios

A Swagger API client generator based on axios and written in TypeScript.

CLI Usage

Display the CLI options by running

swaxios --help

If you pass an OpenAPI Specification (OAS) (v2.0; JSON or YAML) to Swaxios, then it will generate you an API client that uses axios under the hood and is written in TypeScript.

Examples:

swaxios -i ./path/to/swagger.json -o ./path/to/output/directory
swaxios -i ./path/to/swagger.yml -o ./path/to/output/directory

Generated API Client Usage

Example using a Node.js API which has been automatically generated by Swaxios:

YourApp.ts

import {APIClient} from 'swaxios';

const accessToken = 'secret-access-token';

const client = new APIClient('https://staging-nginz-https.zinfra.io');
client.defaults.headers.common['Authorization'] = `Bearer ${decodeURIComponent(accessToken)}`;
client.rest.identityProvidersService
  .getById('some-id')
  .then(response => console.log('Response', response))
  .catch(error => {
    if (error.response.status === 401) {
      throw Error('Did your access token expire?');
    }
  });

This project is inspired by swagger-codegen.

Current Tags

  • 0.0.15                                ...           latest (19 hours ago)

15 Versions

  • 0.0.15                                ...           19 hours ago
  • 0.0.14                                ...           a month ago
  • 0.0.13                                ...           a month ago
  • 0.0.12                                ...           a month ago
  • 0.0.11                                ...           a month ago
  • 0.0.10                                ...           2 months ago
  • 0.0.9                                ...           2 months ago
  • 0.0.8                                ...           2 months ago
  • 0.0.7                                ...           2 months ago
  • 0.0.6                                ...           2 months ago
  • 0.0.5                                ...           2 months ago
  • 0.0.4                                ...           2 months ago
  • 0.0.3                                ...           2 months ago
  • 0.0.2                                ...           2 months ago
  • 0.0.1                                ...           2 months ago
Maintainers (1)
Downloads
Today 1
This Week 22
This Month 22
Last Day 21
Last Week 0
Last Month 86
Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |