https://github.com/toddtreece/swagger-client-promises
An ES6 promise wrapper for swagger-client
https://github.com/toddtreece/swagger-client-promises
Last synced: about 1 year ago
JSON representation
An ES6 promise wrapper for swagger-client
- Host: GitHub
- URL: https://github.com/toddtreece/swagger-client-promises
- Owner: toddtreece
- License: mit
- Created: 2015-09-17T13:48:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-18T20:09:07.000Z (almost 11 years ago)
- Last Synced: 2024-04-24T17:05:59.267Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 148 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swagger-client promisify [](https://travis-ci.org/toddtreece/swagger-client-promises)
An ES6 promise wrapper for [swagger-client](https://www.npmjs.com/package/swagger-client).
## Requirements
This module is a [npm](https://www.npmjs.org) package, and requires
the latest stable version of [node.js](https://nodejs.org).
```
$ 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](https://github.com/swagger-api/swagger-js#calling-an-api-with-swagger--nodejs).
```
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](http://gulpjs.com/).
## License
Copyright (c) 2015 Todd Treece. Licensed under the MIT license.