swagger-client
Advanced tools
Comparing version 2.1.19 to 2.1.20
@@ -145,5 +145,4 @@ 'use strict'; | ||
// default to request timeout when not specified | ||
this.fetchSpecTimeout = typeof options.fetchSpecTimeout !== 'undefined' | ||
? options.fetchSpecTimeout | ||
: options.timeout || null; | ||
this.fetchSpecTimeout = typeof options.fetchSpecTimeout !== 'undefined' ? | ||
options.fetchSpecTimeout : options.timeout || null; | ||
@@ -215,3 +214,3 @@ if(this.usePromise) { | ||
return self.fail('Please specify the protocol for ' + self.url); | ||
} else if (response.errObj && (response.errObj.code === 'ECONNABORTED' || response.errObj.message.indexOf('timeout') != -1)) { | ||
} else if (response.errObj && (response.errObj.code === 'ECONNABORTED' || response.errObj.message.indexOf('timeout') !== -1)) { | ||
return self.fail('Request timed out after ' + self.fetchSpecTimeout + 'ms'); | ||
@@ -490,3 +489,2 @@ } else if (response.status === 0) { | ||
_.forEach(Object.keys(definedTags), function (tag) { | ||
var _apiToAdd; | ||
var pos; | ||
@@ -510,4 +508,4 @@ for(pos in self.apisArray) { | ||
_.forEach(response.definitions, function (definitionObj, definition) { | ||
definitionObj['id'] = definition.toLowerCase(); | ||
definitionObj['name'] = definition; | ||
definitionObj.id = definition.toLowerCase(); | ||
definitionObj.name = definition; | ||
self.modelsArray.push(definitionObj); | ||
@@ -514,0 +512,0 @@ }); |
@@ -227,2 +227,12 @@ 'use strict'; | ||
var accept = obj.headers.Accept; | ||
if(this.binaryRequest(accept)) { | ||
r.on('request', function () { | ||
if(this.xhr) { | ||
this.xhr.responseType = 'blob'; | ||
} | ||
}); | ||
} | ||
if(obj.body) { | ||
@@ -251,4 +261,4 @@ if(_.isObject(obj.body)) { | ||
if (Array.isArray(value)) { | ||
for (var v in value) { | ||
r.field(key, value[v]); | ||
for (var t in value) { | ||
r.field(key, value[t]); | ||
} | ||
@@ -264,7 +274,7 @@ } | ||
else { | ||
var keyname; | ||
for (var keyname in obj.body) { | ||
var value = obj.body[keyname]; | ||
var keyname, value, v; | ||
for (keyname in obj.body) { | ||
value = obj.body[keyname]; | ||
if(Array.isArray(value)) { | ||
for(var v in value) { | ||
for(v in value) { | ||
r.field(keyname, v); | ||
@@ -318,4 +328,4 @@ } | ||
response.statusText = res ? res.text : err.message; | ||
if(res.headers && res.headers['content-type']) { | ||
if(res.headers['content-type'].indexOf('application/json') >= 0) { | ||
if (res.headers && res.headers['content-type']) { | ||
if (res.headers['content-type'].indexOf('application/json') >= 0) { | ||
try { | ||
@@ -334,16 +344,21 @@ response.obj = JSON.parse(response.statusText); | ||
// Already parsed by by superagent? | ||
if(res.body && _.keys(res.body).length > 0) { | ||
if (res.body && _.keys(res.body).length > 0) { | ||
possibleObj = res.body; | ||
} else { | ||
try { | ||
possibleObj = jsyaml.safeLoad(res.text); | ||
// can parse into a string... which we don't need running around in the system | ||
possibleObj = (typeof possibleObj === 'string') ? null : possibleObj; | ||
} catch(e) { | ||
helpers.log('cannot parse JSON/YAML content'); | ||
} | ||
try { | ||
possibleObj = jsyaml.safeLoad(res.text); | ||
// can parse into a string... which we don't need running around in the system | ||
possibleObj = (typeof possibleObj === 'string') ? null : possibleObj; | ||
} catch (e) { | ||
helpers.log('cannot parse JSON/YAML content'); | ||
} | ||
} | ||
// null means we can't parse into object | ||
response.obj = (typeof possibleObj === 'object') ? possibleObj : null; | ||
if(typeof Buffer === 'function' && Buffer.isBuffer(possibleObj)) { | ||
response.data = possibleObj; | ||
} | ||
else { | ||
response.obj = (typeof possibleObj === 'object') ? possibleObj : null; | ||
} | ||
@@ -354,3 +369,8 @@ response.status = res.status; | ||
} | ||
response.data = response.statusText; | ||
if (res.xhr && res.xhr.response) { | ||
response.data = res.xhr.response; | ||
} | ||
else if(!response.data) { | ||
response.data = response.statusText; | ||
} | ||
@@ -362,1 +382,8 @@ if (cb) { | ||
}; | ||
SuperagentHttpClient.prototype. binaryRequest = function (accept) { | ||
if(!accept) { | ||
return false; | ||
} | ||
return (/^image/i).test(accept) || (/^application\/pdf/).test(accept); | ||
}; |
@@ -581,4 +581,8 @@ 'use strict'; | ||
var p = url.split('#'); | ||
if (p[0].length) result.path = p[0]; | ||
if (p.length > 1) result.fragment = p.slice(1).join('#'); | ||
if (p[0].length) { | ||
result.path = p[0]; | ||
} | ||
if (p.length > 1) { | ||
result.fragment = p.slice(1).join('#'); | ||
} | ||
return result; | ||
@@ -589,8 +593,16 @@ } | ||
var result = url.path; | ||
if (result === undefined) result = ''; | ||
if (url.fragment !== undefined) result += '#' + url.fragment; | ||
if (result === undefined) { | ||
result = ''; | ||
} | ||
if (url.fragment !== undefined) { | ||
result += '#' + url.fragment; | ||
} | ||
if (url.domain !== undefined) { | ||
if (result.slice(0, 1) === '/') result = result.slice(1); | ||
if (result.slice(0, 1) === '/') { | ||
result = result.slice(1); | ||
} | ||
result = '//' + url.domain + '/' + result; | ||
if (url.proto !== undefined) result = url.proto + ':' + result; | ||
if (url.proto !== undefined) { | ||
result = url.proto + ':' + result; | ||
} | ||
} | ||
@@ -602,3 +614,5 @@ return result; | ||
var relsp = splitUrl(rel); | ||
if (relsp.domain !== undefined) return rel; | ||
if (relsp.domain !== undefined) { | ||
return rel; | ||
} | ||
var result = splitUrl(base); | ||
@@ -616,5 +630,9 @@ if (relsp.path === undefined) { | ||
var relpath = relsp.path.split('/'); | ||
if (path.length) path.pop(); | ||
if (path.length) { | ||
path.pop(); | ||
} | ||
while (relpath[0] === '..' || relpath[0] === '.') { | ||
if (relpath[0] === '..') path.pop(); | ||
if (relpath[0] === '..') { | ||
path.pop(); | ||
} | ||
relpath.shift(); | ||
@@ -621,0 +639,0 @@ } |
@@ -601,4 +601,5 @@ 'use strict'; | ||
} else if (isMultiPart) { | ||
var bodyParam; | ||
if (typeof FormData === 'function') { | ||
var bodyParam = new FormData(); | ||
bodyParam = new FormData(); | ||
@@ -605,0 +606,0 @@ bodyParam.type = 'formData'; |
@@ -11,3 +11,3 @@ { | ||
"description": "swagger-client is a javascript client for use with swaggering APIs.", | ||
"version": "2.1.19", | ||
"version": "2.1.20", | ||
"homepage": "http://swagger.io", | ||
@@ -40,3 +40,3 @@ "repository": { | ||
"q": "^1.4.1", | ||
"superagent": "^1.2" | ||
"superagent": "^2.2" | ||
}, | ||
@@ -67,2 +67,3 @@ "devDependencies": { | ||
"karma-source-map-support": "^1.0.0", | ||
"md5-file": "^3.1.1", | ||
"mocha": "^1.21.3", | ||
@@ -69,0 +70,0 @@ "object.assign": "^3.0.0", |
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
2062436
25377
30
+ Addedcall-bind@1.0.7(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedform-data@1.0.0-rc4(transitive)
+ Addedformidable@1.2.6(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedsuperagent@2.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedcomponent-emitter@1.2.1(transitive)
- Removedcookiejar@2.0.6(transitive)
- Removedextend@3.0.0(transitive)
- Removedform-data@1.0.0-rc3(transitive)
- Removedformidable@1.0.17(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmime@1.3.4(transitive)
- Removedqs@2.3.3(transitive)
- Removedreadable-stream@1.0.27-1(transitive)
- Removedreduce-component@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedsuperagent@1.8.5(transitive)
Updatedsuperagent@^2.2