swagger-client 3.24.5 → 3.26.0

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.
Files changed (69) hide show
  1. package/README.md +1 -2
  2. package/dist/swagger-client.browser.js +20592 -32714
  3. package/dist/swagger-client.browser.min.js +1 -1
  4. package/dist/swagger-client.browser.min.js.map +1 -1
  5. package/es/execute/index.js +26 -31
  6. package/es/execute/oas3/build-request.js +8 -13
  7. package/es/execute/oas3/parameter-builders.js +22 -26
  8. package/es/execute/oas3/style-serializer.js +23 -28
  9. package/es/execute/swagger2/build-request.js +6 -7
  10. package/es/execute/swagger2/parameter-builders.js +24 -29
  11. package/es/helpers/each-operation.js +0 -2
  12. package/es/helpers/fetch-polyfill.node.js +7 -8
  13. package/es/helpers/get-operation-raw.js +5 -6
  14. package/es/helpers/id-from-path-method/index.js +3 -4
  15. package/es/helpers/op-id.js +3 -5
  16. package/es/http/index.js +12 -28
  17. package/es/index.js +2 -4
  18. package/es/interfaces.js +33 -42
  19. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  20. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  21. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +73 -30
  22. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  23. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  24. package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  25. package/es/resolver/strategies/generic/index.js +3 -4
  26. package/es/resolver/strategies/generic/normalize.js +0 -2
  27. package/es/resolver/strategies/openapi-2/index.js +6 -8
  28. package/es/resolver/strategies/openapi-3-0/index.js +6 -8
  29. package/es/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  30. package/es/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  31. package/es/resolver/utils/index.js +1 -2
  32. package/es/specmap/helpers.js +5 -6
  33. package/es/specmap/index.js +14 -17
  34. package/es/specmap/lib/create-error.js +1 -4
  35. package/es/subtree-resolver/index.js +2 -4
  36. package/lib/execute/index.js +26 -35
  37. package/lib/execute/oas3/build-request.js +8 -13
  38. package/lib/execute/oas3/parameter-builders.js +22 -26
  39. package/lib/execute/oas3/style-serializer.js +23 -27
  40. package/lib/execute/swagger2/build-request.js +6 -7
  41. package/lib/execute/swagger2/parameter-builders.js +24 -29
  42. package/lib/helpers/each-operation.js +0 -2
  43. package/lib/helpers/fetch-polyfill.node.js +7 -8
  44. package/lib/helpers/get-operation-raw.js +5 -6
  45. package/lib/helpers/id-from-path-method/index.js +3 -4
  46. package/lib/helpers/op-id.js +3 -7
  47. package/lib/http/index.js +12 -42
  48. package/lib/index.js +2 -8
  49. package/lib/interfaces.js +33 -50
  50. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  51. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  52. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +72 -29
  53. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  54. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  55. package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  56. package/lib/resolver/strategies/generic/index.js +3 -4
  57. package/lib/resolver/strategies/generic/normalize.js +0 -2
  58. package/lib/resolver/strategies/openapi-2/index.js +6 -8
  59. package/lib/resolver/strategies/openapi-3-0/index.js +6 -8
  60. package/lib/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  61. package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  62. package/lib/resolver/utils/index.js +1 -4
  63. package/lib/specmap/helpers.js +5 -6
  64. package/lib/specmap/index.js +14 -17
  65. package/lib/specmap/lib/create-error.js +1 -4
  66. package/lib/subtree-resolver/index.js +2 -8
  67. package/package.json +21 -19
  68. package/es/helpers/fetch-ponyfill-undici.node.js +0 -4
  69. package/lib/helpers/fetch-ponyfill-undici.node.js +0 -13
package/lib/interfaces.js CHANGED
@@ -17,37 +17,28 @@ const self = exports.self = {
17
17
  };
18
18
 
19
19
  // Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
20
- function makeExecute(swaggerJs) {
21
- if (swaggerJs === void 0) {
22
- swaggerJs = {};
23
- }
24
- return _ref => {
25
- let {
20
+ function makeExecute(swaggerJs = {}) {
21
+ return ({
22
+ pathName,
23
+ method,
24
+ operationId
25
+ }) => (parameters, opts = {}) => {
26
+ const {
27
+ requestInterceptor,
28
+ responseInterceptor,
29
+ userFetch
30
+ } = swaggerJs;
31
+ return swaggerJs.execute({
32
+ spec: swaggerJs.spec,
33
+ requestInterceptor,
34
+ responseInterceptor,
35
+ userFetch,
26
36
  pathName,
27
37
  method,
28
- operationId
29
- } = _ref;
30
- return function (parameters, opts) {
31
- if (opts === void 0) {
32
- opts = {};
33
- }
34
- const {
35
- requestInterceptor,
36
- responseInterceptor,
37
- userFetch
38
- } = swaggerJs;
39
- return swaggerJs.execute({
40
- spec: swaggerJs.spec,
41
- requestInterceptor,
42
- responseInterceptor,
43
- userFetch,
44
- pathName,
45
- method,
46
- parameters,
47
- operationId,
48
- ...opts
49
- });
50
- };
38
+ parameters,
39
+ operationId,
40
+ ...opts
41
+ });
51
42
  };
52
43
  }
53
44
 
@@ -55,10 +46,7 @@ function makeExecute(swaggerJs) {
55
46
  // The shape
56
47
  // { apis: { [tag]: { operations: [operation]: { execute }}}}
57
48
  // NOTE: this is mostly for compatibility
58
- function makeApisTagOperationsOperationExecute(swaggerJs) {
59
- if (swaggerJs === void 0) {
60
- swaggerJs = {};
61
- }
49
+ function makeApisTagOperationsOperationExecute(swaggerJs = {}) {
62
50
  // { apis: tag: operations: execute }
63
51
  const cb = self.makeExecute(swaggerJs);
64
52
  const tagOperations = self.mapTagOperations({
@@ -85,10 +73,7 @@ function makeApisTagOperationsOperationExecute(swaggerJs) {
85
73
  }
86
74
 
87
75
  // .apis[tag][operationId]:ExecuteFunction interface
88
- function makeApisTagOperation(swaggerJs) {
89
- if (swaggerJs === void 0) {
90
- swaggerJs = {};
91
- }
76
+ function makeApisTagOperation(swaggerJs = {}) {
92
77
  const cb = self.makeExecute(swaggerJs);
93
78
  return {
94
79
  apis: self.mapTagOperations({
@@ -108,21 +93,19 @@ function makeApisTagOperation(swaggerJs) {
108
93
  * `defaultTag` will house all non-tagged operations
109
94
  *
110
95
  */
111
- function mapTagOperations(_ref2) {
112
- let {
113
- spec,
114
- cb = nullFn,
115
- defaultTag = 'default',
116
- v2OperationIdCompatibilityMode
117
- } = _ref2;
96
+ function mapTagOperations({
97
+ spec,
98
+ cb = nullFn,
99
+ defaultTag = 'default',
100
+ v2OperationIdCompatibilityMode
101
+ }) {
118
102
  const operationIdCounter = {};
119
103
  const tagOperations = {}; // Will house all tags + operations
120
- (0, _index.eachOperation)(spec, _ref3 => {
121
- let {
122
- pathName,
123
- method,
124
- operation
125
- } = _ref3;
104
+ (0, _index.eachOperation)(spec, ({
105
+ pathName,
106
+ method,
107
+ operation
108
+ }) => {
126
109
  const tags = operation.tags ? normalizeArray(operation.tags) : [defaultTag];
127
110
  tags.forEach(tag => {
128
111
  if (typeof tag !== 'string') {
@@ -24,15 +24,14 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = _openapi.default.compose({
24
24
  mode: 'non-strict',
25
25
  ancestors: null
26
26
  },
27
- init(_temp) {
28
- let {
29
- useCircularStructures = this.useCircularStructures,
30
- allowMetaPatches = this.allowMetaPatches,
31
- parameterMacro = this.parameterMacro,
32
- modelPropertyMacro = this.modelPropertyMacro,
33
- mode = this.mode,
34
- ancestors = []
35
- } = _temp === void 0 ? {} : _temp;
27
+ init({
28
+ useCircularStructures = this.useCircularStructures,
29
+ allowMetaPatches = this.allowMetaPatches,
30
+ parameterMacro = this.parameterMacro,
31
+ modelPropertyMacro = this.modelPropertyMacro,
32
+ mode = this.mode,
33
+ ancestors = []
34
+ } = {}) {
36
35
  this.name = 'openapi-3-1-swagger-client';
37
36
  this.useCircularStructures = useCircularStructures;
38
37
  this.allowMetaPatches = allowMetaPatches;
@@ -8,10 +8,9 @@ var _apidomNsOpenapi = require("@swagger-api/apidom-ns-openapi-3-1");
8
8
  var _compose = _interopRequireDefault(require("../utils/compose.js"));
9
9
  var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
10
10
  const AllOfVisitor = (0, _compose.default)({
11
- init(_ref) {
12
- let {
13
- options
14
- } = _ref;
11
+ init({
12
+ options
13
+ }) {
15
14
  this.options = options;
16
15
  },
17
16
  props: {
@@ -36,12 +36,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
36
36
  allowMetaPatches: false,
37
37
  basePath: null
38
38
  },
39
- init(_ref) {
40
- let {
41
- allowMetaPatches = this.allowMetaPatches,
42
- useCircularStructures = this.useCircularStructures,
43
- basePath = this.basePath
44
- } = _ref;
39
+ init({
40
+ allowMetaPatches = this.allowMetaPatches,
41
+ useCircularStructures = this.useCircularStructures,
42
+ basePath = this.basePath
43
+ }) {
45
44
  this.allowMetaPatches = allowMetaPatches;
46
45
  this.useCircularStructures = useCircularStructures;
47
46
  this.basePath = basePath;
@@ -61,15 +60,19 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
61
60
  if (ancestorsLineage.includesCycle(referencingElement)) {
62
61
  return false;
63
62
  }
63
+ const retrievalURI = this.toBaseURI((0, _apidomCore.toValue)(referencingElement.$ref));
64
+ const isInternalReference = _empty.url.stripHash(this.reference.uri) === retrievalURI;
65
+ const isExternalReference = !isInternalReference;
64
66
 
67
+ // ignore resolving internal Reference Objects
68
+ if (!this.options.resolve.internal && isInternalReference) {
69
+ return false;
70
+ }
65
71
  // ignore resolving external Reference Objects
66
- if (!this.options.resolve.external && (0, _apidomNsOpenapi.isReferenceElementExternal)(referencingElement)) {
72
+ if (!this.options.resolve.external && isExternalReference) {
67
73
  return false;
68
74
  }
69
75
  const reference = await this.toReference((0, _apidomCore.toValue)(referencingElement.$ref));
70
- const {
71
- uri: retrievalURI
72
- } = reference;
73
76
  const $refBaseURI = _empty.url.resolve(retrievalURI, (0, _apidomCore.toValue)(referencingElement.$ref));
74
77
  this.indirections.push(referencingElement);
75
78
  const jsonPointer = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
@@ -80,14 +83,19 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
80
83
  // applying semantics to a fragment
81
84
  if ((0, _apidomCore.isPrimitiveElement)(referencedElement)) {
82
85
  const referencedElementType = (0, _apidomCore.toValue)(referencingElement.meta.get('referenced-element'));
83
- if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
86
+ const cacheKey = `${referencedElementType}-${(0, _apidomCore.toValue)(identityManager.identify(referencedElement))}`;
87
+ if (this.refractCache.has(cacheKey)) {
88
+ referencedElement = this.refractCache.get(cacheKey);
89
+ } else if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
84
90
  // handling indirect references
85
91
  referencedElement = _apidomNsOpenapi.ReferenceElement.refract(referencedElement);
86
92
  referencedElement.setMetaProperty('referenced-element', referencedElementType);
93
+ this.refractCache.set(cacheKey, referencedElement);
87
94
  } else {
88
95
  // handling direct references
89
96
  const ElementClass = this.namespace.getElementClass(referencedElementType);
90
97
  referencedElement = ElementClass.refract(referencedElement);
98
+ this.refractCache.set(cacheKey, referencedElement);
91
99
  }
92
100
  }
93
101
 
@@ -184,7 +192,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
184
192
  } else if (Array.isArray(parent)) {
185
193
  parent[key] = replaceWith; // eslint-disable-line no-param-reassign
186
194
  }
187
-
188
195
  return false;
189
196
  }
190
197
 
@@ -222,15 +229,19 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
222
229
  if (ancestorsLineage.includesCycle(pathItemElement)) {
223
230
  return false;
224
231
  }
232
+ const retrievalURI = this.toBaseURI((0, _apidomCore.toValue)(pathItemElement.$ref));
233
+ const isInternalReference = _empty.url.stripHash(this.reference.uri) === retrievalURI;
234
+ const isExternalReference = !isInternalReference;
225
235
 
236
+ // ignore resolving internal Path Item Elements
237
+ if (!this.options.resolve.internal && isInternalReference) {
238
+ return undefined;
239
+ }
226
240
  // ignore resolving external Path Item Elements
227
- if (!this.options.resolve.external && (0, _apidomNsOpenapi.isPathItemElementExternal)(pathItemElement)) {
241
+ if (!this.options.resolve.external && isExternalReference) {
228
242
  return undefined;
229
243
  }
230
244
  const reference = await this.toReference((0, _apidomCore.toValue)(pathItemElement.$ref));
231
- const {
232
- uri: retrievalURI
233
- } = reference;
234
245
  const $refBaseURI = _empty.url.resolve(retrievalURI, (0, _apidomCore.toValue)(pathItemElement.$ref));
235
246
  this.indirections.push(pathItemElement);
236
247
  const jsonPointer = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
@@ -240,7 +251,13 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
240
251
 
241
252
  // applying semantics to a referenced element
242
253
  if ((0, _apidomCore.isPrimitiveElement)(referencedElement)) {
243
- referencedElement = _apidomNsOpenapi.PathItemElement.refract(referencedElement);
254
+ const cacheKey = `pathItem-${(0, _apidomCore.toValue)(identityManager.identify(referencedElement))}`;
255
+ if (this.refractCache.has(cacheKey)) {
256
+ referencedElement = this.refractCache.get(cacheKey);
257
+ } else {
258
+ referencedElement = _apidomNsOpenapi.PathItemElement.refract(referencedElement);
259
+ this.refractCache.set(cacheKey, referencedElement);
260
+ }
244
261
  }
245
262
 
246
263
  // detect direct or indirect reference
@@ -329,7 +346,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
329
346
  } else if (Array.isArray(parent)) {
330
347
  parent[key] = replaceWith; // eslint-disable-line no-param-reassign
331
348
  }
332
-
333
349
  return false;
334
350
  }
335
351
 
@@ -381,13 +397,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
381
397
  });
382
398
  const isUnknownURI = !this.options.resolve.resolvers.some(r => r.canRead(file));
383
399
  const isURL = !isUnknownURI;
384
- const isExternal = isURL && retrievalURI !== $refBaseURIStrippedHash;
385
-
386
- // ignore resolving external Schema Objects
387
- if (!this.options.resolve.external && isExternal) {
388
- // skip traversing this schema but traverse all it's child schemas
389
- return undefined;
390
- }
400
+ const isInternalReference = uri => _empty.url.stripHash(this.reference.uri) === uri;
401
+ const isExternalReference = uri => !isInternalReference(uri);
391
402
  this.indirections.push(referencingElement);
392
403
 
393
404
  // determining reference, proper evaluation and selection mechanism
@@ -399,8 +410,19 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
399
410
  referencedElement = (0, _uri.evaluate)(selector, (0, _openapi.maybeRefractToSchemaElement)(reference.value.result));
400
411
  } else {
401
412
  // we're assuming here that we're dealing with JSON Pointer here
413
+ retrievalURI = this.toBaseURI((0, _apidomCore.toValue)($refBaseURI));
414
+
415
+ // ignore resolving internal Schema Objects
416
+ if (!this.options.resolve.internal && isInternalReference(retrievalURI)) {
417
+ // skip traversing this schema element but traverse all it's child elements
418
+ return undefined;
419
+ }
420
+ // ignore resolving external Schema Objects
421
+ if (!this.options.resolve.external && isExternalReference(retrievalURI)) {
422
+ // skip traversing this schema element but traverse all it's child elements
423
+ return undefined;
424
+ }
402
425
  reference = await this.toReference(_empty.url.unsanitize($refBaseURI));
403
- retrievalURI = reference.uri;
404
426
  const selector = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
405
427
  referencedElement = (0, _openapi.maybeRefractToSchemaElement)((0, _apidomJsonPointer.evaluate)(selector, reference.value.result));
406
428
  }
@@ -412,14 +434,36 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
412
434
  if (isURL && error instanceof _uri.EvaluationJsonSchemaUriError) {
413
435
  if ((0, _$anchor.isAnchor)((0, _$anchor.uriToAnchor)($refBaseURI))) {
414
436
  // we're dealing with JSON Schema $anchor here
437
+ retrievalURI = this.toBaseURI((0, _apidomCore.toValue)($refBaseURI));
438
+
439
+ // ignore resolving internal Schema Objects
440
+ if (!this.options.resolve.internal && isInternalReference(retrievalURI)) {
441
+ // skip traversing this schema element but traverse all it's child elements
442
+ return undefined;
443
+ }
444
+ // ignore resolving external Schema Objects
445
+ if (!this.options.resolve.external && isExternalReference(retrievalURI)) {
446
+ // skip traversing this schema element but traverse all it's child elements
447
+ return undefined;
448
+ }
415
449
  reference = await this.toReference(_empty.url.unsanitize($refBaseURI));
416
- retrievalURI = reference.uri;
417
450
  const selector = (0, _$anchor.uriToAnchor)($refBaseURI);
418
451
  referencedElement = (0, _$anchor.evaluate)(selector, (0, _openapi.maybeRefractToSchemaElement)(reference.value.result));
419
452
  } else {
420
453
  // we're assuming here that we're dealing with JSON Pointer here
454
+ retrievalURI = this.toBaseURI((0, _apidomCore.toValue)($refBaseURI));
455
+
456
+ // ignore resolving internal Schema Objects
457
+ if (!this.options.resolve.internal && isInternalReference(retrievalURI)) {
458
+ // skip traversing this schema element but traverse all it's child elements
459
+ return undefined;
460
+ }
461
+ // ignore resolving external Schema Objects
462
+ if (!this.options.resolve.external && isExternalReference(retrievalURI)) {
463
+ // skip traversing this schema element but traverse all it's child elements
464
+ return undefined;
465
+ }
421
466
  reference = await this.toReference(_empty.url.unsanitize($refBaseURI));
422
- retrievalURI = reference.uri;
423
467
  const selector = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
424
468
  referencedElement = (0, _openapi.maybeRefractToSchemaElement)((0, _apidomJsonPointer.evaluate)(selector, reference.value.result));
425
469
  }
@@ -528,7 +572,6 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
528
572
  } else if (Array.isArray(parent)) {
529
573
  parent[key] = replaceWith; // eslint-disable-line no-param-reassign
530
574
  }
531
-
532
575
  return false;
533
576
  }
534
577
 
@@ -7,11 +7,10 @@ var _apidomCore = require("@swagger-api/apidom-core");
7
7
  var _compose = _interopRequireDefault(require("../utils/compose.js"));
8
8
  var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
9
9
  const ParameterMacroVisitor = (0, _compose.default)({
10
- init(_ref) {
11
- let {
12
- parameterMacro,
13
- options
14
- } = _ref;
10
+ init({
11
+ parameterMacro,
12
+ options
13
+ }) {
15
14
  this.parameterMacro = parameterMacro;
16
15
  this.options = options;
17
16
  },
@@ -7,11 +7,10 @@ var _apidomCore = require("@swagger-api/apidom-core");
7
7
  var _compose = _interopRequireDefault(require("../utils/compose.js"));
8
8
  var _toPath = _interopRequireDefault(require("../utils/to-path.js"));
9
9
  const ModelPropertyMacroVisitor = (0, _compose.default)({
10
- init(_ref) {
11
- let {
12
- modelPropertyMacro,
13
- options
14
- } = _ref;
10
+ init({
11
+ modelPropertyMacro,
12
+ options
13
+ }) {
15
14
  this.modelPropertyMacro = modelPropertyMacro;
16
15
  this.options = options;
17
16
  },
@@ -13,10 +13,9 @@ const HttpResolverSwaggerClient = _empty.HttpResolver.compose({
13
13
  swaggerHTTPClient: _index.default,
14
14
  swaggerHTTPClientConfig: {}
15
15
  },
16
- init(_temp) {
17
- let {
18
- swaggerHTTPClient = this.swaggerHTTPClient
19
- } = _temp === void 0 ? {} : _temp;
16
+ init({
17
+ swaggerHTTPClient = this.swaggerHTTPClient
18
+ } = {}) {
20
19
  this.swaggerHTTPClient = swaggerHTTPClient;
21
20
  },
22
21
  methods: {
@@ -15,10 +15,9 @@ const genericStrategy = {
15
15
  match() {
16
16
  return true;
17
17
  },
18
- normalize(_ref) {
19
- let {
20
- spec
21
- } = _ref;
18
+ normalize({
19
+ spec
20
+ }) {
22
21
  const {
23
22
  spec: normalized
24
23
  } = (0, _normalize.default)({
@@ -22,7 +22,6 @@ function normalize(parsedSpec) {
22
22
  if (path == null || !['object', 'function'].includes(typeof path)) {
23
23
  continue; // eslint-disable-line no-continue
24
24
  }
25
-
26
25
  const pathParameters = path.parameters;
27
26
 
28
27
  // eslint-disable-next-line no-restricted-syntax, guard-for-in
@@ -31,7 +30,6 @@ function normalize(parsedSpec) {
31
30
  if (operation == null || !['object', 'function'].includes(typeof operation)) {
32
31
  continue; // eslint-disable-line no-continue
33
32
  }
34
-
35
33
  const oid = (0, _opId.default)(operation, pathName, method);
36
34
  if (oid) {
37
35
  if (map[oid]) {
@@ -10,16 +10,14 @@ var _index = require("../generic/index.js");
10
10
  exports.clearCache = _index.clearCache;
11
11
  const openApi2Strategy = {
12
12
  name: 'openapi-2',
13
- match(_ref) {
14
- let {
15
- spec
16
- } = _ref;
13
+ match({
14
+ spec
15
+ }) {
17
16
  return (0, _openapiPredicates.isOpenAPI2)(spec);
18
17
  },
19
- normalize(_ref2) {
20
- let {
21
- spec
22
- } = _ref2;
18
+ normalize({
19
+ spec
20
+ }) {
23
21
  const {
24
22
  spec: normalized
25
23
  } = (0, _normalize.default)({
@@ -10,16 +10,14 @@ var _index = require("../generic/index.js");
10
10
  exports.clearCache = _index.clearCache;
11
11
  const openApi30Strategy = {
12
12
  name: 'openapi-3-0',
13
- match(_ref) {
14
- let {
15
- spec
16
- } = _ref;
13
+ match({
14
+ spec
15
+ }) {
17
16
  return (0, _openapiPredicates.isOpenAPI30)(spec);
18
17
  },
19
- normalize(_ref2) {
20
- let {
21
- spec
22
- } = _ref2;
18
+ normalize({
19
+ spec
20
+ }) {
23
21
  const {
24
22
  spec: normalized
25
23
  } = (0, _normalize.default)({
@@ -9,16 +9,14 @@ var _normalize = _interopRequireWildcard(require("./normalize.js"));
9
9
  var _openapiPredicates = require("../../../helpers/openapi-predicates.js");
10
10
  const openApi31ApiDOMStrategy = {
11
11
  name: 'openapi-3-1-apidom',
12
- match(_ref) {
13
- let {
14
- spec
15
- } = _ref;
12
+ match({
13
+ spec
14
+ }) {
16
15
  return (0, _openapiPredicates.isOpenAPI31)(spec);
17
16
  },
18
- normalize(_ref2) {
19
- let {
20
- spec
21
- } = _ref2;
17
+ normalize({
18
+ spec
19
+ }) {
22
20
  return (0, _normalize.pojoAdapter)(_normalize.default)(spec);
23
21
  },
24
22
  async resolve(options) {
@@ -36,7 +36,7 @@ const normalize = element => {
36
36
  */
37
37
  const pojoAdapter = normalizeFn => spec => {
38
38
  if (spec != null && spec.$$normalized) return spec;
39
- if (pojoAdapter.cache.has(spec)) return spec;
39
+ if (pojoAdapter.cache.has(spec)) return pojoAdapter.cache.get(spec);
40
40
  const openApiElement = _apidomNsOpenapi.OpenApi3_1Element.refract(spec);
41
41
  const normalized = normalizeFn(openApiElement);
42
42
  const value = (0, _apidomCore.toValue)(normalized);
@@ -4,10 +4,7 @@ exports.__esModule = true;
4
4
  exports.makeFetchJSON = makeFetchJSON;
5
5
  var _constants = require("../../constants.js");
6
6
  // eslint-disable-next-line import/prefer-default-export
7
- function makeFetchJSON(http, opts) {
8
- if (opts === void 0) {
9
- opts = {};
10
- }
7
+ function makeFetchJSON(http, opts = {}) {
11
8
  const {
12
9
  requestInterceptor,
13
10
  responseInterceptor
@@ -39,12 +39,11 @@ function isFreelyNamed(parentPath) {
39
39
  freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 || freelyNamedPaths.indexOf(parentStr) > -1 || freelyNamedAncestors.some(el => parentStr.indexOf(el) > -1)
40
40
  );
41
41
  }
42
- function generateAbsoluteRefPatches(obj, basePath, _temp) {
43
- let {
44
- specmap,
45
- getBaseUrlForNodePath = path => specmap.getContext([...basePath, ...path]).baseDoc,
46
- targetKeys = ['$ref', '$$ref']
47
- } = _temp === void 0 ? {} : _temp;
42
+ function generateAbsoluteRefPatches(obj, basePath, {
43
+ specmap,
44
+ getBaseUrlForNodePath = path => specmap.getContext([...basePath, ...path]).baseDoc,
45
+ targetKeys = ['$ref', '$$ref']
46
+ } = {}) {
48
47
  const patches = [];
49
48
  (0, _traverse.default)(obj).forEach(function callback() {
50
49
  if (targetKeys.includes(this.key) && typeof this.node === 'string') {
@@ -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 = 3000;
15
16
  const noop = () => {};
16
17
  class SpecMap {
17
18
  static getPluginName(plugin) {
@@ -55,24 +56,16 @@ class SpecMap {
55
56
  this.patches.push(_index.default.context([], this.context));
56
57
  this.updatePatches(this.patches);
57
58
  }
58
- debug(level) {
59
+ debug(level, ...args) {
59
60
  if (this.debugLevel === level) {
60
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
61
- args[_key - 1] = arguments[_key];
62
- }
63
61
  console.log(...args); // eslint-disable-line no-console
64
62
  }
65
63
  }
66
-
67
- verbose(header) {
64
+ verbose(header, ...args) {
68
65
  if (this.debugLevel === 'verbose') {
69
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
70
- args[_key2 - 1] = arguments[_key2];
71
- }
72
66
  console.log(`[${header}] `, ...args); // eslint-disable-line no-console
73
67
  }
74
68
  }
75
-
76
69
  wrapPlugin(plugin, name) {
77
70
  const {
78
71
  pathDiscriminator
@@ -107,8 +100,12 @@ class SpecMap {
107
100
  const refCache = {};
108
101
 
109
102
  // eslint-disable-next-line no-restricted-syntax
110
- for (const patch of patches.filter(_index.default.isAdditiveMutation)) {
111
- yield* traverse(patch.value, patch.path, patch);
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
+ }
112
109
  }
113
110
  function* traverse(obj, path, patch) {
114
111
  if (!_index.default.isObject(obj)) {
@@ -310,12 +307,12 @@ class SpecMap {
310
307
  }
311
308
 
312
309
  // Makes sure plugin isn't running an endless loop
313
- that.pluginCount = that.pluginCount || {};
314
- that.pluginCount[plugin] = (that.pluginCount[plugin] || 0) + 1;
315
- if (that.pluginCount[plugin] > HARD_LIMIT) {
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) {
316
313
  return Promise.resolve({
317
314
  spec: that.state,
318
- errors: that.errors.concat(new Error(`We've reached a hard limit of ${HARD_LIMIT} plugin runs`))
315
+ errors: that.errors.concat(new Error(`We've reached a hard limit of ${PLUGIN_DISPATCH_LIMIT} plugin runs`))
319
316
  });
320
317
  }
321
318
 
@@ -3,15 +3,12 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = createErrorType;
5
5
  function createErrorType(name, init) {
6
- function E() {
6
+ function E(...args) {
7
7
  if (!Error.captureStackTrace) {
8
8
  this.stack = new Error().stack;
9
9
  } else {
10
10
  Error.captureStackTrace(this, this.constructor);
11
11
  }
12
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13
- args[_key] = arguments[_key];
14
- }
15
12
  [this.message] = args;
16
13
  if (init) {
17
14
  init.apply(this, args);
@@ -30,10 +30,7 @@ var _index4 = _interopRequireDefault(require("../resolver/strategies/openapi-3-0
30
30
  //
31
31
  // TODO: move the remarks above into project documentation
32
32
 
33
- const resolveSubtree = async function (obj, path, options) {
34
- if (options === void 0) {
35
- options = {};
36
- }
33
+ const resolveSubtree = async (obj, path, options = {}) => {
37
34
  const {
38
35
  returnEntireTree,
39
36
  baseDoc,
@@ -68,10 +65,7 @@ const resolveSubtree = async function (obj, path, options) {
68
65
  }
69
66
  return result;
70
67
  };
71
- const makeResolveSubtree = defaultOptions => async function (obj, path, options) {
72
- if (options === void 0) {
73
- options = {};
74
- }
68
+ const makeResolveSubtree = defaultOptions => async (obj, path, options = {}) => {
75
69
  const mergedOptions = {
76
70
  ...defaultOptions,
77
71
  ...options