diff --git a/dist/css/print.css b/dist/css/print.css
index 6d8044f3..32bf0c86 100644
--- a/dist/css/print.css
+++ b/dist/css/print.css
@@ -1193,6 +1193,25 @@
text-decoration: underline;
cursor: pointer;
}
+.swagger-section .authorize__btn_operation:hover .authorize-scopes {
+ display: block;
+}
+.swagger-section .authorize-scopes {
+ position: absolute;
+ margin-top: 20px;
+ background: #FFF;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ max-width: 300px;
+ line-height: 30px;
+ color: black;
+ padding: 5px;
+}
+.swagger-section .authorize-scopes .authorize__scope {
+ text-decoration: none;
+}
.swagger-section .authorize__btn_operation {
height: 18px;
vertical-align: middle;
diff --git a/dist/css/screen.css b/dist/css/screen.css
index 68d6510e..90a93a2d 100644
--- a/dist/css/screen.css
+++ b/dist/css/screen.css
@@ -1193,6 +1193,25 @@
text-decoration: underline;
cursor: pointer;
}
+.swagger-section .authorize__btn_operation:hover .authorize-scopes {
+ display: block;
+}
+.swagger-section .authorize-scopes {
+ position: absolute;
+ margin-top: 20px;
+ background: #FFF;
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ display: none;
+ font-size: 13px;
+ max-width: 300px;
+ line-height: 30px;
+ color: black;
+ padding: 5px;
+}
+.swagger-section .authorize-scopes .authorize__scope {
+ text-decoration: none;
+}
.swagger-section .authorize__btn_operation {
height: 18px;
vertical-align: middle;
@@ -1463,3 +1482,7 @@
.swagger-section .swagger-expand:before {
content: "+";
}
+.swagger-section .error {
+ outline-color: #cc0000;
+ background-color: #f2dede;
+}
diff --git a/dist/lib/swagger-oauth.js b/dist/lib/swagger-oauth.js
index 486533b8..2bb6be11 100644
--- a/dist/lib/swagger-oauth.js
+++ b/dist/lib/swagger-oauth.js
@@ -332,6 +332,7 @@ window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
}
});
window.swaggerUi.api.clientAuthorizations.add(window.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
+ window.swaggerUi.load();
}
}
}
diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index c90e9592..7e97557b 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -29,11 +29,26 @@ this["Handlebars"]["templates"]["auth_button_operation"] = Handlebars.template({
return " authorize__btn_operation_login\n";
},"3":function(depth0,helpers,partials,data) {
return " authorize__btn_operation_logout\n";
- },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
+ },"5":function(depth0,helpers,partials,data) {
+ var stack1, buffer = "
');
+ this.authViews = [];
},
render: function () {
@@ -19456,22 +19489,30 @@ SwaggerUi.Views.AuthsCollectionView = Backbone.View.extend({
},
renderOneAuth: function (authModel) {
- var authEl, authView;
+ var authViewEl, authView, authViewName;
var type = authModel.get('type');
if (type === 'apiKey') {
- authView = 'ApiKeyAuthView';
+ authViewName = 'ApiKeyAuthView';
} else if (type === 'basic' && this.$innerEl.find('.basic_auth_container').length === 0) {
- authView = 'BasicAuthView';
+ authViewName = 'BasicAuthView';
} else if (type === 'oauth2') {
- authView = 'Oauth2View';
+ authViewName = 'Oauth2View';
}
- if (authView) {
- authEl = new SwaggerUi.Views[authView]({model: authModel, router: this.router}).render().el;
+ if (authViewName) {
+ authView = new SwaggerUi.Views[authViewName]({model: authModel, router: this.router});
+ authViewEl = authView.render().el;
+ this.authViews.push(authView);
}
- this.$innerEl.append(authEl);
+ this.$innerEl.append(authViewEl);
+ },
+
+ highlightInvalid: function () {
+ this.authViews.forEach(function (view) {
+ view.highlightInvalid();
+ }, this);
}
});
@@ -19529,6 +19570,8 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
if (this.authsCollectionView.collection.isValid()) {
this.authorize();
+ } else {
+ this.authsCollectionView.highlightInvalid();
}
},
@@ -19689,6 +19732,15 @@ SwaggerUi.Views.BasicAuthView = Backbone.View.extend({
'change .auth_input': 'inputChange'
},
+ selectors: {
+ usernameInput: '.basic_auth__username',
+ passwordInput: '.basic_auth__password'
+ },
+
+ cls: {
+ error: 'error'
+ },
+
template: Handlebars.templates.basic_auth,
render: function(){
@@ -19702,13 +19754,26 @@ SwaggerUi.Views.BasicAuthView = Backbone.View.extend({
var val = $el.val();
var attr = $el.prop('name');
+ if (val) {
+ $el.removeClass(this.cls.error);
+ }
+
this.model.set(attr, val);
},
isValid: function () {
return this.model.validate();
- }
+ },
+ highlightInvalid: function () {
+ if (!this.model.get('username')) {
+ this.$(this.selectors.usernameInput).addClass(this.cls.error);
+ }
+
+ if (!this.model.get('password')) {
+ this.$(this.selectors.passwordInput).addClass(this.cls.error);
+ }
+ }
});
'use strict';
@@ -20232,7 +20297,14 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
var authsModel = SwaggerUi.utils.parseSecurityDefinitions(this.model.security);
authsModel.isLogout = !_.isEmpty(window.swaggerUi.api.clientAuthorizations.authz);
- this.authView = new SwaggerUi.Views.AuthButtonView({data: authsModel, router: this.router, isOperation: true});
+ this.authView = new SwaggerUi.Views.AuthButtonView({
+ data: authsModel,
+ router: this.router,
+ isOperation: true,
+ model: {
+ scopes: authsModel.scopes
+ }
+ });
this.$('.authorize-wrapper').append(this.authView.render().el);
}
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index eb18ee3c..57b9213a 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(/