diff --git a/dist/index.html b/dist/index.html index 6f966cc9..9163833d 100644 --- a/dist/index.html +++ b/dist/index.html @@ -25,7 +25,7 @@ diff --git a/dist/lib/shred.bundle.js b/dist/lib/shred.bundle.js index 74d08168..eed2126b 100644 --- a/dist/lib/shred.bundle.js +++ b/dist/lib/shred.bundle.js @@ -2131,10 +2131,12 @@ require.define("/shred/mixins/headers.js", function (require, module, exports, _ // to `Content-Type`. var corsetCase = function(string) { - return string.toLowerCase() + return string; +/* return string.toLowerCase() //.replace("_","-") .replace(/(^|-)(\w)/g, function(s) { return s.toUpperCase(); }); +*/ }; // We suspect that `initializeHeaders` was once more complicated ... diff --git a/dist/lib/swagger.js b/dist/lib/swagger.js index 17a77a73..489e9d9a 100644 --- a/dist/lib/swagger.js +++ b/dist/lib/swagger.js @@ -432,6 +432,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, output = []; for (var i = 0; i < ops.length; i++) { o = ops[i]; + consumes = this.consumes; produces = this.produces; if (o.consumes != null) @@ -674,6 +675,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not this.resource = (resource||errors.push("Resource is required")); this.consumes = consumes; this.produces = produces; + this.authorizations = authorizations; this["do"] = __bind(this["do"], this); @@ -1203,7 +1205,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal } else { e = exports; } - status = e.authorizations.apply(obj, this.operation.authorizations); + status = e.authorizations.apply(obj, this.operation); if (opts.mock == null) { if (status !== false) { new SwaggerHttp().execute(obj); @@ -1440,16 +1442,32 @@ SwaggerAuthorizations.prototype.remove = function(name) { return delete this.authz[name]; }; -SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { +SwaggerAuthorizations.prototype.apply = function(obj, operation) { status = null; var key; for (key in this.authz) { + var authorizations = (operation||{}).authorizations + var applyAuth = false; + if(operation) { + if(!operation.authorizations) + applyAuth = true; + else if(typeof authorizations[key] !== 'undefined') + applyAuth = true; + } + else { + applyAuth = true; + } + value = this.authz[key]; - result = value.apply(obj, authorizations); - if (result === false) - status = false; - if (result === true) - status = true; + if(applyAuth) { + console.log('applying auth ' + key); + result = value.apply(obj, authorizations); + if (result === false) + status = false; + if (result === true) + status = true; + } + else status = false; } return status; }; @@ -1463,7 +1481,7 @@ var ApiKeyAuthorization = function(name, value, type) { this.type = type; }; -ApiKeyAuthorization.prototype.apply = function(obj, authorizations) { +ApiKeyAuthorization.prototype.apply = function(obj, operation) { if (this.type === "query") { if (obj.url.indexOf('?') > 0) obj.url = obj.url + "&" + this.name + "=" + this.value; @@ -1480,7 +1498,7 @@ var CookieAuthorization = function(cookie) { this.cookie = cookie; } -CookieAuthorization.prototype.apply = function(obj, authorizations) { +CookieAuthorization.prototype.apply = function(obj, operation) { obj.cookieJar = obj.cookieJar || CookieJar(); obj.cookieJar.setCookie(this.cookie); return true; @@ -1500,7 +1518,7 @@ var PasswordAuthorization = function(name, username, password) { this._btoa = require("btoa"); }; -PasswordAuthorization.prototype.apply = function(obj, authorizations) { +PasswordAuthorization.prototype.apply = function(obj, operation) { var base64encoder = this._btoa; obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password); return true; diff --git a/src/main/html/index.html b/src/main/html/index.html index 6f966cc9..5af095a0 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -2,7 +2,7 @@ Swagger UI - +