diff --git a/README.md b/README.md index cd62fc8edba..c8fac273209 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ onComplete | This is a callback function parameter which can be passed to be not onFailure | This is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render. highlightSizeThreshold | Any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses. supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!` option. An empty array disables all operations. This does not filter the operations from the display. +redirectUrl | OAuth redirect URL * All other parameters are explained in greater detail below diff --git a/dist/lib/swagger-oauth.js b/dist/lib/swagger-oauth.js index 01fae27f9be..b2254b7f529 100644 --- a/dist/lib/swagger-oauth.js +++ b/dist/lib/swagger-oauth.js @@ -97,7 +97,8 @@ function handleLogin() { var authSchemes = window.swaggerUi.api.authSchemes; var host = window.location; var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); - var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; + var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; + var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; var url = null; for (var key in authSchemes) { diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 20cc321b737..aaf793dc649 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -38,6 +38,10 @@ window.SwaggerUi = Backbone.Router.extend({ ]; } + if (typeof options.redirectUrl === 'string') { + window.oAuthRedirectUrl = options.redirectUrl; + } + // Create an empty div which contains the dom_id if (! $('#' + this.dom_id).length){ $('body').append('
') ; diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js index 008c1e90985..82388d36ec6 100644 --- a/dist/swagger-ui.min.js +++ b/dist/swagger-ui.min.js @@ -1,2 +1,2 @@ -(function(){"use strict";window.SwaggerUi=Backbone.Router.extend({dom_id:"swagger_ui",options:null,api:null,headerView:null,mainView:null,initialize:function(e){e=e||{},e.dom_id&&(this.dom_id=e.dom_id,delete e.dom_id),e.supportedSubmitMethods||(e.supportedSubmitMethods=["get","put","post","delete","head","options","patch"]),$("#"+this.dom_id).length||$("body").append(''),this.options=e,marked.setOptions({gfm:!0});var n=this;this.options.success=function(){return n.render()},this.options.progress=function(e){return n.showMessage(e)},this.options.failure=function(e){return n.onLoadFailure(e)},this.headerView=new SwaggerUi.Views.HeaderView({el:$("#header")}),this.headerView.on("update-swagger-ui",function(e){return n.updateSwaggerUi(e)})},setOption:function(e,n){this.options[e]=n},getOption:function(e){return this.options[e]},updateSwaggerUi:function(e){this.options.url=e.url,this.load()},load:function(){this.mainView&&this.mainView.clear();var e=this.options.url;e&&0!==e.indexOf("http")&&(e=this.buildUrl(window.location.href.toString(),e)),this.options.url=e,this.headerView.update(e),this.api=new SwaggerClient(this.options)},collapseAll:function(){Docs.collapseEndpointListForResource("")},listAll:function(){Docs.collapseOperationsForResource("")},expandAll:function(){Docs.expandOperationsForResource("")},render:function(){switch(this.showMessage("Finished Loading Resource Information. Rendering Swagger UI..."),this.mainView=new SwaggerUi.Views.MainView({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options,router:this}).render(),this.showMessage(),this.options.docExpansion){case"full":this.expandAll();break;case"list":this.listAll()}this.renderGFM(),this.options.onComplete&&this.options.onComplete(this.api,this),setTimeout(Docs.shebang.bind(this),100)},buildUrl:function(e,n){if(0===n.indexOf("/")){var t=e.split("/");return e=t[0]+"//"+t[2],e+n}var a=e.length;return e.indexOf("?")>-1&&(a=Math.min(a,e.indexOf("?"))),e.indexOf("#")>-1&&(a=Math.min(a,e.indexOf("#"))),e=e.substring(0,a),-1!==e.indexOf("/",e.length-1)?e+n:e+"/"+n},showMessage:function(e){void 0===e&&(e=""),$("#message-bar").removeClass("message-fail"),$("#message-bar").addClass("message-success"),$("#message-bar").html(e)},onLoadFailure:function(e){void 0===e&&(e=""),$("#message-bar").removeClass("message-success"),$("#message-bar").addClass("message-fail");var n=$("#message-bar").html(e);return this.options.onFailure&&this.options.onFailure(e),n},renderGFM:function(){$(".markdown").each(function(){$(this).html(marked($(this).html()))})}}),window.SwaggerUi.Views={},function(){function e(e){"console"in window&&"function"==typeof window.console.warn&&console.warn(e)}window.authorizations={add:function(){if(e("Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add()."),"undefined"==typeof window.swaggerUi)throw new TypeError("window.swaggerUi is not defined");window.swaggerUi instanceof SwaggerUi&&window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations,arguments)}},window.ApiKeyAuthorization=function(){e("window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization."),SwaggerClient.ApiKeyAuthorization.apply(window,arguments)},window.PasswordAuthorization=function(){e("window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization."),SwaggerClient.PasswordAuthorization.apply(window,arguments)}}(),function(e,n){"function"==typeof define&&define.amd?define(["b"],function(t){return e.SwaggerUi=n(t)}):"object"==typeof exports?module.exports=n(require("b")):e.SwaggerUi=n(e.b)}(this,function(){return SwaggerUi}),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(e,n,t,a){var i,s="function",l=n.helperMissing,r=this.escapeExpression;return"\n