swagger-client 3.25.1 → 3.25.3

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,23 +1,22 @@
1
- import { fetch as fetchU, Headers as HeaderU, Request as RequestU, Response as ResponseU, FormData as FormDataU, File as FileU, Blob as BlobU } from './fetch-ponyfill-undici.node.js';
2
1
  import { fetch as fetchNF, Headers as HeadersNF, Request as RequestNF, Response as ResponseNF, FormData as FormDataNF, File as FileNF, Blob as BlobNF } from './fetch-ponyfill-node-fetch.node.js';
3
2
  if (typeof globalThis.fetch === 'undefined') {
4
- globalThis.fetch = fetchU || fetchNF;
3
+ globalThis.fetch = fetchNF;
5
4
  }
6
5
  if (typeof globalThis.Headers === 'undefined') {
7
- globalThis.Headers = HeaderU || HeadersNF;
6
+ globalThis.Headers = HeadersNF;
8
7
  }
9
8
  if (typeof globalThis.Request === 'undefined') {
10
- globalThis.Request = RequestU || RequestNF;
9
+ globalThis.Request = RequestNF;
11
10
  }
12
11
  if (typeof globalThis.Response === 'undefined') {
13
- globalThis.Response = ResponseU || ResponseNF;
12
+ globalThis.Response = ResponseNF;
14
13
  }
15
14
  if (typeof globalThis.FormData === 'undefined') {
16
- globalThis.FormData = FormDataU || FormDataNF;
15
+ globalThis.FormData = FormDataNF;
17
16
  }
18
17
  if (typeof globalThis.File === 'undefined') {
19
- globalThis.File = FileU || FileNF;
18
+ globalThis.File = FileNF;
20
19
  }
21
20
  if (typeof globalThis.Blob === 'undefined') {
22
- globalThis.Blob = BlobU || BlobNF;
21
+ globalThis.Blob = BlobNF;
23
22
  }
@@ -4,7 +4,8 @@ import allOf from './lib/all-of.js';
4
4
  import parameters from './lib/parameters.js';
5
5
  import properties from './lib/properties.js';
6
6
  import ContextTree from './lib/context-tree.js';
7
- const HARD_LIMIT = 100;
7
+ const PLUGIN_DISPATCH_LIMIT = 100;
8
+ const TRAVERSE_LIMIT = 1000;
8
9
  const noop = () => {};
9
10
  class SpecMap {
10
11
  static getPluginName(plugin) {
@@ -33,7 +34,8 @@ class SpecMap {
33
34
  libMethods: Object.assign(Object.create(this), lib, {
34
35
  getInstance: () => this
35
36
  }),
36
- allowMetaPatches: false
37
+ allowMetaPatches: false,
38
+ currentTraverseCount: 0
37
39
  }, opts);
38
40
 
39
41
  // Lib methods bound
@@ -62,6 +64,7 @@ class SpecMap {
62
64
  const {
63
65
  pathDiscriminator
64
66
  } = this;
67
+ const that = this;
65
68
  let ctx = null;
66
69
  let fn;
67
70
  if (plugin[this.pluginProp]) {
@@ -93,9 +96,14 @@ class SpecMap {
93
96
 
94
97
  // eslint-disable-next-line no-restricted-syntax
95
98
  for (const patch of patches.filter(lib.isAdditiveMutation)) {
96
- yield* traverse(patch.value, patch.path, patch);
99
+ if (that.currentTraverseCount < TRAVERSE_LIMIT) {
100
+ yield* traverse(patch.value, patch.path, patch);
101
+ } else {
102
+ return;
103
+ }
97
104
  }
98
105
  function* traverse(obj, path, patch) {
106
+ that.currentTraverseCount += 1;
99
107
  if (!lib.isObject(obj)) {
100
108
  if (pluginObj.key === path[path.length - 1]) {
101
109
  yield pluginObj.plugin(obj, pluginObj.key, path, specmap);
@@ -119,7 +127,11 @@ class SpecMap {
119
127
  if (specmap.allowMetaPatches && objRef) {
120
128
  refCache[objRef] = true;
121
129
  }
122
- yield* traverse(val, updatedPath, patch);
130
+ if (that.currentTraverseCount < TRAVERSE_LIMIT) {
131
+ yield* traverse(val, updatedPath, patch);
132
+ } else {
133
+ return;
134
+ }
123
135
  }
124
136
  }
125
137
  if (!isRootProperties && key === pluginObj.key) {
@@ -277,6 +289,7 @@ class SpecMap {
277
289
  dispatch() {
278
290
  const that = this;
279
291
  const plugin = this.nextPlugin();
292
+ that.currentTraverseCount = 0;
280
293
  if (!plugin) {
281
294
  const nextPromise = this.nextPromisedPatch();
282
295
  if (nextPromise) {
@@ -295,12 +308,12 @@ class SpecMap {
295
308
  }
296
309
 
297
310
  // Makes sure plugin isn't running an endless loop
298
- that.pluginCount = that.pluginCount || {};
299
- that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
300
- if (that.pluginCount[plugin] > HARD_LIMIT) {
311
+ that.pluginCount = that.pluginCount || new WeakMap();
312
+ that.pluginCount.set(plugin, (that.pluginCount.get(plugin) || 0) + 1);
313
+ if (that.pluginCount[plugin] > PLUGIN_DISPATCH_LIMIT) {
301
314
  return Promise.resolve({
302
315
  spec: that.state,
303
- errors: that.errors.concat(new Error(`We've reached a hard limit of ${HARD_LIMIT} plugin runs`))
316
+ errors: that.errors.concat(new Error(`We've reached a hard limit of ${PLUGIN_DISPATCH_LIMIT} plugin runs`))
304
317
  });
305
318
  }
306
319
 
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _fetchPonyfillUndiciNode = require("./fetch-ponyfill-undici.node.js");
4
3
  var _fetchPonyfillNodeFetchNode = require("./fetch-ponyfill-node-fetch.node.js");
5
4
  if (typeof globalThis.fetch === 'undefined') {
6
- globalThis.fetch = _fetchPonyfillUndiciNode.fetch || _fetchPonyfillNodeFetchNode.fetch;
5
+ globalThis.fetch = _fetchPonyfillNodeFetchNode.fetch;
7
6
  }
8
7
  if (typeof globalThis.Headers === 'undefined') {
9
- globalThis.Headers = _fetchPonyfillUndiciNode.Headers || _fetchPonyfillNodeFetchNode.Headers;
8
+ globalThis.Headers = _fetchPonyfillNodeFetchNode.Headers;
10
9
  }
11
10
  if (typeof globalThis.Request === 'undefined') {
12
- globalThis.Request = _fetchPonyfillUndiciNode.Request || _fetchPonyfillNodeFetchNode.Request;
11
+ globalThis.Request = _fetchPonyfillNodeFetchNode.Request;
13
12
  }
14
13
  if (typeof globalThis.Response === 'undefined') {
15
- globalThis.Response = _fetchPonyfillUndiciNode.Response || _fetchPonyfillNodeFetchNode.Response;
14
+ globalThis.Response = _fetchPonyfillNodeFetchNode.Response;
16
15
  }
17
16
  if (typeof globalThis.FormData === 'undefined') {
18
- globalThis.FormData = _fetchPonyfillUndiciNode.FormData || _fetchPonyfillNodeFetchNode.FormData;
17
+ globalThis.FormData = _fetchPonyfillNodeFetchNode.FormData;
19
18
  }
20
19
  if (typeof globalThis.File === 'undefined') {
21
- globalThis.File = _fetchPonyfillUndiciNode.File || _fetchPonyfillNodeFetchNode.File;
20
+ globalThis.File = _fetchPonyfillNodeFetchNode.File;
22
21
  }
23
22
  if (typeof globalThis.Blob === 'undefined') {
24
- globalThis.Blob = _fetchPonyfillUndiciNode.Blob || _fetchPonyfillNodeFetchNode.Blob;
23
+ globalThis.Blob = _fetchPonyfillNodeFetchNode.Blob;
25
24
  }
@@ -11,7 +11,8 @@ var _allOf = _interopRequireDefault(require("./lib/all-of.js"));
11
11
  var _parameters = _interopRequireDefault(require("./lib/parameters.js"));
12
12
  var _properties = _interopRequireDefault(require("./lib/properties.js"));
13
13
  var _contextTree = _interopRequireDefault(require("./lib/context-tree.js"));
14
- const HARD_LIMIT = 100;
14
+ const PLUGIN_DISPATCH_LIMIT = 100;
15
+ const TRAVERSE_LIMIT = 1000;
15
16
  const noop = () => {};
16
17
  class SpecMap {
17
18
  static getPluginName(plugin) {
@@ -40,7 +41,8 @@ class SpecMap {
40
41
  libMethods: Object.assign(Object.create(this), _index.default, {
41
42
  getInstance: () => this
42
43
  }),
43
- allowMetaPatches: false
44
+ allowMetaPatches: false,
45
+ currentTraverseCount: 0
44
46
  }, opts);
45
47
 
46
48
  // Lib methods bound
@@ -69,6 +71,7 @@ class SpecMap {
69
71
  const {
70
72
  pathDiscriminator
71
73
  } = this;
74
+ const that = this;
72
75
  let ctx = null;
73
76
  let fn;
74
77
  if (plugin[this.pluginProp]) {
@@ -100,9 +103,14 @@ class SpecMap {
100
103
 
101
104
  // eslint-disable-next-line no-restricted-syntax
102
105
  for (const patch of patches.filter(_index.default.isAdditiveMutation)) {
103
- yield* traverse(patch.value, patch.path, patch);
106
+ if (that.currentTraverseCount < TRAVERSE_LIMIT) {
107
+ yield* traverse(patch.value, patch.path, patch);
108
+ } else {
109
+ return;
110
+ }
104
111
  }
105
112
  function* traverse(obj, path, patch) {
113
+ that.currentTraverseCount += 1;
106
114
  if (!_index.default.isObject(obj)) {
107
115
  if (pluginObj.key === path[path.length - 1]) {
108
116
  yield pluginObj.plugin(obj, pluginObj.key, path, specmap);
@@ -126,7 +134,11 @@ class SpecMap {
126
134
  if (specmap.allowMetaPatches && objRef) {
127
135
  refCache[objRef] = true;
128
136
  }
129
- yield* traverse(val, updatedPath, patch);
137
+ if (that.currentTraverseCount < TRAVERSE_LIMIT) {
138
+ yield* traverse(val, updatedPath, patch);
139
+ } else {
140
+ return;
141
+ }
130
142
  }
131
143
  }
132
144
  if (!isRootProperties && key === pluginObj.key) {
@@ -284,6 +296,7 @@ class SpecMap {
284
296
  dispatch() {
285
297
  const that = this;
286
298
  const plugin = this.nextPlugin();
299
+ that.currentTraverseCount = 0;
287
300
  if (!plugin) {
288
301
  const nextPromise = this.nextPromisedPatch();
289
302
  if (nextPromise) {
@@ -302,12 +315,12 @@ class SpecMap {
302
315
  }
303
316
 
304
317
  // Makes sure plugin isn't running an endless loop
305
- that.pluginCount = that.pluginCount || {};
306
- that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
307
- if (that.pluginCount[plugin] > HARD_LIMIT) {
318
+ that.pluginCount = that.pluginCount || new WeakMap();
319
+ that.pluginCount.set(plugin, (that.pluginCount.get(plugin) || 0) + 1);
320
+ if (that.pluginCount[plugin] > PLUGIN_DISPATCH_LIMIT) {
308
321
  return Promise.resolve({
309
322
  spec: that.state,
310
- errors: that.errors.concat(new Error(`We've reached a hard limit of ${HARD_LIMIT} plugin runs`))
323
+ errors: that.errors.concat(new Error(`We've reached a hard limit of ${PLUGIN_DISPATCH_LIMIT} plugin runs`))
311
324
  });
312
325
  }
313
326
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-client",
3
- "version": "3.25.1",
3
+ "version": "3.25.3",
4
4
  "description": "SwaggerJS - a collection of interfaces for OAI specs",
5
5
  "browser": {
6
6
  "./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
@@ -102,7 +102,8 @@
102
102
  "rimraf": "=5.0.5",
103
103
  "source-map-explorer": "^2.5.3",
104
104
  "terser-webpack-plugin": "^5.0.3",
105
- "webpack": "=5.90.1",
105
+ "undici": "^5.28.3",
106
+ "webpack": "=5.90.3",
106
107
  "webpack-bundle-size-analyzer": "=3.1.0",
107
108
  "webpack-cli": "=5.1.4",
108
109
  "webpack-stats-plugin": "=1.1.3"
@@ -119,11 +120,10 @@
119
120
  "fast-json-patch": "^3.0.0-1",
120
121
  "is-plain-object": "^5.0.0",
121
122
  "js-yaml": "^4.1.0",
122
- "node-fetch-commonjs": "^3.3.1",
123
123
  "node-abort-controller": "^3.1.1",
124
+ "node-fetch-commonjs": "^3.3.2",
124
125
  "qs": "^6.10.2",
125
- "traverse": "~0.6.6",
126
- "undici": "^5.24.0"
126
+ "traverse": "~0.6.6"
127
127
  },
128
128
  "overrides": {
129
129
  "@swagger-api/apidom-reference": {
@@ -1,4 +0,0 @@
1
- import { Blob } from 'buffer';
2
- import { fetch, Response, Headers, Request, FormData, File } from 'undici';
3
- const BlobU = typeof fetch === 'undefined' ? undefined : Blob;
4
- export { fetch, Response, Headers, Request, FormData, File, BlobU as Blob };
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.Blob = void 0;
5
- var _buffer = require("buffer");
6
- var _undici = require("undici");
7
- exports.fetch = _undici.fetch;
8
- exports.Response = _undici.Response;
9
- exports.Headers = _undici.Headers;
10
- exports.Request = _undici.Request;
11
- exports.FormData = _undici.FormData;
12
- exports.File = _undici.File;
13
- const BlobU = exports.Blob = typeof _undici.fetch === 'undefined' ? undefined : _buffer.Blob;