Remove global auth object references and fix header api key adding mechanism
Fixes #1033
This commit is contained in:
15
.jshintrc
15
.jshintrc
@@ -18,18 +18,21 @@
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"globals": {
|
||||
"Backbone": false,
|
||||
|
||||
// Libraries
|
||||
"_": false,
|
||||
"$": false,
|
||||
"Backbone": false,
|
||||
"Handlebars": false,
|
||||
"jQuery": false,
|
||||
"marked": false,
|
||||
"Docs": false,
|
||||
"SwaggerClient": false,
|
||||
"Handlebars": false,
|
||||
"ApiKeyAuthorization": false,
|
||||
"PasswordAuthorization": false,
|
||||
"hljs": false,
|
||||
"SwaggerUi": false,
|
||||
"swaggerUi": false // TODO: remove me
|
||||
|
||||
// Global object
|
||||
// TODO: remove these
|
||||
"swaggerUi": false,
|
||||
"Docs": false
|
||||
}
|
||||
}
|
||||
9
dist/index.html
vendored
9
dist/index.html
vendored
@@ -61,8 +61,9 @@
|
||||
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);
|
||||
log("added key " + key);
|
||||
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +79,12 @@
|
||||
*/
|
||||
|
||||
window.swaggerUi.load();
|
||||
|
||||
function log() {
|
||||
if ('console' in window) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
6
dist/swagger-ui.js
vendored
6
dist/swagger-ui.js
vendored
@@ -59,7 +59,7 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
|
||||
// Event handler for when the baseUrl/apiKey is entered by user
|
||||
this.headerView.on('update-swagger-ui', function(data) {
|
||||
return this.updateSwaggerUi(data);
|
||||
return that.updateSwaggerUi(data);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1025,7 +1025,7 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
|
||||
|
||||
|
||||
applyApiKey: function(){
|
||||
var keyAuth = new ApiKeyAuthorization(
|
||||
var keyAuth = new SwaggerClient.ApiKeyAuthorization(
|
||||
this.model.name,
|
||||
$('#input_apiKey_entry').val(),
|
||||
this.model.in
|
||||
@@ -1078,7 +1078,7 @@ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({
|
||||
applyPassword: function(){
|
||||
var username = $('.input_username').val();
|
||||
var password = $('.input_password').val();
|
||||
var basicAuth = new PasswordAuthorization('basic', username, password);
|
||||
var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password);
|
||||
window.authorizations.add(this.model.type, basicAuth);
|
||||
window.swaggerUi.load();
|
||||
$('#basic_auth_container').hide();
|
||||
|
||||
4
dist/swagger-ui.min.js
vendored
4
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -61,8 +61,9 @@
|
||||
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);
|
||||
log("added key " + key);
|
||||
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +79,12 @@
|
||||
*/
|
||||
|
||||
window.swaggerUi.load();
|
||||
|
||||
function log() {
|
||||
if ('console' in window) {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -53,7 +53,7 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
|
||||
// Event handler for when the baseUrl/apiKey is entered by user
|
||||
this.headerView.on('update-swagger-ui', function(data) {
|
||||
return this.updateSwaggerUi(data);
|
||||
return that.updateSwaggerUi(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
|
||||
|
||||
|
||||
applyApiKey: function(){
|
||||
var keyAuth = new ApiKeyAuthorization(
|
||||
var keyAuth = new SwaggerClient.ApiKeyAuthorization(
|
||||
this.model.name,
|
||||
$('#input_apiKey_entry').val(),
|
||||
this.model.in
|
||||
|
||||
@@ -20,7 +20,7 @@ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({
|
||||
applyPassword: function(){
|
||||
var username = $('.input_username').val();
|
||||
var password = $('.input_password').val();
|
||||
var basicAuth = new PasswordAuthorization('basic', username, password);
|
||||
var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password);
|
||||
window.authorizations.add(this.model.type, basicAuth);
|
||||
window.swaggerUi.load();
|
||||
$('#basic_auth_container').hide();
|
||||
|
||||
Reference in New Issue
Block a user