[auth] show securityDefinitions when clicking on authorize in header

This commit is contained in:
bodnia
2016-03-15 09:03:59 +02:00
parent 1f7dbe44c4
commit ab411cbbe0
3 changed files with 18 additions and 6 deletions

10
dist/swagger-ui.js vendored
View File

@@ -18986,6 +18986,7 @@ window.SwaggerUi = Backbone.Router.extend({
// This is bound to success handler for SwaggerApi
// so it gets called when SwaggerApi completes loading
render: function(){
var authsModel;
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
this.mainView = new SwaggerUi.Views.MainView({
model: this.api,
@@ -18993,9 +18994,14 @@ window.SwaggerUi = Backbone.Router.extend({
swaggerOptions: this.options,
router: this
}).render();
if (!_.isEmpty(this.api.security)){
if (!_.isEmpty(this.api.securityDefinitions)){
authsModel = _.map(this.api.securityDefinitions, function (auth, name) {
var result = {};
result[name] = auth;
return result;
});
this.authView = new SwaggerUi.Views.AuthButtonView({
data: SwaggerUi.utils.parseSecurityDefinitions(this.api.security),
data: SwaggerUi.utils.parseSecurityDefinitions(authsModel),
router: this
});
$('#auth_container').append(this.authView.render().el);

File diff suppressed because one or more lines are too long

View File

@@ -137,6 +137,7 @@ window.SwaggerUi = Backbone.Router.extend({
// This is bound to success handler for SwaggerApi
// so it gets called when SwaggerApi completes loading
render: function(){
var authsModel;
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
this.mainView = new SwaggerUi.Views.MainView({
model: this.api,
@@ -144,9 +145,14 @@ window.SwaggerUi = Backbone.Router.extend({
swaggerOptions: this.options,
router: this
}).render();
if (!_.isEmpty(this.api.security)){
if (!_.isEmpty(this.api.securityDefinitions)){
authsModel = _.map(this.api.securityDefinitions, function (auth, name) {
var result = {};
result[name] = auth;
return result;
});
this.authView = new SwaggerUi.Views.AuthButtonView({
data: SwaggerUi.utils.parseSecurityDefinitions(this.api.security),
data: SwaggerUi.utils.parseSecurityDefinitions(authsModel),
router: this
});
$('#auth_container').append(this.authView.render().el);