Skip to content

Commit 071bef5

Browse files
committed
Merge pull request swagger-api#594 from alexagranov/master
pull out onChange handler for #input_apiKey so it can be called manually
2 parents 6be1292 + abdf9e9 commit 071bef5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

index.html

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,26 @@
5858
sorter : "alpha"
5959
});
6060

61+
function addApiKeyAuthorization() {
62+
var key = $('#input_apiKey')[0].value;
63+
log("key: " + key);
64+
if(key && key.trim() != "") {
65+
log("added key " + key);
66+
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
67+
}
68+
}
69+
6170
$('#input_apiKey').change(function() {
62-
var key = $('#input_apiKey')[0].value;
63-
log("key: " + key);
64-
if(key && key.trim() != "") {
65-
log("added key " + key);
66-
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
67-
}
68-
})
71+
addApiKeyAuthorization();
72+
});
73+
74+
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
75+
/*
76+
var apiKey = "myApiKeyXXXX123456789";
77+
$('#input_apiKey').val(apiKey);
78+
addApiKeyAuthorization();
79+
*/
80+
6981
window.swaggerUi.load();
7082
});
7183
</script>

0 commit comments

Comments
 (0)