swagger-client
Advanced tools
Comparing version 2.1.15 to 2.1.16
@@ -126,5 +126,5 @@ 'use strict'; | ||
if(this.url && this.url.indexOf('http') === -1) { | ||
if(this.url && this.url.indexOf('http:') === -1 && this.url.indexOf('https:') === -1) { | ||
// no protocol, so we can only use window if it exists | ||
if(window && window.location) { | ||
if(typeof(window) !== 'undefined' && window && window.location) { | ||
this.url = window.location.origin + this.url; | ||
@@ -187,3 +187,7 @@ } | ||
this.progress('fetching resource list: ' + this.url + '; Please wait.'); | ||
if (this.spec) { | ||
this.progress('fetching resource list; Please wait.'); | ||
} else { | ||
this.progress('fetching resource list: ' + this.url + '; Please wait.'); | ||
} | ||
@@ -190,0 +194,0 @@ var obj = { |
@@ -7,3 +7,4 @@ 'use strict'; | ||
cloneDeep: require('lodash-compat/lang/cloneDeep'), | ||
isArray: require('lodash-compat/lang/isArray') | ||
isArray: require('lodash-compat/lang/isArray'), | ||
isString: require('lodash-compat/lang/isString') | ||
}; | ||
@@ -263,3 +264,3 @@ | ||
if(parts.length === 2) { | ||
if(parts[0].indexOf('http://') === 0 || parts[0].indexOf('https://') === 0) { | ||
if(parts[0].indexOf('http:') === 0 || parts[0].indexOf('https:') === 0) { | ||
a.root = parts[0]; | ||
@@ -445,3 +446,4 @@ } | ||
for (key in resolvedTo.obj) { | ||
var abs = this.retainRoot(resolvedTo.obj[key], item.root); | ||
var abs = this.retainRoot(key, resolvedTo.obj[key], item.root); | ||
resolvedTo.obj[key] = abs; | ||
} | ||
@@ -461,3 +463,3 @@ } | ||
// don't retain root for local definitions | ||
abs = this.retainRoot(resolvedTo.obj[key], item.root); | ||
abs = this.retainRoot(key, resolvedTo.obj[key], item.root); | ||
} | ||
@@ -536,34 +538,42 @@ targetObj[key] = abs; | ||
Resolver.prototype.retainRoot = function(obj, root) { | ||
Resolver.prototype.retainRoot = function(origKey, obj, root) { | ||
// walk object and look for relative $refs | ||
for(var key in obj) { | ||
var item = obj[key]; | ||
if(key === '$ref' && typeof item === 'string') { | ||
// stop and inspect | ||
if(item.indexOf('http://') !== 0 && item.indexOf('https://') !== 0) { | ||
// TODO: check if root ends in '/'. If not, AND item has no protocol, make relative | ||
var appendHash = true; | ||
var oldRoot = root; | ||
if(root) { | ||
var lastChar = root.slice(-1); | ||
if(lastChar !== '/' && (item.indexOf('#') !== 0 && item.indexOf('http://') !== 0 && item.indexOf('https://'))) { | ||
appendHash = false; | ||
var parts = root.split('\/'); | ||
parts = parts.splice(0, parts.length - 1); | ||
root = ''; | ||
for(var i = 0; i < parts.length; i++) { | ||
root += parts[i] + '/'; | ||
if(_.isObject(obj)) { | ||
for(var key in obj) { | ||
var item = obj[key]; | ||
if (key === '$ref' && typeof item === 'string') { | ||
// stop and inspect | ||
if (item.indexOf('http:') !== 0 && item.indexOf('https:') !== 0) { | ||
// TODO: check if root ends in '/'. If not, AND item has no protocol, make relative | ||
var appendHash = true; | ||
var oldRoot = root; | ||
if (root) { | ||
var lastChar = root.slice(-1); | ||
if (lastChar !== '/' && (item.indexOf('#') !== 0 && item.indexOf('http:') !== 0 && item.indexOf('https:'))) { | ||
appendHash = false; | ||
var parts = root.split('\/'); | ||
parts = parts.splice(0, parts.length - 1); | ||
root = ''; | ||
for (var i = 0; i < parts.length; i++) { | ||
root += parts[i] + '/'; | ||
} | ||
} | ||
} | ||
if (item.indexOf('#') !== 0 && appendHash) { | ||
item = '#' + item; | ||
} | ||
item = (root || '') + item; | ||
obj[key] = item; | ||
} | ||
if(item.indexOf('#') !== 0 && appendHash) { | ||
item = '#' + item; | ||
} | ||
item = (root || '') + item; | ||
obj[key] = item; | ||
} | ||
else if (_.isObject(item)) { | ||
this.retainRoot(key, item, root); | ||
} | ||
} | ||
else if(_.isObject(item)) { | ||
this.retainRoot(item, root); | ||
} | ||
else if(_.isString(obj) && origKey === '$ref') { | ||
// look at the ref? | ||
if(obj.indexOf('http:') === -1 && obj.indexOf('https:') === -1) { | ||
obj = root + obj; | ||
} | ||
@@ -631,3 +641,3 @@ } | ||
} | ||
if (ref.indexOf('http') === 0) { | ||
if (ref.indexOf('http:') === 0 || ref.indexOf('https:') === 0) { | ||
if(ref.indexOf('#') >= 0) { | ||
@@ -676,3 +686,3 @@ root = ref.split('#')[0]; | ||
} | ||
else if(parts[0] && parts[0].indexOf('http') === 0) { | ||
else if(parts[0] && (parts[0].indexOf('http:') === 0 || parts[0].indexOf('https:') === 0)) { | ||
lroot = parts[0]; | ||
@@ -696,3 +706,3 @@ ref = parts[1]; | ||
} | ||
else if (ref.indexOf('http://') === 0 || ref.indexOf('https://') === 0) { | ||
else if (ref.indexOf('http:') === 0 || ref.indexOf('https:') === 0) { | ||
lroot = ref; | ||
@@ -699,0 +709,0 @@ location = ''; |
@@ -541,3 +541,3 @@ 'use strict'; | ||
var location = docLocation; | ||
if(path.indexOf('http://') === 0 || path.indexOf('https://') === 0) { | ||
if(path.indexOf('http:') === 0 || path.indexOf('https:') === 0) { | ||
location = path; | ||
@@ -544,0 +544,0 @@ } |
@@ -56,3 +56,3 @@ 'use strict'; | ||
if(this.basePath !== '/' && this.basePath.slice(-1) == '/') { | ||
if(this.basePath !== '/' && this.basePath.slice(-1) === '/') { | ||
this.basePath = this.basePath.slice(0, -1); | ||
@@ -1014,3 +1014,3 @@ } | ||
if(paramValue.name) { | ||
body += '-F @' + paramValue.name + ' '; | ||
body += '-F ' + parameter.name + '=@"' + paramValue.name + '" '; | ||
} | ||
@@ -1039,3 +1039,3 @@ } | ||
// escape @ => %40, ' => %27 | ||
body = body.replace(/\'/g, '%27').replace(/\n/g, " \\ \n "); | ||
body = body.replace(/\'/g, '%27').replace(/\n/g, ' \\ \n '); | ||
@@ -1042,0 +1042,0 @@ if(!isFormData) { |
@@ -11,3 +11,3 @@ { | ||
"description": "swagger-client is a javascript client for use with swaggering APIs.", | ||
"version": "2.1.15", | ||
"version": "2.1.16", | ||
"homepage": "http://swagger.io", | ||
@@ -14,0 +14,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1997469
24728