checks for window

This commit is contained in:
Tony Tam
2016-11-14 11:34:50 -08:00
parent a63dc0c51b
commit 81e897a07a
8 changed files with 47 additions and 35 deletions

View File

@@ -11,7 +11,7 @@ var additionalQueryStringParams;
function handleLogin() {
var scopes = [];
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
var auths = window.swaggerUiAuth.authSchemes || window.swaggerUiAuth.securityDefinitions;
if(auths) {
var key;
var defs = auths;
@@ -36,8 +36,7 @@ function handleLogin() {
}
}
if(window.swaggerUi.api
&& window.swaggerUi.api.info) {
if(window.swaggerUi.api && window.swaggerUi.api.info) {
appName = window.swaggerUi.api.info.title;
}
@@ -285,7 +284,7 @@ window.processOAuthCode = function processOAuthCode(data) {
});
};
window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
window.onOAuthComplete = function onOAuthComplete(token, OAuthSchemeKey) {
if(token) {
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
@@ -295,7 +294,7 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
alert(token.error);
}
else {
var b = token[window.swaggerUi.tokenName];
var b = token[window.swaggerUiAuth.tokenName];
if (!OAuthSchemeKey){
OAuthSchemeKey = token.state;
}
@@ -339,8 +338,10 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
}
}
});
window.swaggerUi.api.clientAuthorizations.add(window.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
window.swaggerUi.load();
if(typeof window.swaggerUi !== 'undefined') {
window.swaggerUi.api.clientAuthorizations.add(window.swaggerUiAuth.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
window.swaggerUi.load();
}
}
}
}