diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index cd053a37..14368b2d 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -19242,7 +19242,7 @@ SwaggerUi.Models.ApiKeyAuthModel = Backbone.Model.extend({
SwaggerUi.Views.ApiKeyAuthView = Backbone.View.extend({ // TODO: append this to global SwaggerUi
events: {
- 'change .auth_input': 'apiKeyChange'
+ 'change .input_apiKey_entry': 'apiKeyChange'
},
template: Handlebars.templates.apikey_auth,
@@ -19365,7 +19365,15 @@ SwaggerUi.Collections.AuthsCollection = Backbone.Collection.extend({
},
isValid: function () {
- return this.length === this.where({ valid: true }).length;
+ var valid = true;
+
+ this.models.forEach(function(model) {
+ if (!model.validate()) {
+ valid = false;
+ }
+ });
+
+ return valid;
},
isAuthorized: function () {
@@ -19378,6 +19386,74 @@ SwaggerUi.Collections.AuthsCollection = Backbone.Collection.extend({
});
'use strict';
+SwaggerUi.Views.AuthsCollectionView = Backbone.View.extend({
+
+ initialize: function(opts) {
+ this.options = opts || {};
+ this.options.data = this.options.data || {};
+ this.router = this.options.router;
+
+ this.collection = new SwaggerUi.Collections.AuthsCollection();
+ this.collection.add(this.parseData(opts.data));
+
+ this.$innerEl = $('
');
+ },
+
+ render: function () {
+ this.collection.each(function (auth) {
+ this.renderOneAuth(auth);
+ }, this);
+
+ this.$el.html(this.$innerEl.html() ? this.$innerEl : '');
+
+ return this;
+ },
+
+ renderOneAuth: function (authModel) {
+ var authEl;
+ var type = authModel.get('type');
+
+ //todo refactor move view name into var and call new with it.
+ if (type === 'apiKey') {
+ authEl = new SwaggerUi.Views.ApiKeyAuthView({model: authModel, router: this.router}).render().el;
+ } else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
+ authEl = new SwaggerUi.Views.BasicAuthView({model: authModel, router: this.router}).render().el;
+ } else if (type === 'oauth2') {
+ authEl = new SwaggerUi.Views.Oauth2View({model: authModel, router: this.router}).render().el;
+ }
+
+ this.$innerEl.append(authEl);
+ },
+
+ //todo move into collection
+ parseData: function (data) {
+ var authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
+
+ return _.map(data, function (auth, name) {
+ var isBasic = authz.basic && auth.type === 'basic';
+
+ _.extend(auth, {
+ title: name
+ });
+
+ if (authz[name] || isBasic) {
+ _.extend(auth, {
+ isLogout: true,
+ value: isBasic ? undefined : authz[name].value,
+ username: isBasic ? authz.basic.username : undefined,
+ password: isBasic ? authz.basic.password : undefined,
+ valid: true
+ });
+ }
+
+ return auth;
+ });
+ }
+
+});
+
+'use strict';
+
/* global OAuthSchemeKeys */
/* global redirect_uri */
/* global clientId */
@@ -19400,7 +19476,8 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
},
selectors: {
- innerEl: '.auth_inner'
+ innerEl: '.auth_inner',
+ authBtn: '.auth_submit__button'
},
initialize: function(opts) {
@@ -19408,22 +19485,17 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
opts.data = opts.data || {};
this.router = this.options.router;
- this.collection = new SwaggerUi.Collections.AuthsCollection();
- this.collection.add(this.parseData(opts.data));
+ this.authsCollectionView = new SwaggerUi.Views.AuthsCollectionView({data: opts.data});
this.$el.html(this.tpls.main({
- isLogout: this.collection.isAuthorized(),
- isAuthorized: this.collection.isPartiallyAuthorized()
+ isLogout: this.authsCollectionView.collection.isAuthorized(),
+ isAuthorized: this.authsCollectionView.collection.isPartiallyAuthorized()
}));
this.$innerEl = this.$(this.selectors.innerEl);
},
render: function () {
- this.renderAuths();
-
- if (!this.$innerEl.html()) {
- this.$el.html('');
- }
+ this.$innerEl.html(this.authsCollectionView.render().el);
return this;
},
@@ -19432,59 +19504,13 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
e.preventDefault();
e.stopPropagation();
- if (this.collection.isValid()) {
+ if (this.authsCollectionView.collection.isValid()) {
this.authorize();
}
},
- parseData: function (data) {
- var authz = Object.assign({}, window.swaggerUi.api.clientAuthorizations.authz);
-
- return _.map(data, function (auth, name) {
- var isBasic = authz.basic && auth.type === 'basic';
-
- _.extend(auth, {
- title: name
- });
-
- if (authz[name] || isBasic) {
- _.extend(auth, {
- isLogout: true,
- value: isBasic ? undefined : authz[name].value,
- username: isBasic ? authz.basic.username : undefined,
- password: isBasic ? authz.basic.password : undefined,
- valid: true
- });
- }
-
- return auth;
- });
- },
-
- renderAuths: function () {
- this.collection.each(function (auth) {
- this.renderOneAuth(auth);
- }, this);
- },
-
- renderOneAuth: function (authModel) {
- var authEl;
- var type = authModel.get('type');
-
- //todo refactor move view name into var and call new with it.
- if (type === 'apiKey') {
- authEl = new SwaggerUi.Views.ApiKeyAuthView({model: authModel, router: this.router}).render().el;
- } else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
- authEl = new SwaggerUi.Views.BasicAuthView({model: authModel, router: this.router}).render().el;
- } else if (type === 'oauth2') {
- authEl = new SwaggerUi.Views.Oauth2View({model: authModel, router: this.router}).render().el;
- }
-
- this.$innerEl.append(authEl);
- },
-
authorize: function () {
- this.collection.forEach(function (auth) {
+ this.authsCollectionView.collection.forEach(function (auth) {
var keyAuth, basicAuth;
var type = auth.get('type');
@@ -19510,7 +19536,7 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
logoutClick: function (e) {
e.preventDefault();
- this.collection.forEach(function (auth) {
+ this.authsCollectionView.collection.forEach(function (auth) {
var name = auth.get('type') === 'basic' ? 'basic' : auth.get('title');
window.swaggerUi.api.clientAuthorizations.remove(name);
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index 36b5d9a3..da9ec589 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1,9 +1,9 @@
(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_auth=Handlebars.template({1:function(e,t,n,i){var r,a="function",o=t.helperMissing,s=this.escapeExpression;return'
'+s((r=null!=(r=t.value||(null!=e?e.value:e))?r:o,typeof r===a?r.call(e,{name:"value",hash:{},data:i}):r))+"\n"},3:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a,o="function",s=t.helperMissing,l=this.escapeExpression,u='
\n"},useData:!0}),this.Handlebars.templates.auth_button_operation=Handlebars.template({1:function(e,t,n,i){return" authorize__btn_operation_login\n"},3:function(e,t,n,i){return" authorize__btn_operation_logout\n"},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a='
\n
\n'},useData:!0}),this.Handlebars.templates.auth_button=Handlebars.template({compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){return"
Authorize\n"},useData:!0}),this.Handlebars.templates.auth_view=Handlebars.template({1:function(e,t,n,i){return'
\n'},3:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a='
\n\n
\n
\n';return r=t.unless.call(e,null!=e?e.isLogout:e,{name:"unless",hash:{},fn:this.program(1,i),inverse:this.noop,data:i}),null!=r&&(a+=r),r=t["if"].call(e,null!=e?e.isAuthorized:e,{name:"if",hash:{},fn:this.program(3,i),inverse:this.noop,data:i}),null!=r&&(a+=r),a+"
\n\n
\n"},useData:!0}),this.Handlebars.templates.basic_auth=Handlebars.template({1:function(e,t,n,i){return" - authorized"},3:function(e,t,n,i){var r,a="function",o=t.helperMissing,s=this.escapeExpression;return'
'+s((r=null!=(r=t.username||(null!=e?e.username:e))?r:o,typeof r===a?r.call(e,{name:"username",hash:{},data:i}):r))+"\n"},5:function(e,t,n,i){return'
\n'},7:function(e,t,n,i){return'
\n password:\n \n
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,a,o="function",s=t.helperMissing,l=this.escapeExpression,u="
\n
Basic authentication";return r=t["if"].call(e,null!=e?e.isLogout:e,{name:"if",hash:{},fn:this.program(1,i),inverse:this.noop,data:i}),null!=r&&(u+=r),u+='
\n
\n
\n"},useData:!0}),this.Handlebars.templates.content_type=Handlebars.template({1:function(e,t,n,i){var r,a="";return r=t.each.call(e,null!=e?e.produces:e,{name:"each",hash:{},fn:this.program(2,i),inverse:this.noop,data:i}),null!=r&&(a+=r),a},2:function(e,t,n,i){var r=this.lambda,a=this.escapeExpression;return'
\n"},4:function(e,t,n,i){return'
\n'},compiler:[6,">= 2.0.0-beta.1"],main:function(e,t,n,i){var r,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("_"),i=n+"_content";Docs.expandOperation($("#"+i)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?($.bbq.pushState("#/",2),Docs.collapseEndpointListForResource(e)):($.bbq.pushState("#/"+e,2),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(/