Skip to content

Instantly share code, notes, and snippets.

@fehguy
Created February 11, 2015 22:01
Show Gist options
  • Save fehguy/2b144c8f90c3f9f0f2d5 to your computer and use it in GitHub Desktop.
Save fehguy/2b144c8f90c3f9f0f2d5 to your computer and use it in GitHub Desktop.
package.json:
{
"dependencies": {
"swagger-client": "2.1.2-M1"
}
}
test.js:
var swagger = require('swagger-client');
var api = new swagger.SwaggerClient();
swagger.authorizations.add('api_key', new swagger.ApiKeyAuthorization('api_key', 'special-key', 'header'));
api.initialize({url: 'http://petstore.swagger.io/v2/swagger.json', success: function () {
api.pet.getPetById({petId: 1}, function (data) {
console.log(data.obj);
})
}})
// to run:
node test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment