Created
November 20, 2013 21:20
-
-
Save fehguy/7571252 to your computer and use it in GitHub Desktop.
Using swagger-js to create objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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