Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-client

Package Overview
Dependencies
Maintainers
2
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-client - npm Package Compare versions

Comparing version 2.1.19 to 2.1.20

12

lib/client.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc