swagger2client
Client for Swagger 2.0
Last updated 6 years ago by bebraw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install swagger2client 
SYNC missed versions from official npm registry.

build status

swagger2client - Client for Swagger 2.0

Usage:

var swaggerClient = require('swagger2client');

var client = swaggerClient({
    url: ..., // url to API root
    schema: ..., // swagger 2.0 schema
    headers: { // optional headers (handy for auth)
        'Authorization': 'Bearer ' + ...
    }
});

// Swagger resources can be accessed like this
// parameters are optional. in case of GET they are passed to query,
// otherwise to body
client.todos.get({...}).then(function(res) {
    ...
}).catch(function(err) {
    ...
});

// in addition it is possible to access metadata related to resources
client.todos.parameters
client.todos.responses
client.todos.description

// these map to Swagger definition. $refs have been expanded

Internally the requests are based on axios so check that out for specifications for return values and such.

License

swagger2client is available under MIT. See LICENSE for more details.

Current Tags

  • 0.1.4                                ...           latest (6 years ago)

5 Versions

  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 5
Dependencies (6)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |