From b056f0914adff9912a714ff365a16cdd7767c600 Mon Sep 17 00:00:00 2001 From: Alex Agranov Date: Fri, 19 Sep 2014 18:14:28 -0400 Subject: [PATCH 1/2] pull out onChange handler for #input_apiKey so it can be called manually --- index.html | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index caf4ef0ed38..17cd7e93451 100644 --- a/index.html +++ b/index.html @@ -51,14 +51,24 @@ 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(); }); From e6100899966c1f3a40eba15eaab6b2223809a4d6 Mon Sep 17 00:00:00 2001 From: Alex Agranov Date: Fri, 19 Sep 2014 18:18:57 -0400 Subject: [PATCH 2/2] tidy up the commenting --- index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 17cd7e93451..1a419be6783 100644 --- a/index.html +++ b/index.html @@ -65,9 +65,11 @@ }); // 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(); + /* + var apiKey = "myApiKeyXXXX123456789"; + $('#input_apiKey').val(apiKey); + addApiKeyAuthorization(); + */ window.swaggerUi.load(); });