swagger-client-promises

1.0.2 • Public • Published

swagger-client promisify Build Status

An ES6 promise wrapper for swagger-client.

Requirements

This module is a npm package, and requires the latest stable version of node.js.

$ node -v
v4.0.0

Installation

$ npm install swagger-client-promises

Usage

This wrapper turns every API operation into an ES6 promise, and leaves the rest of the swagger-client interface intact.

Here's a modified version of the example from the swagger-client README.

const client = require('swagger-client-promises');

const swagger = new client({
  url: 'http://petstore.swagger.io/v2/swagger.json',
  success: () => {
    swagger.pet.getPetById({petId: 7}, {responseContentType: 'application/json'})
    .then(pet => {
      console.log('pet', pet);
    })
    .catch(err => {
      console.log(err);
    });
  }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp.

License

Copyright (c) 2015 Todd Treece. Licensed under the MIT license.

Package Sidebar

Install

npm i swagger-client-promises

Weekly Downloads

5

Version

1.0.2

License

MIT

Last publish

Collaborators

  • toddtreece