[auth] moved authorizations into the header
This commit is contained in:
@@ -102,6 +102,10 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
if (this.mainView) {
|
||||
this.mainView.clear();
|
||||
}
|
||||
|
||||
if (this.authView) {
|
||||
this.authView.remove();
|
||||
}
|
||||
var url = this.options.url;
|
||||
if (url && url.indexOf('http') !== 0) {
|
||||
url = this.buildUrl(window.location.href.toString(), url);
|
||||
@@ -133,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,
|
||||
@@ -140,6 +145,20 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
swaggerOptions: this.options,
|
||||
router: this
|
||||
}).render();
|
||||
if (!_.isEmpty(this.api.securityDefinitions)){
|
||||
authsModel = {
|
||||
auths: _.map(this.api.securityDefinitions, function (auth, name) {
|
||||
var result = {};
|
||||
result[name] = auth;
|
||||
return result;
|
||||
})
|
||||
};
|
||||
this.authView = new SwaggerUi.Views.AuthButtonView({
|
||||
model: authsModel,
|
||||
router: this
|
||||
});
|
||||
$('#auth_container').append(this.authView.render().el);
|
||||
}
|
||||
this.showMessage();
|
||||
switch (this.options.docExpansion) {
|
||||
case 'full':
|
||||
|
||||
Reference in New Issue
Block a user