Skip to content

Instantly share code, notes, and snippets.

@ponelat
Created May 1, 2015 16:59
Show Gist options
  • Save ponelat/534088a33ab5656cea7d to your computer and use it in GitHub Desktop.
Save ponelat/534088a33ab5656cea7d to your computer and use it in GitHub Desktop.
var client = require('swagger-client');
var swagger = new client({
url: 'http://petstore.swagger.io/v2/swagger.json',
success: function() {
swagger.apis.pet.getPetById({petId:10},function(pet){
console.log('pet', pet);
});
}
})
// Output from running js-readme-node.js
// ..having assigned a pet with ID = 10
pet { url: 'http://petstore.swagger.io/v2/pet/10',
method: 'GET',
headers:
{ 'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET, POST, DELETE, PUT',
'access-control-allow-headers': 'Content-Type, api_key, Authorization',
'content-type': 'application/xml',
connection: 'close',
server: 'Jetty(9.2.7.v20150116)' },
obj: {},
status: 200,
statusText: undefined,
data: undefined }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment