Skip to content

Commit

Permalink
Merge pull request swagger-api#594 from alexagranov/master
Browse files Browse the repository at this point in the history
pull out onChange handler for #input_apiKey so it can be called manually
  • Loading branch information
fehguy committed Sep 26, 2014
2 parents d90392b + e610089 commit c536cee
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@
sorter : "alpha"
});

function addApiKeyAuthorization() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
}
}

$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
}
})
addApiKeyAuthorization();
});

// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/

window.swaggerUi.load();
});
</script>
Expand Down

0 comments on commit c536cee

Please sign in to comment.