Found a bug in OperationView.js which caused the oAuth toggle to be displayed for non-oAuth endpoints if oAuth was enabled at all, fixed it

This commit is contained in:
Robert Brownstein
2015-06-19 13:37:54 -04:00
parent d75505fb73
commit 128fc5c112

View File

@@ -95,22 +95,23 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
for (l = 0, len = modelAuths.length; l < len; l++) { for (l = 0, len = modelAuths.length; l < len; l++) {
auths = modelAuths[l]; auths = modelAuths[l];
for (key in auths) { for (key in auths) {
auth = auths[key];
for (a in this.auths) { for (a in this.auths) {
auth = this.auths[a]; auth = this.auths[a];
if (auth.type === 'oauth2') { if (key === auth.name) {
this.model.oauth = {}; if (auth.type === 'oauth2') {
this.model.oauth.scopes = []; this.model.oauth = {};
ref1 = auth.value.scopes; this.model.oauth.scopes = [];
for (k in ref1) { ref1 = auth.value.scopes;
v = ref1[k]; for (k in ref1) {
scopeIndex = auths[key].indexOf(k); v = ref1[k];
if (scopeIndex >= 0) { scopeIndex = auths[key].indexOf(k);
o = { if (scopeIndex >= 0) {
scope: k, o = {
description: v scope: k,
}; description: v
this.model.oauth.scopes.push(o); };
this.model.oauth.scopes.push(o);
}
} }
} }
} }