From 7945dec86c0ee7f2ffe04642d0276bd7d48a0a52 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sat, 12 Jul 2014 20:14:38 -0700 Subject: [PATCH] updated versions, swagger-js --- dist/lib/swagger.js | 26 +++++++++++++++----------- dist/swagger-ui.js | 2 +- lib/swagger.js | 26 +++++++++++++++----------- package.json | 2 +- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/dist/lib/swagger.js b/dist/lib/swagger.js index e8ad7c13..df78db98 100644 --- a/dist/lib/swagger.js +++ b/dist/lib/swagger.js @@ -372,20 +372,24 @@ var SwaggerResource = function(resourceObj, api) { } } -SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) { - var parts, pos, url; +SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { + var pos, url; url = this.api.basePath; pos = url.lastIndexOf(relativeBasePath); - if (pos === -1) { - parts = url.split("/"); - url = parts[0] + "//" + parts[2]; + var parts = url.split("/"); + var rootUrl = parts[0] + "//" + parts[2]; + //if the relative path is '/' return the root url + if (relativeBasePath === '/'){ + return rootUrl + } + //if the relative path is not in the base path + else if (pos === -1 ) { if (relativeBasePath.indexOf("/") === 0) { return url + relativeBasePath; } else { return url + "/" + relativeBasePath; } - } else if (relativeBasePath === "/") { - return url.substring(0, pos); + //If the relative path is in the base path } else { return url.substring(0, pos) + relativeBasePath; } @@ -1271,7 +1275,7 @@ SwaggerHttp.prototype.isIE8 = function() { var JQueryHttpClient = function(options) { "use strict"; if(!jQuery){ - var jQuery = window.jQuery; + var jQuery = window.jQuery; } } @@ -1346,7 +1350,7 @@ JQueryHttpClient.prototype.execute = function(obj) { else return cb.response(out); }; - + jQuery.support.cors = true; return jQuery.ajax(obj); } @@ -1467,8 +1471,8 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { var status = null; var key; - if(typeof authorizations === 'undefined') { - // apply all keys since no authorizations hash is defined + // if the "authorizations" key is undefined, or has an empty array, add all keys + if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) { for (key in this.authz) { value = this.authz[key]; result = value.apply(obj, authorizations); diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 7fc84a4a..462ce11f 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -1,5 +1,5 @@ // swagger-ui.js -// version 2.0.17 +// version 2.0.18 $(function() { // Helper function for vertically aligning DOM elements diff --git a/lib/swagger.js b/lib/swagger.js index e8ad7c13..df78db98 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -372,20 +372,24 @@ var SwaggerResource = function(resourceObj, api) { } } -SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) { - var parts, pos, url; +SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { + var pos, url; url = this.api.basePath; pos = url.lastIndexOf(relativeBasePath); - if (pos === -1) { - parts = url.split("/"); - url = parts[0] + "//" + parts[2]; + var parts = url.split("/"); + var rootUrl = parts[0] + "//" + parts[2]; + //if the relative path is '/' return the root url + if (relativeBasePath === '/'){ + return rootUrl + } + //if the relative path is not in the base path + else if (pos === -1 ) { if (relativeBasePath.indexOf("/") === 0) { return url + relativeBasePath; } else { return url + "/" + relativeBasePath; } - } else if (relativeBasePath === "/") { - return url.substring(0, pos); + //If the relative path is in the base path } else { return url.substring(0, pos) + relativeBasePath; } @@ -1271,7 +1275,7 @@ SwaggerHttp.prototype.isIE8 = function() { var JQueryHttpClient = function(options) { "use strict"; if(!jQuery){ - var jQuery = window.jQuery; + var jQuery = window.jQuery; } } @@ -1346,7 +1350,7 @@ JQueryHttpClient.prototype.execute = function(obj) { else return cb.response(out); }; - + jQuery.support.cors = true; return jQuery.ajax(obj); } @@ -1467,8 +1471,8 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { var status = null; var key; - if(typeof authorizations === 'undefined') { - // apply all keys since no authorizations hash is defined + // if the "authorizations" key is undefined, or has an empty array, add all keys + if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) { for (key in this.authz) { value = this.authz[key]; result = value.apply(obj, authorizations); diff --git a/package.json b/package.json index e11f1706..144c30d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swagger-ui", - "version": "2.0.17", + "version": "2.0.18", "description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", "scripts": { "build": "PATH=$PATH:./node_modules/.bin cake dist",