swagger-client 3.14.0 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime-corejs3/helpers/objectSpread2";
2
2
  import { Readable } from 'stream';
3
- import { Encoder } from 'form-data-encoder';
3
+ import { FormDataEncoder } from 'form-data-encoder';
4
4
  /**
5
5
  * formdata-node works in node-fetch@2.x via form-data-encoder only.
6
6
  * FormData instance is converted to Encoder instance which gets converted
@@ -10,7 +10,7 @@ import { Encoder } from 'form-data-encoder';
10
10
  */
11
11
 
12
12
  var foldFormDataToRequest = function foldFormDataToRequest(formdata, request) {
13
- var encoder = new Encoder(formdata);
13
+ var encoder = new FormDataEncoder(formdata);
14
14
  var readableStream = Readable.from(encoder); // get rid of previous headers
15
15
 
16
16
  delete request.headers['content-type'];
package/es/http/index.js CHANGED
@@ -20,7 +20,7 @@ import jsYaml from 'js-yaml';
20
20
  import pick from 'lodash/pick';
21
21
  import isFunction from 'lodash/isFunction';
22
22
  import { Buffer } from 'buffer';
23
- import { FormData } from 'formdata-node';
23
+ import { FormData, File, Blob } from 'formdata-node';
24
24
  import { encodeDisallowedCharacters } from '../execute/oas3/style-serializer';
25
25
  import foldFormDataToRequest from './fold-formdata-to-request.node'; // For testing
26
26
 
@@ -197,7 +197,7 @@ function parseBody(body, contentType) {
197
197
  return JSON.parse(body);
198
198
  }
199
199
 
200
- return jsYaml.safeLoad(body);
200
+ return jsYaml.load(body);
201
201
  } // Serialize the response, returns a promise with headers and the body part of the hash
202
202
 
203
203
 
@@ -272,16 +272,14 @@ export function isFile(obj, navigatorObj) {
272
272
  }
273
273
 
274
274
  if (typeof File !== 'undefined' && obj instanceof File) {
275
- // eslint-disable-line no-undef
276
275
  return true;
277
276
  }
278
277
 
279
278
  if (typeof Blob !== 'undefined' && obj instanceof Blob) {
280
- // eslint-disable-line no-undef
281
279
  return true;
282
280
  }
283
281
 
284
- if (typeof Buffer !== 'undefined' && obj instanceof Buffer) {
282
+ if (Buffer.isBuffer(obj)) {
285
283
  return true;
286
284
  }
287
285
 
@@ -465,6 +463,11 @@ function buildFormData(reqForm) {
465
463
  * Build a new FormData instance, support array as field value
466
464
  * OAS2.0 - when collectionFormat is multi
467
465
  * OAS3.0 - when explode of Encoding Object is true
466
+ *
467
+ * This function explicitly handles Buffers (for backward compatibility)
468
+ * if provided as a values to FormData. FormData can only handle USVString
469
+ * or Blob.
470
+ *
468
471
  * @param {Object} reqForm - ori req.form
469
472
  * @return {FormData} - new FormData instance
470
473
  */
@@ -491,13 +494,23 @@ function buildFormData(reqForm) {
491
494
  try {
492
495
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
493
496
  var v = _step2.value;
494
- formData.append(key, v);
497
+
498
+ if (Buffer.isBuffer(v)) {
499
+ var blob = new Blob([v]);
500
+ formData.append(key, blob);
501
+ } else {
502
+ formData.append(key, v);
503
+ }
495
504
  }
496
505
  } catch (err) {
497
506
  _iterator2.e(err);
498
507
  } finally {
499
508
  _iterator2.f();
500
509
  }
510
+ } else if (Buffer.isBuffer(value)) {
511
+ var _blob = new Blob([value]);
512
+
513
+ formData.append(key, _blob);
501
514
  } else {
502
515
  formData.append(key, value);
503
516
  }
@@ -6,7 +6,9 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
6
6
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
7
7
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
8
8
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
- import { fetch } from 'cross-fetch';
9
+ import 'cross-fetch/polyfill';
10
+ /* global fetch */
11
+
10
12
  import jsYaml from 'js-yaml';
11
13
  import qs from 'querystring-browser';
12
14
  import url from 'url';
@@ -391,7 +393,7 @@ function fetchJSON(docPath) {
391
393
  }).then(function (res) {
392
394
  return res.text();
393
395
  }).then(function (text) {
394
- return jsYaml.safeLoad(text);
396
+ return jsYaml.load(text);
395
397
  });
396
398
  }
397
399
  /**
@@ -530,7 +532,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
530
532
 
531
533
  var rootDoc = specmap.contextTree.get([]).baseDoc;
532
534
 
533
- if (basePath == rootDoc && pointerIsAParent(safeParentPointer, pointer)) {
535
+ if (basePath === rootDoc && pointerIsAParent(safeParentPointer, pointer)) {
534
536
  // eslint-disable-line
535
537
  return true;
536
538
  } // Case 2: indirect cycle
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
21
21
  * TODO(vladimir.gorej@gmail.com): this can be removed when migrated to node-fetch@3.x
22
22
  */
23
23
  const foldFormDataToRequest = (formdata, request) => {
24
- const encoder = new _formDataEncoder.Encoder(formdata);
24
+ const encoder = new _formDataEncoder.FormDataEncoder(formdata);
25
25
 
26
26
  const readableStream = _stream.Readable.from(encoder); // get rid of previous headers
27
27
 
package/lib/http/index.js CHANGED
@@ -125,7 +125,7 @@ function parseBody(body, contentType) {
125
125
  return JSON.parse(body);
126
126
  }
127
127
 
128
- return _jsYaml.default.safeLoad(body);
128
+ return _jsYaml.default.load(body);
129
129
  } // Serialize the response, returns a promise with headers and the body part of the hash
130
130
 
131
131
 
@@ -192,17 +192,15 @@ function isFile(obj, navigatorObj) {
192
192
  return false;
193
193
  }
194
194
 
195
- if (typeof File !== 'undefined' && obj instanceof File) {
196
- // eslint-disable-line no-undef
195
+ if (typeof _formdataNode.File !== 'undefined' && obj instanceof _formdataNode.File) {
197
196
  return true;
198
197
  }
199
198
 
200
- if (typeof Blob !== 'undefined' && obj instanceof Blob) {
201
- // eslint-disable-line no-undef
199
+ if (typeof _formdataNode.Blob !== 'undefined' && obj instanceof _formdataNode.Blob) {
202
200
  return true;
203
201
  }
204
202
 
205
- if (typeof _buffer.Buffer !== 'undefined' && obj instanceof _buffer.Buffer) {
203
+ if (_buffer.Buffer.isBuffer(obj)) {
206
204
  return true;
207
205
  }
208
206
 
@@ -355,6 +353,11 @@ function buildFormData(reqForm) {
355
353
  * Build a new FormData instance, support array as field value
356
354
  * OAS2.0 - when collectionFormat is multi
357
355
  * OAS3.0 - when explode of Encoding Object is true
356
+ *
357
+ * This function explicitly handles Buffers (for backward compatibility)
358
+ * if provided as a values to FormData. FormData can only handle USVString
359
+ * or Blob.
360
+ *
358
361
  * @param {Object} reqForm - ori req.form
359
362
  * @return {FormData} - new FormData instance
360
363
  */
@@ -364,8 +367,16 @@ function buildFormData(reqForm) {
364
367
  if (Array.isArray(value)) {
365
368
  // eslint-disable-next-line no-restricted-syntax
366
369
  for (const v of value) {
367
- formData.append(key, v);
370
+ if (_buffer.Buffer.isBuffer(v)) {
371
+ const blob = new _formdataNode.Blob([v]);
372
+ formData.append(key, blob);
373
+ } else {
374
+ formData.append(key, v);
375
+ }
368
376
  }
377
+ } else if (_buffer.Buffer.isBuffer(value)) {
378
+ const blob = new _formdataNode.Blob([value]);
379
+ formData.append(key, blob);
369
380
  } else {
370
381
  formData.append(key, value);
371
382
  }
@@ -3,7 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
5
 
6
- var _crossFetch = require("cross-fetch");
6
+ require("cross-fetch/polyfill");
7
7
 
8
8
  var _jsYaml = _interopRequireDefault(require("js-yaml"));
9
9
 
@@ -21,6 +21,7 @@ var _constants = require("../../constants");
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
+ /* global fetch */
24
25
  const ABSOLUTE_URL_REGEXP = new RegExp('^([a-z]+://|//)', 'i');
25
26
  const JSONRefError = (0, _createError.default)('JSONRefError', function cb(message, extra, oriError) {
26
27
  this.originalError = oriError;
@@ -341,12 +342,12 @@ function getDoc(docPath) {
341
342
 
342
343
 
343
344
  function fetchJSON(docPath) {
344
- return (0, _crossFetch.fetch)(docPath, {
345
+ return fetch(docPath, {
345
346
  headers: {
346
347
  Accept: _constants.ACCEPT_HEADER_VALUE_FOR_DOCUMENTS
347
348
  },
348
349
  loadSpec: true
349
- }).then(res => res.text()).then(text => _jsYaml.default.safeLoad(text));
350
+ }).then(res => res.text()).then(text => _jsYaml.default.load(text));
350
351
  }
351
352
  /**
352
353
  * Extracts a pointer from an object.
@@ -474,7 +475,7 @@ function pointerAlreadyInPath(pointer, basePath, parent, specmap) {
474
475
 
475
476
  const rootDoc = specmap.contextTree.get([]).baseDoc;
476
477
 
477
- if (basePath == rootDoc && pointerIsAParent(safeParentPointer, pointer)) {
478
+ if (basePath === rootDoc && pointerIsAParent(safeParentPointer, pointer)) {
478
479
  // eslint-disable-line
479
480
  return true;
480
481
  } // Case 2: indirect cycle
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "swagger-client",
3
- "version": "3.14.0",
3
+ "version": "3.16.1",
4
4
  "description": "SwaggerJS - a collection of interfaces for OAI specs",
5
5
  "browser": {
6
- "./src/http/fold-formdata-to-request.node.js": "./src/http/fold-formdata-to-request.browser.js"
6
+ "./src/http/fold-formdata-to-request.node.js": "./src/http/fold-formdata-to-request.browser.js",
7
+ "./lib/http/fold-formdata-to-request.node.js": "./lib/http/fold-formdata-to-request.browser.js",
8
+ "./es/http/fold-formdata-to-request.node.js": "./es/http/fold-formdata-to-request.browser.js"
7
9
  },
8
10
  "main": "lib/commonjs.js",
9
11
  "module": "es/index.js",
@@ -63,25 +65,25 @@
63
65
  ],
64
66
  "license": "Apache-2.0",
65
67
  "devDependencies": {
66
- "@babel/cli": "=7.14.8",
67
- "@babel/core": "=7.14.8",
68
+ "@babel/cli": "=7.15.4",
69
+ "@babel/core": "=7.15.5",
68
70
  "@babel/plugin-proposal-class-properties": "=7.14.5",
69
- "@babel/plugin-proposal-object-rest-spread": "=7.14.7",
70
- "@babel/plugin-transform-runtime": "=7.14.5",
71
- "@babel/preset-env": "=7.14.8",
72
- "@babel/register": "=7.14.5",
71
+ "@babel/plugin-proposal-object-rest-spread": "=7.15.6",
72
+ "@babel/plugin-transform-runtime": "=7.15.0",
73
+ "@babel/preset-env": "=7.15.6",
74
+ "@babel/register": "=7.15.3",
73
75
  "@char0n/npm-audit": "gist:2964395223d7943c10396f59df9a8ea0",
74
- "@commitlint/cli": "^12.0.0",
76
+ "@commitlint/cli": "^13.1.0",
75
77
  "@commitlint/config-conventional": "^13.1.0",
76
78
  "babel-loader": "=8.2.2",
77
79
  "babel-plugin-lodash": "=3.3.4",
78
80
  "cross-env": "=7.0.3",
79
- "eslint": "=7.31.0",
81
+ "eslint": "=7.32.0",
80
82
  "eslint-config-airbnb-base": "=14.2.1",
81
83
  "eslint-config-prettier": "=8.3.0",
82
- "eslint-plugin-import": "=2.23.4",
83
- "eslint-plugin-prettier": "=3.4.0",
84
- "expect": "=27.0.6",
84
+ "eslint-plugin-import": "=2.24.2",
85
+ "eslint-plugin-prettier": "=4.0.0",
86
+ "expect": "=27.1.1",
85
87
  "fetch-mock": "=9.11.0",
86
88
  "glob": "=7.1.7",
87
89
  "husky": "^7.0.1",
@@ -90,17 +92,17 @@
90
92
  "jest": "^27.0.1",
91
93
  "json-loader": "=0.5.7",
92
94
  "license-checker": "=25.0.1",
93
- "lint-staged": "=11.1.1",
95
+ "lint-staged": "=11.1.2",
94
96
  "lodash-webpack-plugin": "=0.11.6",
95
- "nock": "=13.1.1",
97
+ "nock": "=13.1.3",
96
98
  "node-fetch": "=2.6.1",
97
99
  "npm-run-all": "=4.1.5",
98
100
  "prettier": "^2.3.0",
99
101
  "rimraf": "=3.0.2",
100
102
  "terser-webpack-plugin": "^5.0.3",
101
- "webpack": "=5.46.0",
103
+ "webpack": "=5.52.0",
102
104
  "webpack-bundle-size-analyzer": "=3.1.0",
103
- "webpack-cli": "=4.7.2",
105
+ "webpack-cli": "=4.8.0",
104
106
  "webpack-stats-plugin": "=1.0.3",
105
107
  "xmock": "=0.3.0"
106
108
  },
@@ -112,10 +114,10 @@
112
114
  "cross-fetch": "^3.1.4",
113
115
  "deep-extend": "~0.6.0",
114
116
  "fast-json-patch": "^3.0.0-1",
115
- "form-data-encoder": "^1.0.1",
116
- "formdata-node": "^3.6.2",
117
- "js-yaml": "^3.14.0",
118
- "lodash": "^4.17.19",
117
+ "form-data-encoder": "^1.4.3",
118
+ "formdata-node": "^4.0.0",
119
+ "js-yaml": "^4.1.0",
120
+ "lodash": "^4.17.21",
119
121
  "qs": "^6.9.4",
120
122
  "querystring-browser": "^1.0.4",
121
123
  "traverse": "~0.6.6",