Skip to content

Commit 7945dec

Browse files
committed
updated versions, swagger-js
1 parent 011f709 commit 7945dec

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

dist/lib/swagger.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,24 @@ var SwaggerResource = function(resourceObj, api) {
372372
}
373373
}
374374

375-
SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) {
376-
var parts, pos, url;
375+
SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
376+
var pos, url;
377377
url = this.api.basePath;
378378
pos = url.lastIndexOf(relativeBasePath);
379-
if (pos === -1) {
380-
parts = url.split("/");
381-
url = parts[0] + "//" + parts[2];
379+
var parts = url.split("/");
380+
var rootUrl = parts[0] + "//" + parts[2];
381+
//if the relative path is '/' return the root url
382+
if (relativeBasePath === '/'){
383+
return rootUrl
384+
}
385+
//if the relative path is not in the base path
386+
else if (pos === -1 ) {
382387
if (relativeBasePath.indexOf("/") === 0) {
383388
return url + relativeBasePath;
384389
} else {
385390
return url + "/" + relativeBasePath;
386391
}
387-
} else if (relativeBasePath === "/") {
388-
return url.substring(0, pos);
392+
//If the relative path is in the base path
389393
} else {
390394
return url.substring(0, pos) + relativeBasePath;
391395
}
@@ -1271,7 +1275,7 @@ SwaggerHttp.prototype.isIE8 = function() {
12711275
var JQueryHttpClient = function(options) {
12721276
"use strict";
12731277
if(!jQuery){
1274-
var jQuery = window.jQuery;
1278+
var jQuery = window.jQuery;
12751279
}
12761280
}
12771281

@@ -1346,7 +1350,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
13461350
else
13471351
return cb.response(out);
13481352
};
1349-
1353+
13501354
jQuery.support.cors = true;
13511355
return jQuery.ajax(obj);
13521356
}
@@ -1467,8 +1471,8 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
14671471
var status = null;
14681472
var key;
14691473

1470-
if(typeof authorizations === 'undefined') {
1471-
// apply all keys since no authorizations hash is defined
1474+
// if the "authorizations" key is undefined, or has an empty array, add all keys
1475+
if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
14721476
for (key in this.authz) {
14731477
value = this.authz[key];
14741478
result = value.apply(obj, authorizations);

dist/swagger-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// swagger-ui.js
2-
// version 2.0.17
2+
// version 2.0.18
33
$(function() {
44

55
// Helper function for vertically aligning DOM elements

lib/swagger.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,24 @@ var SwaggerResource = function(resourceObj, api) {
372372
}
373373
}
374374

375-
SwaggerResource.prototype.getAbsoluteBasePath = function(relativeBasePath) {
376-
var parts, pos, url;
375+
SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) {
376+
var pos, url;
377377
url = this.api.basePath;
378378
pos = url.lastIndexOf(relativeBasePath);
379-
if (pos === -1) {
380-
parts = url.split("/");
381-
url = parts[0] + "//" + parts[2];
379+
var parts = url.split("/");
380+
var rootUrl = parts[0] + "//" + parts[2];
381+
//if the relative path is '/' return the root url
382+
if (relativeBasePath === '/'){
383+
return rootUrl
384+
}
385+
//if the relative path is not in the base path
386+
else if (pos === -1 ) {
382387
if (relativeBasePath.indexOf("/") === 0) {
383388
return url + relativeBasePath;
384389
} else {
385390
return url + "/" + relativeBasePath;
386391
}
387-
} else if (relativeBasePath === "/") {
388-
return url.substring(0, pos);
392+
//If the relative path is in the base path
389393
} else {
390394
return url.substring(0, pos) + relativeBasePath;
391395
}
@@ -1271,7 +1275,7 @@ SwaggerHttp.prototype.isIE8 = function() {
12711275
var JQueryHttpClient = function(options) {
12721276
"use strict";
12731277
if(!jQuery){
1274-
var jQuery = window.jQuery;
1278+
var jQuery = window.jQuery;
12751279
}
12761280
}
12771281

@@ -1346,7 +1350,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
13461350
else
13471351
return cb.response(out);
13481352
};
1349-
1353+
13501354
jQuery.support.cors = true;
13511355
return jQuery.ajax(obj);
13521356
}
@@ -1467,8 +1471,8 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
14671471
var status = null;
14681472
var key;
14691473

1470-
if(typeof authorizations === 'undefined') {
1471-
// apply all keys since no authorizations hash is defined
1474+
// if the "authorizations" key is undefined, or has an empty array, add all keys
1475+
if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
14721476
for (key in this.authz) {
14731477
value = this.authz[key];
14741478
result = value.apply(obj, authorizations);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-ui",
3-
"version": "2.0.17",
3+
"version": "2.0.18",
44
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
55
"scripts": {
66
"build": "PATH=$PATH:./node_modules/.bin cake dist",

0 commit comments

Comments
 (0)