0.1.4 • Published 9 years ago

swagger2client v0.1.4

Weekly downloads
5
License
-
Repository
github
Last release
9 years ago

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.