From d61cf24ae01f59d6e7afa476e692b7af20469f68 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Mon, 16 Mar 2015 15:05:42 -0700 Subject: [PATCH] Append swagger-auth global functions to window and don't break backward --- dist/lib/swagger-oauth.js | 4 ++-- dist/swagger-ui.js | 3 ++- lib/swagger-oauth.js | 4 ++-- src/main/html/index.html | 7 +++++++ src/main/javascript/SwaggerUi.js | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dist/lib/swagger-oauth.js b/dist/lib/swagger-oauth.js index 72e649a6..01fae27f 100644 --- a/dist/lib/swagger-oauth.js +++ b/dist/lib/swagger-oauth.js @@ -202,7 +202,7 @@ function initOAuth(opts) { }); } -function processOAuthCode(data) { +window.processOAuthCode = function processOAuthCode(data) { var params = { 'client_id': clientId, 'code': data.code, @@ -225,7 +225,7 @@ function processOAuthCode(data) { }); } -function onOAuthComplete(token) { +window.onOAuthComplete = function onOAuthComplete(token) { if(token) { if(token.error) { var checkbox = $('input[type=checkbox],.secured') diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 9a7cf6bf..0ebe8737 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -201,7 +201,8 @@ window.SwaggerUi = Backbone.Router.extend({ }); -window.SwaggerUi.Views = {}; +window.SwaggerUi.Views = {}; + this["Handlebars"] = this["Handlebars"] || {}; this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {}; this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { diff --git a/lib/swagger-oauth.js b/lib/swagger-oauth.js index 72e649a6..01fae27f 100644 --- a/lib/swagger-oauth.js +++ b/lib/swagger-oauth.js @@ -202,7 +202,7 @@ function initOAuth(opts) { }); } -function processOAuthCode(data) { +window.processOAuthCode = function processOAuthCode(data) { var params = { 'client_id': clientId, 'code': data.code, @@ -225,7 +225,7 @@ function processOAuthCode(data) { }); } -function onOAuthComplete(token) { +window.onOAuthComplete = function onOAuthComplete(token) { if(token) { if(token.error) { var checkbox = $('input[type=checkbox],.secured') diff --git a/src/main/html/index.html b/src/main/html/index.html index daff2810..6cc38ff7 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -83,6 +83,13 @@ console.log.apply(console, arguments); } } + + // don't break backward compatibility with previous versions + window.authorizations = { + add: swaggerUi.api.clientAuthorizations.add + }; + window.ApiKeyAuthorization = SwaggerClient.ApiKeyAuthorization; + window.PasswordAuthorization = SwaggerClient.PasswordAuthorization; }); diff --git a/src/main/javascript/SwaggerUi.js b/src/main/javascript/SwaggerUi.js index 5fb6ad27..bea7b447 100644 --- a/src/main/javascript/SwaggerUi.js +++ b/src/main/javascript/SwaggerUi.js @@ -195,4 +195,4 @@ window.SwaggerUi = Backbone.Router.extend({ }); -window.SwaggerUi.Views = {}; \ No newline at end of file +window.SwaggerUi.Views = {};