Created
May 3, 2015 10:20
-
-
Save ponelat/b2fcea0c7921029d72dc to your computer and use it in GitHub Desktop.
Basic sending of an api_key
This file contains 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
<script src='browser/swagger-client.js' type='text/javascript'></script> | |
<script type="text/javascript"> | |
// initialize swagger, point to a resource listing | |
window.swagger = new SwaggerClient({ | |
url: "http://petstore.swagger.io/api/api-docs", | |
success: function() { | |
// This will add a query parameter called api_key with the value 'special-key' | |
this.clientAuthorizations.add("api_key", new client.ApiKeyAuthorization("api_key","special-key","query")); | |
// This will add a header called api_key with the value 'special-key' | |
this.clientAuthorizations.add("api_key", new client.ApiKeyAuthorization("api_key","special-key","header")); | |
// upon connect, fetch a pet and set contents to element "mydata" | |
swagger.apis.pet.getPetById({petId:1}, function(data) { | |
document.getElementById("mydata").innerHTML = JSON.stringify(data.obj); | |
}); | |
} | |
}); | |
</script> | |
<body> | |
<div id="mydata"></div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment