diff --git a/dist/index.html b/dist/index.html
index a6904d0f..40287021 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -38,7 +38,8 @@
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
- appName: "your-app-name"
+ appName: "your-app-name",
+ scopeSeparator: ","
});
}
diff --git a/dist/lib/swagger-oauth.js b/dist/lib/swagger-oauth.js
index fed588c6..f211ebd9 100644
--- a/dist/lib/swagger-oauth.js
+++ b/dist/lib/swagger-oauth.js
@@ -5,6 +5,7 @@ var clientId;
var realm;
var oauth2KeyName;
var redirect_uri;
+var scopeSeparator;
function handleLogin() {
var scopes = [];
@@ -151,7 +152,7 @@ function handleLogin() {
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
- url += '&scope=' + encodeURIComponent(scopes.join(' '));
+ url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator));
url += '&state=' + encodeURIComponent(state);
window.open(url);
@@ -185,6 +186,7 @@ function initOAuth(opts) {
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push('missing client id'));
realm = (o.realm||errors.push('missing realm'));
+ scopeSeparator = (o.scopeSeparator||' ');
if(errors.length > 0){
log('auth unable initialize oauth: ' + errors);
diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index cb460bbb..d0826224 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -4,7 +4,273 @@
* @link http://swagger.io
* @license Apache 2.0
*/
-(function(){this["Handlebars"] = this["Handlebars"] || {};
+(function(){'use strict';
+
+window.SwaggerUi = Backbone.Router.extend({
+
+ dom_id: 'swagger_ui',
+
+ // Attributes
+ options: null,
+ api: null,
+ headerView: null,
+ mainView: null,
+
+ // SwaggerUi accepts all the same options as SwaggerApi
+ initialize: function(options) {
+ options = options || {};
+ if(!options.highlightSizeThreshold) {
+ options.highlightSizeThreshold = 100000;
+ }
+
+ // Allow dom_id to be overridden
+ if (options.dom_id) {
+ this.dom_id = options.dom_id;
+ delete options.dom_id;
+ }
+
+ if (!options.supportedSubmitMethods){
+ options.supportedSubmitMethods = [
+ 'get',
+ 'put',
+ 'post',
+ 'delete',
+ 'head',
+ 'options',
+ 'patch'
+ ];
+ }
+
+ if (typeof options.oauth2RedirectUrl === 'string') {
+ window.oAuthRedirectUrl = options.redirectUrl;
+ }
+
+ // Create an empty div which contains the dom_id
+ if (! $('#' + this.dom_id).length){
+ $('body').append('
') ;
+ }
+
+ this.options = options;
+
+ // set marked options
+ marked.setOptions({gfm: true});
+
+ // Set the callbacks
+ var that = this;
+ this.options.success = function() { return that.render(); };
+ this.options.progress = function(d) { return that.showMessage(d); };
+ this.options.failure = function(d) { return that.onLoadFailure(d); };
+
+ // Create view to handle the header inputs
+ this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')});
+
+ // Event handler for when the baseUrl/apiKey is entered by user
+ this.headerView.on('update-swagger-ui', function(data) {
+ return that.updateSwaggerUi(data);
+ });
+ },
+
+ // Set an option after initializing
+ setOption: function(option, value) {
+ this.options[option] = value;
+ },
+
+ // Get the value of a previously set option
+ getOption: function(option) {
+ return this.options[option];
+ },
+
+ // Event handler for when url/key is received from user
+ updateSwaggerUi: function(data){
+ this.options.url = data.url;
+ this.load();
+ },
+
+ // Create an api and render
+ load: function(){
+ // Initialize the API object
+ if (this.mainView) {
+ this.mainView.clear();
+ }
+ var url = this.options.url;
+ if (url && url.indexOf('http') !== 0) {
+ url = this.buildUrl(window.location.href.toString(), url);
+ }
+ if(this.api) {
+ this.options.authorizations = this.api.clientAuthorizations.authz;
+ }
+ this.options.url = url;
+ this.headerView.update(url);
+
+ this.api = new SwaggerClient(this.options);
+ },
+
+ // collapse all sections
+ collapseAll: function(){
+ Docs.collapseEndpointListForResource('');
+ },
+
+ // list operations for all sections
+ listAll: function(){
+ Docs.collapseOperationsForResource('');
+ },
+
+ // expand operations for all sections
+ expandAll: function(){
+ Docs.expandOperationsForResource('');
+ },
+
+ // This is bound to success handler for SwaggerApi
+ // so it gets called when SwaggerApi completes loading
+ render: function(){
+ 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();
+ switch (this.options.docExpansion) {
+ case 'full':
+ this.expandAll(); break;
+ case 'list':
+ this.listAll(); break;
+ default:
+ break;
+ }
+ this.renderGFM();
+
+ if (this.options.onComplete){
+ this.options.onComplete(this.api, this);
+ }
+
+ setTimeout(Docs.shebang.bind(this), 100);
+ },
+
+ buildUrl: function(base, url){
+ if (url.indexOf('/') === 0) {
+ var parts = base.split('/');
+ base = parts[0] + '//' + parts[2];
+ return base + url;
+ } else {
+ var endOfPath = base.length;
+
+ if (base.indexOf('?') > -1){
+ endOfPath = Math.min(endOfPath, base.indexOf('?'));
+ }
+
+ if (base.indexOf('#') > -1){
+ endOfPath = Math.min(endOfPath, base.indexOf('#'));
+ }
+
+ base = base.substring(0, endOfPath);
+
+ if (base.indexOf('/', base.length - 1 ) !== -1){
+ return base + url;
+ }
+
+ return base + '/' + url;
+ }
+ },
+
+ // Shows message on topbar of the ui
+ showMessage: function(data){
+ if (data === undefined) {
+ data = '';
+ }
+ $('#message-bar').removeClass('message-fail');
+ $('#message-bar').addClass('message-success');
+ $('#message-bar').text(data);
+ },
+
+ // shows message in red
+ onLoadFailure: function(data){
+ if (data === undefined) {
+ data = '';
+ }
+ $('#message-bar').removeClass('message-success');
+ $('#message-bar').addClass('message-fail');
+
+ var val = $('#message-bar').text(data);
+
+ if (this.options.onFailure) {
+ this.options.onFailure(data);
+ }
+
+ return val;
+ },
+
+ // Renders GFM for elements with 'markdown' class
+ renderGFM: function(){
+ $('.markdown').each(function(){
+ $(this).html(marked($(this).html()));
+ });
+
+ $('.propDesc', '.model-signature .description').each(function () {
+ $(this).html(marked($(this).html())).addClass('markdown');
+ });
+ }
+
+});
+
+window.SwaggerUi.Views = {};
+
+// don't break backward compatibility with previous versions and warn users to upgrade their code
+(function(){
+ window.authorizations = {
+ add: function() {
+ warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().');
+
+ if (typeof window.swaggerUi === 'undefined') {
+ throw new TypeError('window.swaggerUi is not defined');
+ }
+
+ if (window.swaggerUi instanceof SwaggerUi) {
+ window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations, arguments);
+ }
+ }
+ };
+
+ window.ApiKeyAuthorization = function() {
+ warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.');
+ SwaggerClient.ApiKeyAuthorization.apply(window, arguments);
+ };
+
+ window.PasswordAuthorization = function() {
+ warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.');
+ SwaggerClient.PasswordAuthorization.apply(window, arguments);
+ };
+
+ function warn(message) {
+ if ('console' in window && typeof window.console.warn === 'function') {
+ console.warn(message);
+ }
+ }
+})();
+
+
+// UMD
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['b'], function (b) {
+ return (root.SwaggerUi = factory(b));
+ });
+ } else if (typeof exports === 'object') {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like enviroments that support module.exports,
+ // like Node.
+ module.exports = factory(require('b'));
+ } else {
+ // Browser globals
+ root.SwaggerUi = factory(root.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(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
@@ -484,6 +750,67 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
if (stack1 != null) { buffer += stack1; }
return buffer + " Response Body
\n \n Response Code
\n \n Response Headers
\n \n \n \n \n \n";
},"useData":true});
+this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
+ var stack1, buffer = "";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ return buffer;
+},"2":function(depth0,helpers,partials,data) {
+ var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
+ return " \n \n";
+},"4":function(depth0,helpers,partials,data) {
+ var stack1, buffer = "";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.program(7, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ return buffer;
+},"5":function(depth0,helpers,partials,data) {
+ var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
+ return " \n
\n \n";
+},"7":function(depth0,helpers,partials,data) {
+ var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
+ return " \n
\n \n";
+},"9":function(depth0,helpers,partials,data) {
+ var stack1, buffer = "";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(10, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ return buffer;
+},"10":function(depth0,helpers,partials,data) {
+ var stack1, helperMissing=helpers.helperMissing, buffer = "";
+ stack1 = ((helpers.renderTextParam || (depth0 && depth0.renderTextParam) || helperMissing).call(depth0, depth0, {"name":"renderTextParam","hash":{},"fn":this.program(11, data),"inverse":this.noop,"data":data}));
+ if (stack1 != null) { buffer += stack1; }
+ return buffer;
+},"11":function(depth0,helpers,partials,data) {
+ return "";
+},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
+ var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " | \n\n\n";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(9, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ buffer += "\n | \n";
+ stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
+ if (stack1 != null) { buffer += stack1; }
+ buffer += " | \n";
+ stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
+ if (stack1 != null) { buffer += stack1; }
+ return buffer + " | \n\n \n | \n";
+},"useData":true});
this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
return " required";
},"3":function(depth0,helpers,partials,data) {
@@ -553,43 +880,6 @@ this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":functio
if (stack1 != null) { buffer += stack1; }
return buffer + "\n | \n";
},"useData":true});
-this["Handlebars"]["templates"]["param_readonly_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return " \n";
-},"3":function(depth0,helpers,partials,data) {
- var stack1, buffer = "";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.program(6, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- return buffer;
-},"4":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return " "
- + escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
- + "\n";
-},"6":function(depth0,helpers,partials,data) {
- return " (empty)\n";
- },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
- var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " | \n\n";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(3, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- buffer += " | \n";
- stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
- if (stack1 != null) { buffer += stack1; }
- buffer += " | \n";
- stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
- if (stack1 != null) { buffer += stack1; }
- return buffer + " | \n | \n";
-},"useData":true});
this["Handlebars"]["templates"]["param_readonly"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " \n";
+},"3":function(depth0,helpers,partials,data) {
+ var stack1, buffer = "";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.program(6, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ return buffer;
+},"4":function(depth0,helpers,partials,data) {
+ var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
+ return " "
+ + escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ + "\n";
+},"6":function(depth0,helpers,partials,data) {
+ return " (empty)\n";
+ },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
+ var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " | \n\n";
+ stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(3, data),"data":data});
+ if (stack1 != null) { buffer += stack1; }
+ buffer += " | \n";
+ stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
+ if (stack1 != null) { buffer += stack1; }
+ buffer += " | \n";
+ stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
+ if (stack1 != null) { buffer += stack1; }
+ return buffer + " | \n | \n";
+},"useData":true});
this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data});
@@ -695,67 +1022,6 @@ this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":fun
if (stack1 != null) { buffer += stack1; }
return buffer + "\n | \n";
},"useData":true});
-this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
- var stack1, buffer = "";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(4, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- return buffer;
-},"2":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return " \n \n";
-},"4":function(depth0,helpers,partials,data) {
- var stack1, buffer = "";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0['default'] : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.program(7, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- return buffer;
-},"5":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return " \n
\n \n";
-},"7":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return " \n
\n \n";
-},"9":function(depth0,helpers,partials,data) {
- var stack1, buffer = "";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isFile : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.program(10, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- return buffer;
-},"10":function(depth0,helpers,partials,data) {
- var stack1, helperMissing=helpers.helperMissing, buffer = "";
- stack1 = ((helpers.renderTextParam || (depth0 && depth0.renderTextParam) || helperMissing).call(depth0, depth0, {"name":"renderTextParam","hash":{},"fn":this.program(11, data),"inverse":this.noop,"data":data}));
- if (stack1 != null) { buffer += stack1; }
- return buffer;
-},"11":function(depth0,helpers,partials,data) {
- return "";
-},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
- var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = " | \n\n\n";
- stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isBody : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.program(9, data),"data":data});
- if (stack1 != null) { buffer += stack1; }
- buffer += "\n | \n";
- stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"description","hash":{},"data":data}) : helper));
- if (stack1 != null) { buffer += stack1; }
- buffer += " | \n";
- stack1 = ((helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"paramType","hash":{},"data":data}) : helper));
- if (stack1 != null) { buffer += stack1; }
- return buffer + " | \n\n \n | \n";
-},"useData":true});
this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
var stack1, buffer = "";
stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
@@ -30575,272 +30841,6 @@ module.exports = function(arr, fn, initial){
'use strict';
-window.SwaggerUi = Backbone.Router.extend({
-
- dom_id: 'swagger_ui',
-
- // Attributes
- options: null,
- api: null,
- headerView: null,
- mainView: null,
-
- // SwaggerUi accepts all the same options as SwaggerApi
- initialize: function(options) {
- options = options || {};
- if(!options.highlightSizeThreshold) {
- options.highlightSizeThreshold = 100000;
- }
-
- // Allow dom_id to be overridden
- if (options.dom_id) {
- this.dom_id = options.dom_id;
- delete options.dom_id;
- }
-
- if (!options.supportedSubmitMethods){
- options.supportedSubmitMethods = [
- 'get',
- 'put',
- 'post',
- 'delete',
- 'head',
- 'options',
- 'patch'
- ];
- }
-
- if (typeof options.oauth2RedirectUrl === 'string') {
- window.oAuthRedirectUrl = options.redirectUrl;
- }
-
- // Create an empty div which contains the dom_id
- if (! $('#' + this.dom_id).length){
- $('body').append('') ;
- }
-
- this.options = options;
-
- // set marked options
- marked.setOptions({gfm: true});
-
- // Set the callbacks
- var that = this;
- this.options.success = function() { return that.render(); };
- this.options.progress = function(d) { return that.showMessage(d); };
- this.options.failure = function(d) { return that.onLoadFailure(d); };
-
- // Create view to handle the header inputs
- this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')});
-
- // Event handler for when the baseUrl/apiKey is entered by user
- this.headerView.on('update-swagger-ui', function(data) {
- return that.updateSwaggerUi(data);
- });
- },
-
- // Set an option after initializing
- setOption: function(option, value) {
- this.options[option] = value;
- },
-
- // Get the value of a previously set option
- getOption: function(option) {
- return this.options[option];
- },
-
- // Event handler for when url/key is received from user
- updateSwaggerUi: function(data){
- this.options.url = data.url;
- this.load();
- },
-
- // Create an api and render
- load: function(){
- // Initialize the API object
- if (this.mainView) {
- this.mainView.clear();
- }
- var url = this.options.url;
- if (url && url.indexOf('http') !== 0) {
- url = this.buildUrl(window.location.href.toString(), url);
- }
- if(this.api) {
- this.options.authorizations = this.api.clientAuthorizations.authz;
- }
- this.options.url = url;
- this.headerView.update(url);
-
- this.api = new SwaggerClient(this.options);
- },
-
- // collapse all sections
- collapseAll: function(){
- Docs.collapseEndpointListForResource('');
- },
-
- // list operations for all sections
- listAll: function(){
- Docs.collapseOperationsForResource('');
- },
-
- // expand operations for all sections
- expandAll: function(){
- Docs.expandOperationsForResource('');
- },
-
- // This is bound to success handler for SwaggerApi
- // so it gets called when SwaggerApi completes loading
- render: function(){
- 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();
- switch (this.options.docExpansion) {
- case 'full':
- this.expandAll(); break;
- case 'list':
- this.listAll(); break;
- default:
- break;
- }
- this.renderGFM();
-
- if (this.options.onComplete){
- this.options.onComplete(this.api, this);
- }
-
- setTimeout(Docs.shebang.bind(this), 100);
- },
-
- buildUrl: function(base, url){
- if (url.indexOf('/') === 0) {
- var parts = base.split('/');
- base = parts[0] + '//' + parts[2];
- return base + url;
- } else {
- var endOfPath = base.length;
-
- if (base.indexOf('?') > -1){
- endOfPath = Math.min(endOfPath, base.indexOf('?'));
- }
-
- if (base.indexOf('#') > -1){
- endOfPath = Math.min(endOfPath, base.indexOf('#'));
- }
-
- base = base.substring(0, endOfPath);
-
- if (base.indexOf('/', base.length - 1 ) !== -1){
- return base + url;
- }
-
- return base + '/' + url;
- }
- },
-
- // Shows message on topbar of the ui
- showMessage: function(data){
- if (data === undefined) {
- data = '';
- }
- $('#message-bar').removeClass('message-fail');
- $('#message-bar').addClass('message-success');
- $('#message-bar').text(data);
- },
-
- // shows message in red
- onLoadFailure: function(data){
- if (data === undefined) {
- data = '';
- }
- $('#message-bar').removeClass('message-success');
- $('#message-bar').addClass('message-fail');
-
- var val = $('#message-bar').text(data);
-
- if (this.options.onFailure) {
- this.options.onFailure(data);
- }
-
- return val;
- },
-
- // Renders GFM for elements with 'markdown' class
- renderGFM: function(){
- $('.markdown').each(function(){
- $(this).html(marked($(this).html()));
- });
-
- $('.propDesc', '.model-signature .description').each(function () {
- $(this).html(marked($(this).html())).addClass('markdown');
- });
- }
-
-});
-
-window.SwaggerUi.Views = {};
-
-// don't break backward compatibility with previous versions and warn users to upgrade their code
-(function(){
- window.authorizations = {
- add: function() {
- warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().');
-
- if (typeof window.swaggerUi === 'undefined') {
- throw new TypeError('window.swaggerUi is not defined');
- }
-
- if (window.swaggerUi instanceof SwaggerUi) {
- window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations, arguments);
- }
- }
- };
-
- window.ApiKeyAuthorization = function() {
- warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.');
- SwaggerClient.ApiKeyAuthorization.apply(window, arguments);
- };
-
- window.PasswordAuthorization = function() {
- warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.');
- SwaggerClient.PasswordAuthorization.apply(window, arguments);
- };
-
- function warn(message) {
- if ('console' in window && typeof window.console.warn === 'function') {
- console.warn(message);
- }
- }
-})();
-
-
-// UMD
-(function (root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['b'], function (b) {
- return (root.SwaggerUi = factory(b));
- });
- } else if (typeof exports === 'object') {
- // Node. Does not work with strict CommonJS, but
- // only CommonJS-like enviroments that support module.exports,
- // like Node.
- module.exports = factory(require('b'));
- } else {
- // Browser globals
- root.SwaggerUi = factory(root.b);
- }
-}(this, function () {
- return SwaggerUi;
-}));
-
-'use strict';
-
SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to global SwaggerUi
events:{
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index 6602cb58..c53e964a 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1,16 +1,15 @@
-(function(){function e(){e.history=e.history||[],e.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments)[0])}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,t,n,r){var i,a="function",o=t.helperMissing,s=this.escapeExpression;return"\n\n\n"},useData:!0}),this.Handlebars.templates.basic_auth_button_view=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,r){return'\n\n\n'},useData:!0}),this.Handlebars.templates.content_type=Handlebars.template({1:function(e,t,n,r){var i,a="";return i=t.each.call(e,null!=e?e.produces:e,{name:"each",hash:{},fn:this.program(2,r),inverse:this.noop,data:r}),null!=i&&(a+=i),a},2:function(e,t,n,r){var i,a=this.lambda,o=' \n"},4:function(e,t,n,r){return' \n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,r){var i,a,o="function",s=t.helperMissing,l=this.escapeExpression,u='\n\n"},useData:!0}),$(function(){$.fn.vAlign=function(){return this.each(function(){var e=$(this).height(),t=$(this).parent().height(),n=(t-e)/2;$(this).css("margin-top",n)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(){var e=$(this).closest("form").innerWidth(),t=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),n=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",e-t-n)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),""===$(this).val()&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),Function.prototype.bind&&console&&"object"==typeof console.log&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call),window.Docs={shebang:function(){var e=$.param.fragment().split("/");switch(e.shift(),e.length){case 1:if(e[0].length>0){var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1})}break;case 2:Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),r=n+"_content";Docs.expandOperation($("#"+r)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?Docs.collapseEndpointListForResource(e):Docs.expandEndpointListForResource(e)},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideDown();$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideUp();$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideDown():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideUp():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}},Handlebars.registerHelper("sanitize",function(e){return e=e.replace(/