Add API Key auth in onComplete callback of SwaggerUI#load call

This commit is contained in:
Mohsen Azimi
2015-04-15 14:44:35 -07:00
parent 854ef16cbb
commit b579783ba0
3 changed files with 10 additions and 10 deletions

6
dist/index.html vendored
View File

@@ -42,9 +42,12 @@
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
addApiKeyAuthorization();
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
@@ -53,9 +56,8 @@
sorter : "alpha"
});
function addApiKeyAuthorization() {
function addApiKeyAuthorization(){
var key = encodeURIComponent($('#input_apiKey')[0].value);
log("key: " + key);
if(key && key.trim() != "") {
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);