swagger-client 3.25.2 → 3.25.4
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.
package/es/specmap/index.js
CHANGED
|
@@ -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
|
|
7
|
+
const PLUGIN_DISPATCH_LIMIT = 100;
|
|
8
|
+
const TRAVERSE_LIMIT = 3000;
|
|
8
9
|
const noop = () => {};
|
|
9
10
|
class SpecMap {
|
|
10
11
|
static getPluginName(plugin) {
|
|
@@ -92,8 +93,12 @@ class SpecMap {
|
|
|
92
93
|
const refCache = {};
|
|
93
94
|
|
|
94
95
|
// eslint-disable-next-line no-restricted-syntax
|
|
95
|
-
for (const patch of patches.filter(lib.isAdditiveMutation)) {
|
|
96
|
-
|
|
96
|
+
for (const [i, patch] of patches.filter(lib.isAdditiveMutation).entries()) {
|
|
97
|
+
if (i < TRAVERSE_LIMIT) {
|
|
98
|
+
yield* traverse(patch.value, patch.path, patch);
|
|
99
|
+
} else {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
function* traverse(obj, path, patch) {
|
|
99
104
|
if (!lib.isObject(obj)) {
|
|
@@ -295,12 +300,12 @@ class SpecMap {
|
|
|
295
300
|
}
|
|
296
301
|
|
|
297
302
|
// Makes sure plugin isn't running an endless loop
|
|
298
|
-
that.pluginCount = that.pluginCount ||
|
|
299
|
-
that.pluginCount
|
|
300
|
-
if (that.pluginCount[plugin] >
|
|
303
|
+
that.pluginCount = that.pluginCount || new WeakMap();
|
|
304
|
+
that.pluginCount.set(plugin, (that.pluginCount.get(plugin) || 0) + 1);
|
|
305
|
+
if (that.pluginCount[plugin] > PLUGIN_DISPATCH_LIMIT) {
|
|
301
306
|
return Promise.resolve({
|
|
302
307
|
spec: that.state,
|
|
303
|
-
errors: that.errors.concat(new Error(`We've reached a hard limit of ${
|
|
308
|
+
errors: that.errors.concat(new Error(`We've reached a hard limit of ${PLUGIN_DISPATCH_LIMIT} plugin runs`))
|
|
304
309
|
});
|
|
305
310
|
}
|
|
306
311
|
|
package/lib/specmap/index.js
CHANGED
|
@@ -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
|
|
14
|
+
const PLUGIN_DISPATCH_LIMIT = 100;
|
|
15
|
+
const TRAVERSE_LIMIT = 3000;
|
|
15
16
|
const noop = () => {};
|
|
16
17
|
class SpecMap {
|
|
17
18
|
static getPluginName(plugin) {
|
|
@@ -99,8 +100,12 @@ class SpecMap {
|
|
|
99
100
|
const refCache = {};
|
|
100
101
|
|
|
101
102
|
// eslint-disable-next-line no-restricted-syntax
|
|
102
|
-
for (const patch of patches.filter(_index.default.isAdditiveMutation)) {
|
|
103
|
-
|
|
103
|
+
for (const [i, patch] of patches.filter(_index.default.isAdditiveMutation).entries()) {
|
|
104
|
+
if (i < TRAVERSE_LIMIT) {
|
|
105
|
+
yield* traverse(patch.value, patch.path, patch);
|
|
106
|
+
} else {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
function* traverse(obj, path, patch) {
|
|
106
111
|
if (!_index.default.isObject(obj)) {
|
|
@@ -302,12 +307,12 @@ class SpecMap {
|
|
|
302
307
|
}
|
|
303
308
|
|
|
304
309
|
// Makes sure plugin isn't running an endless loop
|
|
305
|
-
that.pluginCount = that.pluginCount ||
|
|
306
|
-
that.pluginCount
|
|
307
|
-
if (that.pluginCount[plugin] >
|
|
310
|
+
that.pluginCount = that.pluginCount || new WeakMap();
|
|
311
|
+
that.pluginCount.set(plugin, (that.pluginCount.get(plugin) || 0) + 1);
|
|
312
|
+
if (that.pluginCount[plugin] > PLUGIN_DISPATCH_LIMIT) {
|
|
308
313
|
return Promise.resolve({
|
|
309
314
|
spec: that.state,
|
|
310
|
-
errors: that.errors.concat(new Error(`We've reached a hard limit of ${
|
|
315
|
+
errors: that.errors.concat(new Error(`We've reached a hard limit of ${PLUGIN_DISPATCH_LIMIT} plugin runs`))
|
|
311
316
|
});
|
|
312
317
|
}
|
|
313
318
|
|