Skip to content

Instantly share code, notes, and snippets.

@fehguy
Created November 20, 2013 21:20
Show Gist options
  • Save fehguy/7571252 to your computer and use it in GitHub Desktop.
Save fehguy/7571252 to your computer and use it in GitHub Desktop.
Using swagger-js to create objects
var client = require("swagger-client");
client.authorizations.add("key", new client.ApiKeyAuthorization("api_key", "special-key", "query"))
var swagger = new client.SwaggerApi({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
success: function() {
if(swagger.ready === true) {
var json = JSON.stringify({
"id": 1,
"name": "string",
"status": "string"
});
swagger.apis.pet.addPet({
body: json
},
function(data) {
console.log("got data: " + data.content.data);
}
);
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment