swagger-client 3.24.4 → 3.24.6

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 (66) hide show
  1. package/dist/swagger-client.browser.js +6243 -16715
  2. package/dist/swagger-client.browser.min.js +1 -1
  3. package/dist/swagger-client.browser.min.js.map +1 -1
  4. package/es/execute/index.js +26 -31
  5. package/es/execute/oas3/build-request.js +8 -13
  6. package/es/execute/oas3/parameter-builders.js +20 -24
  7. package/es/execute/oas3/style-serializer.js +23 -28
  8. package/es/execute/swagger2/build-request.js +6 -7
  9. package/es/execute/swagger2/parameter-builders.js +24 -29
  10. package/es/helpers/each-operation.js +0 -2
  11. package/es/helpers/get-operation-raw.js +5 -6
  12. package/es/helpers/id-from-path-method/index.js +3 -4
  13. package/es/helpers/op-id.js +3 -5
  14. package/es/http/index.js +12 -28
  15. package/es/index.js +2 -4
  16. package/es/interfaces.js +33 -42
  17. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  18. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  19. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +67 -32
  20. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  21. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  22. package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  23. package/es/resolver/strategies/generic/index.js +3 -4
  24. package/es/resolver/strategies/generic/normalize.js +0 -2
  25. package/es/resolver/strategies/openapi-2/index.js +6 -8
  26. package/es/resolver/strategies/openapi-3-0/index.js +6 -8
  27. package/es/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  28. package/es/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  29. package/es/resolver/strategies/openapi-3-1-apidom/resolve.js +1 -1
  30. package/es/resolver/utils/index.js +1 -2
  31. package/es/specmap/helpers.js +5 -6
  32. package/es/specmap/index.js +2 -10
  33. package/es/specmap/lib/create-error.js +1 -4
  34. package/es/subtree-resolver/index.js +2 -4
  35. package/lib/execute/index.js +26 -35
  36. package/lib/execute/oas3/build-request.js +8 -13
  37. package/lib/execute/oas3/parameter-builders.js +20 -24
  38. package/lib/execute/oas3/style-serializer.js +23 -27
  39. package/lib/execute/swagger2/build-request.js +6 -7
  40. package/lib/execute/swagger2/parameter-builders.js +24 -29
  41. package/lib/helpers/each-operation.js +0 -2
  42. package/lib/helpers/get-operation-raw.js +5 -6
  43. package/lib/helpers/id-from-path-method/index.js +3 -4
  44. package/lib/helpers/op-id.js +3 -7
  45. package/lib/http/index.js +12 -42
  46. package/lib/index.js +2 -8
  47. package/lib/interfaces.js +33 -50
  48. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +8 -9
  49. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +3 -4
  50. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +66 -31
  51. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +4 -5
  52. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +4 -5
  53. package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +3 -4
  54. package/lib/resolver/strategies/generic/index.js +3 -4
  55. package/lib/resolver/strategies/generic/normalize.js +0 -2
  56. package/lib/resolver/strategies/openapi-2/index.js +6 -8
  57. package/lib/resolver/strategies/openapi-3-0/index.js +6 -8
  58. package/lib/resolver/strategies/openapi-3-1-apidom/index.js +6 -8
  59. package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +1 -1
  60. package/lib/resolver/strategies/openapi-3-1-apidom/resolve.js +1 -1
  61. package/lib/resolver/utils/index.js +1 -4
  62. package/lib/specmap/helpers.js +5 -6
  63. package/lib/specmap/index.js +2 -10
  64. package/lib/specmap/lib/create-error.js +1 -4
  65. package/lib/subtree-resolver/index.js +2 -8
  66. package/package.json +9 -8
@@ -17,15 +17,14 @@ const OpenApi3_1SwaggerClientDereferenceStrategy = OpenApi3_1DereferenceStrategy
17
17
  mode: 'non-strict',
18
18
  ancestors: null
19
19
  },
20
- init() {
21
- let {
22
- useCircularStructures = this.useCircularStructures,
23
- allowMetaPatches = this.allowMetaPatches,
24
- parameterMacro = this.parameterMacro,
25
- modelPropertyMacro = this.modelPropertyMacro,
26
- mode = this.mode,
27
- ancestors = []
28
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
+ init({
21
+ useCircularStructures = this.useCircularStructures,
22
+ allowMetaPatches = this.allowMetaPatches,
23
+ parameterMacro = this.parameterMacro,
24
+ modelPropertyMacro = this.modelPropertyMacro,
25
+ mode = this.mode,
26
+ ancestors = []
27
+ } = {}) {
29
28
  this.name = 'openapi-3-1-swagger-client';
30
29
  this.useCircularStructures = useCircularStructures;
31
30
  this.allowMetaPatches = allowMetaPatches;
@@ -3,10 +3,9 @@ import { isSchemaElement, SchemaElement } from '@swagger-api/apidom-ns-openapi-3
3
3
  import compose from '../utils/compose.js';
4
4
  import toPath from '../utils/to-path.js';
5
5
  const AllOfVisitor = compose({
6
- init(_ref) {
7
- let {
8
- options
9
- } = _ref;
6
+ init({
7
+ options
8
+ }) {
10
9
  this.options = options;
11
10
  },
12
11
  props: {
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
- import { isObjectElement, isPrimitiveElement, isStringElement, isMemberElement, visit, toValue, cloneShallow, cloneDeep } from '@swagger-api/apidom-core';
2
+ import { isObjectElement, isPrimitiveElement, isStringElement, isMemberElement, IdentityManager, visit, includesClasses, toValue, cloneShallow, cloneDeep } from '@swagger-api/apidom-core';
3
+ import { ApiDOMError } from '@swagger-api/apidom-error';
3
4
  import { isReferenceElementExternal, isReferenceLikeElement, isPathItemElementExternal, isBooleanJsonSchemaElement, ReferenceElement, PathItemElement, SchemaElement, getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1';
4
5
  import { evaluate as jsonPointerEvaluate, uriToPointer } from '@swagger-api/apidom-json-pointer';
5
6
  import { url, MaximumDereferenceDepthError, File } from '@swagger-api/apidom-reference/configuration/empty';
@@ -14,18 +15,26 @@ const {
14
15
  wrapError
15
16
  } = specMapMod;
16
17
  const visitAsync = visit[Symbol.for('nodejs.util.promisify.custom')];
18
+
19
+ // initialize element identity manager
20
+ const identityManager = IdentityManager();
21
+
22
+ /**
23
+ * Predicate for detecting if element was created by merging referencing
24
+ * element with particular element identity with a referenced element.
25
+ */
26
+ const wasReferencedBy = referencingElement => element => element.meta.hasKey('ref-referencing-element-id') && element.meta.get('ref-referencing-element-id').equals(toValue(identityManager.identify(referencingElement)));
17
27
  const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.compose({
18
28
  props: {
19
29
  useCircularStructures: true,
20
30
  allowMetaPatches: false,
21
31
  basePath: null
22
32
  },
23
- init(_ref) {
24
- let {
25
- allowMetaPatches = this.allowMetaPatches,
26
- useCircularStructures = this.useCircularStructures,
27
- basePath = this.basePath
28
- } = _ref;
33
+ init({
34
+ allowMetaPatches = this.allowMetaPatches,
35
+ useCircularStructures = this.useCircularStructures,
36
+ basePath = this.basePath
37
+ }) {
29
38
  this.allowMetaPatches = allowMetaPatches;
30
39
  this.useCircularStructures = useCircularStructures;
31
40
  this.basePath = basePath;
@@ -36,6 +45,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
36
45
  var _this$basePath;
37
46
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
38
47
 
48
+ // skip already identified cycled Path Item Objects
49
+ if (includesClasses(['cycle'], referencingElement.$ref)) {
50
+ return false;
51
+ }
52
+
39
53
  // detect possible cycle in traversal and avoid it
40
54
  if (ancestorsLineage.includesCycle(referencingElement)) {
41
55
  return false;
@@ -72,7 +86,7 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
72
86
 
73
87
  // detect direct or indirect reference
74
88
  if (this.indirections.includes(referencedElement)) {
75
- throw new Error('Recursive JSON Pointer detected');
89
+ throw new ApiDOMError('Recursive JSON Pointer detected');
76
90
  }
77
91
 
78
92
  // detect maximum depth of dereferencing
@@ -84,9 +98,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
84
98
  if (hasCycles) {
85
99
  if (url.isHttpUrl(retrievalURI) || url.isFileSystemPath(retrievalURI)) {
86
100
  // make the referencing URL or file system path absolute
87
- return new ReferenceElement({
101
+ const cycledReferenceElement = new ReferenceElement({
88
102
  $ref: $refBaseURI
89
103
  }, cloneDeep(referencingElement.meta), cloneDeep(referencingElement.attributes));
104
+ cycledReferenceElement.get('$ref').classes.push('cycle');
105
+ return cycledReferenceElement;
90
106
  }
91
107
  // skip processing this reference
92
108
  return false;
@@ -121,26 +137,22 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
121
137
  // annotate fragment with info about original Reference element
122
138
  copy.setMetaProperty('ref-fields', {
123
139
  $ref: toValue(referencingElement.$ref),
124
- // @ts-ignore
125
140
  description: toValue(referencingElement.description),
126
- // @ts-ignore
127
141
  summary: toValue(referencingElement.summary)
128
142
  });
129
143
  // annotate fragment with info about origin
130
144
  copy.setMetaProperty('ref-origin', reference.uri);
145
+ // annotate fragment with info about referencing element
146
+ copy.setMetaProperty('ref-referencing-element-id', cloneDeep(identityManager.identify(referencingElement)));
131
147
 
132
148
  // override description and summary (outer has higher priority then inner)
133
149
  if (isObjectElement(refedElement)) {
134
150
  if (referencingElement.hasKey('description') && 'description' in refedElement) {
135
- // @ts-ignore
136
151
  copy.remove('description');
137
- // @ts-ignore
138
152
  copy.set('description', referencingElement.get('description'));
139
153
  }
140
154
  if (referencingElement.hasKey('summary') && 'summary' in refedElement) {
141
- // @ts-ignore
142
155
  copy.remove('summary');
143
- // @ts-ignore
144
156
  copy.set('summary', referencingElement.get('summary'));
145
157
  }
146
158
  }
@@ -157,13 +169,14 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
157
169
  };
158
170
 
159
171
  // attempting to create cycle
160
- if (ancestorsLineage.includes(referencedElement)) {
172
+ if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
173
+ var _ancestorsLineage$fin;
174
+ const replaceWith = (_ancestorsLineage$fin = ancestorsLineage.findItem(wasReferencedBy(referencingElement))) !== null && _ancestorsLineage$fin !== void 0 ? _ancestorsLineage$fin : mergeAndAnnotateReferencedElement(referencedElement);
161
175
  if (isMemberElement(parent)) {
162
- parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
176
+ parent.value = replaceWith; // eslint-disable-line no-param-reassign
163
177
  } else if (Array.isArray(parent)) {
164
- parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
178
+ parent[key] = replaceWith; // eslint-disable-line no-param-reassign
165
179
  }
166
-
167
180
  return false;
168
181
  }
169
182
 
@@ -192,6 +205,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
192
205
  return undefined;
193
206
  }
194
207
 
208
+ // skip already identified cycled Path Item Objects
209
+ if (includesClasses(['cycle'], pathItemElement.$ref)) {
210
+ return false;
211
+ }
212
+
195
213
  // detect possible cycle in traversal and avoid it
196
214
  if (ancestorsLineage.includesCycle(pathItemElement)) {
197
215
  return false;
@@ -219,7 +237,7 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
219
237
 
220
238
  // detect direct or indirect reference
221
239
  if (this.indirections.includes(referencedElement)) {
222
- throw new Error('Recursive JSON Pointer detected');
240
+ throw new ApiDOMError('Recursive JSON Pointer detected');
223
241
  }
224
242
 
225
243
  // detect maximum depth of dereferencing
@@ -231,9 +249,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
231
249
  if (hasCycles) {
232
250
  if (url.isHttpUrl(retrievalURI) || url.isFileSystemPath(retrievalURI)) {
233
251
  // make the referencing URL or file system path absolute
234
- return new PathItemElement({
252
+ const cycledPathItemElement = new PathItemElement({
235
253
  $ref: $refBaseURI
236
254
  }, cloneDeep(pathItemElement.meta), cloneDeep(pathItemElement.attributes));
255
+ cycledPathItemElement.get('$ref').classes.push('cycle');
256
+ return cycledPathItemElement;
237
257
  }
238
258
  // skip processing this path item and all it's child elements
239
259
  return false;
@@ -278,6 +298,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
278
298
  });
279
299
  // annotate referenced element with info about origin
280
300
  mergedElement.setMetaProperty('ref-origin', reference.uri);
301
+ // annotate fragment with info about referencing element
302
+ mergedElement.setMetaProperty('ref-referencing-element-id', cloneDeep(identityManager.identify(pathItemElement)));
281
303
 
282
304
  // apply meta patches
283
305
  if (this.allowMetaPatches) {
@@ -291,13 +313,14 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
291
313
  };
292
314
 
293
315
  // attempting to create cycle
294
- if (ancestorsLineage.includes(referencedElement)) {
316
+ if (ancestorsLineage.includes(pathItemElement) || ancestorsLineage.includes(referencedElement)) {
317
+ var _ancestorsLineage$fin2;
318
+ const replaceWith = (_ancestorsLineage$fin2 = ancestorsLineage.findItem(wasReferencedBy(pathItemElement))) !== null && _ancestorsLineage$fin2 !== void 0 ? _ancestorsLineage$fin2 : mergeAndAnnotateReferencedElement(referencedElement);
295
319
  if (isMemberElement(parent)) {
296
- parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
320
+ parent.value = replaceWith; // eslint-disable-line no-param-reassign
297
321
  } else if (Array.isArray(parent)) {
298
- parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
322
+ parent[key] = replaceWith; // eslint-disable-line no-param-reassign
299
323
  }
300
-
301
324
  return false;
302
325
  }
303
326
 
@@ -327,6 +350,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
327
350
  return undefined;
328
351
  }
329
352
 
353
+ // skip already identified cycled Path Item Objects
354
+ if (includesClasses(['cycle'], referencingElement.$ref)) {
355
+ return false;
356
+ }
357
+
330
358
  // detect possible cycle in traversal and avoid it
331
359
  if (ancestorsLineage.includesCycle(referencingElement)) {
332
360
  return false;
@@ -393,7 +421,7 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
393
421
 
394
422
  // detect direct or indirect reference
395
423
  if (this.indirections.includes(referencedElement)) {
396
- throw new Error('Recursive Schema Object reference detected');
424
+ throw new ApiDOMError('Recursive Schema Object reference detected');
397
425
  }
398
426
 
399
427
  // detect maximum depth of dereferencing
@@ -403,14 +431,16 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
403
431
 
404
432
  // useCircularStructures option processing
405
433
  if (!this.useCircularStructures) {
406
- const hasCycles = ancestorsLineage.some(ancs => ancs.has(referencedElement));
434
+ const hasCycles = ancestorsLineage.includes(referencedElement);
407
435
  if (hasCycles) {
408
436
  if (url.isHttpUrl(retrievalURI) || url.isFileSystemPath(retrievalURI)) {
409
437
  // make the referencing URL or file system path absolute
410
438
  const baseURI = url.resolve(retrievalURI, $refBaseURI);
411
- return new SchemaElement({
439
+ const cycledSchemaElement = new SchemaElement({
412
440
  $ref: baseURI
413
441
  }, cloneDeep(referencingElement.meta), cloneDeep(referencingElement.attributes));
442
+ cycledSchemaElement.get('$ref').classes.push('cycle');
443
+ return cycledSchemaElement;
414
444
  }
415
445
  // skip processing this schema and all it's child schemas
416
446
  return false;
@@ -447,6 +477,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
447
477
  });
448
478
  // annotate referenced element with info about origin
449
479
  booleanJsonSchemaElement.setMetaProperty('ref-origin', reference.uri);
480
+ // annotate fragment with info about referencing element
481
+ booleanJsonSchemaElement.setMetaProperty('ref-referencing-element-id', cloneDeep(identityManager.identify(referencingElement)));
450
482
  return booleanJsonSchemaElement;
451
483
  }
452
484
  const mergeAndAnnotateReferencedElement = refedElement => {
@@ -464,6 +496,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
464
496
  });
465
497
  // annotate fragment with info about origin
466
498
  mergedElement.setMetaProperty('ref-origin', reference.uri);
499
+ // annotate fragment with info about referencing element
500
+ mergedElement.setMetaProperty('ref-referencing-element-id', cloneDeep(identityManager.identify(referencingElement)));
467
501
 
468
502
  // allowMetaPatches option processing
469
503
  if (this.allowMetaPatches) {
@@ -477,13 +511,14 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = OpenApi3_1DereferenceVisitor.c
477
511
  };
478
512
 
479
513
  // attempting to create cycle
480
- if (ancestorsLineage.includes(referencedElement)) {
514
+ if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
515
+ var _ancestorsLineage$fin3;
516
+ const replaceWith = (_ancestorsLineage$fin3 = ancestorsLineage.findItem(wasReferencedBy(referencingElement))) !== null && _ancestorsLineage$fin3 !== void 0 ? _ancestorsLineage$fin3 : mergeAndAnnotateReferencedElement(referencedElement);
481
517
  if (isMemberElement(parent)) {
482
- parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
518
+ parent.value = replaceWith; // eslint-disable-line no-param-reassign
483
519
  } else if (Array.isArray(parent)) {
484
- parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
520
+ parent[key] = replaceWith; // eslint-disable-line no-param-reassign
485
521
  }
486
-
487
522
  return false;
488
523
  }
489
524
 
@@ -2,11 +2,10 @@ import { toValue } from '@swagger-api/apidom-core';
2
2
  import compose from '../utils/compose.js';
3
3
  import toPath from '../utils/to-path.js';
4
4
  const ParameterMacroVisitor = compose({
5
- init(_ref) {
6
- let {
7
- parameterMacro,
8
- options
9
- } = _ref;
5
+ init({
6
+ parameterMacro,
7
+ options
8
+ }) {
10
9
  this.parameterMacro = parameterMacro;
11
10
  this.options = options;
12
11
  },
@@ -2,11 +2,10 @@ import { isObjectElement, toValue } from '@swagger-api/apidom-core';
2
2
  import compose from '../utils/compose.js';
3
3
  import toPath from '../utils/to-path.js';
4
4
  const ModelPropertyMacroVisitor = compose({
5
- init(_ref) {
6
- let {
7
- modelPropertyMacro,
8
- options
9
- } = _ref;
5
+ init({
6
+ modelPropertyMacro,
7
+ options
8
+ }) {
10
9
  this.modelPropertyMacro = modelPropertyMacro;
11
10
  this.options = options;
12
11
  },
@@ -8,10 +8,9 @@ const HttpResolverSwaggerClient = HttpResolver.compose({
8
8
  swaggerHTTPClient: Http,
9
9
  swaggerHTTPClientConfig: {}
10
10
  },
11
- init() {
12
- let {
13
- swaggerHTTPClient = this.swaggerHTTPClient
14
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11
+ init({
12
+ swaggerHTTPClient = this.swaggerHTTPClient
13
+ } = {}) {
15
14
  this.swaggerHTTPClient = swaggerHTTPClient;
16
15
  },
17
16
  methods: {
@@ -9,10 +9,9 @@ const genericStrategy = {
9
9
  match() {
10
10
  return true;
11
11
  },
12
- normalize(_ref) {
13
- let {
14
- spec
15
- } = _ref;
12
+ normalize({
13
+ spec
14
+ }) {
16
15
  const {
17
16
  spec: normalized
18
17
  } = normalize({
@@ -17,7 +17,6 @@ export default function normalize(parsedSpec) {
17
17
  if (path == null || !['object', 'function'].includes(typeof path)) {
18
18
  continue; // eslint-disable-line no-continue
19
19
  }
20
-
21
20
  const pathParameters = path.parameters;
22
21
 
23
22
  // eslint-disable-next-line no-restricted-syntax, guard-for-in
@@ -26,7 +25,6 @@ export default function normalize(parsedSpec) {
26
25
  if (operation == null || !['object', 'function'].includes(typeof operation)) {
27
26
  continue; // eslint-disable-line no-continue
28
27
  }
29
-
30
28
  const oid = opId(operation, pathName, method);
31
29
  if (oid) {
32
30
  if (map[oid]) {
@@ -4,16 +4,14 @@ import { isOpenAPI2 } from '../../../helpers/openapi-predicates.js';
4
4
  export { clearCache } from '../generic/index.js';
5
5
  const openApi2Strategy = {
6
6
  name: 'openapi-2',
7
- match(_ref) {
8
- let {
9
- spec
10
- } = _ref;
7
+ match({
8
+ spec
9
+ }) {
11
10
  return isOpenAPI2(spec);
12
11
  },
13
- normalize(_ref2) {
14
- let {
15
- spec
16
- } = _ref2;
12
+ normalize({
13
+ spec
14
+ }) {
17
15
  const {
18
16
  spec: normalized
19
17
  } = normalize({
@@ -4,16 +4,14 @@ import { isOpenAPI30 } from '../../../helpers/openapi-predicates.js';
4
4
  export { clearCache } from '../generic/index.js';
5
5
  const openApi30Strategy = {
6
6
  name: 'openapi-3-0',
7
- match(_ref) {
8
- let {
9
- spec
10
- } = _ref;
7
+ match({
8
+ spec
9
+ }) {
11
10
  return isOpenAPI30(spec);
12
11
  },
13
- normalize(_ref2) {
14
- let {
15
- spec
16
- } = _ref2;
12
+ normalize({
13
+ spec
14
+ }) {
17
15
  const {
18
16
  spec: normalized
19
17
  } = normalize({
@@ -3,16 +3,14 @@ import normalize, { pojoAdapter } from './normalize.js';
3
3
  import { isOpenAPI31 } from '../../../helpers/openapi-predicates.js';
4
4
  const openApi31ApiDOMStrategy = {
5
5
  name: 'openapi-3-1-apidom',
6
- match(_ref) {
7
- let {
8
- spec
9
- } = _ref;
6
+ match({
7
+ spec
8
+ }) {
10
9
  return isOpenAPI31(spec);
11
10
  },
12
- normalize(_ref2) {
13
- let {
14
- spec
15
- } = _ref2;
11
+ normalize({
12
+ spec
13
+ }) {
16
14
  return pojoAdapter(normalize)(spec);
17
15
  },
18
16
  async resolve(options) {
@@ -30,7 +30,7 @@ const normalize = element => {
30
30
  */
31
31
  export const pojoAdapter = normalizeFn => spec => {
32
32
  if (spec !== null && spec !== void 0 && spec.$$normalized) return spec;
33
- if (pojoAdapter.cache.has(spec)) return spec;
33
+ if (pojoAdapter.cache.has(spec)) return pojoAdapter.cache.get(spec);
34
34
  const openApiElement = OpenApi3_1Element.refract(spec);
35
35
  const normalized = normalizeFn(openApiElement);
36
36
  const value = toValue(normalized);
@@ -66,7 +66,7 @@ const resolveOpenAPI31Strategy = async options => {
66
66
  if (jsonPointer !== '') refSet.rootRef = null; // reset root reference as we want fragment to become the root reference
67
67
 
68
68
  // prepare ancestors; needed for cases where fragment is not OpenAPI element
69
- const ancestors = [new WeakSet([fragmentElement])];
69
+ const ancestors = [new Set([fragmentElement])];
70
70
  const errors = [];
71
71
  const dereferenced = await dereferenceApiDOM(fragmentElement, {
72
72
  resolve: {
@@ -1,8 +1,7 @@
1
1
  import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants.js';
2
2
 
3
3
  // eslint-disable-next-line import/prefer-default-export
4
- export function makeFetchJSON(http) {
5
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4
+ export function makeFetchJSON(http, opts = {}) {
6
5
  const {
7
6
  requestInterceptor,
8
7
  responseInterceptor
@@ -33,12 +33,11 @@ export function isFreelyNamed(parentPath) {
33
33
  freelyNamedKeyParents.indexOf(parentKey) > -1 && nonFreelyNamedKeyGrandparents.indexOf(grandparentKey) === -1 || freelyNamedPaths.indexOf(parentStr) > -1 || freelyNamedAncestors.some(el => parentStr.indexOf(el) > -1)
34
34
  );
35
35
  }
36
- export function generateAbsoluteRefPatches(obj, basePath) {
37
- let {
38
- specmap,
39
- getBaseUrlForNodePath = path => specmap.getContext([...basePath, ...path]).baseDoc,
40
- targetKeys = ['$ref', '$$ref']
41
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
36
+ export function generateAbsoluteRefPatches(obj, basePath, {
37
+ specmap,
38
+ getBaseUrlForNodePath = path => specmap.getContext([...basePath, ...path]).baseDoc,
39
+ targetKeys = ['$ref', '$$ref']
40
+ } = {}) {
42
41
  const patches = [];
43
42
  traverse(obj).forEach(function callback() {
44
43
  if (targetKeys.includes(this.key) && typeof this.node === 'string') {
@@ -48,24 +48,16 @@ class SpecMap {
48
48
  this.patches.push(lib.context([], this.context));
49
49
  this.updatePatches(this.patches);
50
50
  }
51
- debug(level) {
51
+ debug(level, ...args) {
52
52
  if (this.debugLevel === level) {
53
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
54
- args[_key - 1] = arguments[_key];
55
- }
56
53
  console.log(...args); // eslint-disable-line no-console
57
54
  }
58
55
  }
59
-
60
- verbose(header) {
56
+ verbose(header, ...args) {
61
57
  if (this.debugLevel === 'verbose') {
62
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
63
- args[_key2 - 1] = arguments[_key2];
64
- }
65
58
  console.log(`[${header}] `, ...args); // eslint-disable-line no-console
66
59
  }
67
60
  }
68
-
69
61
  wrapPlugin(plugin, name) {
70
62
  const {
71
63
  pathDiscriminator
@@ -1,13 +1,10 @@
1
1
  export default function createErrorType(name, init) {
2
- function E() {
2
+ function E(...args) {
3
3
  if (!Error.captureStackTrace) {
4
4
  this.stack = new Error().stack;
5
5
  } else {
6
6
  Error.captureStackTrace(this, this.constructor);
7
7
  }
8
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
9
- args[_key] = arguments[_key];
10
- }
11
8
  [this.message] = args;
12
9
  if (init) {
13
10
  init.apply(this, args);
@@ -24,8 +24,7 @@ import resolve from '../resolver/index.js';
24
24
  import genericResolverStrategy from '../resolver/strategies/generic/index.js';
25
25
  import openApi2ResolverStrategy from '../resolver/strategies/openapi-2/index.js';
26
26
  import openApi30ResolverStrategy from '../resolver/strategies/openapi-3-0/index.js';
27
- const resolveSubtree = async function (obj, path) {
28
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
27
+ const resolveSubtree = async (obj, path, options = {}) => {
29
28
  const {
30
29
  returnEntireTree,
31
30
  baseDoc,
@@ -60,8 +59,7 @@ const resolveSubtree = async function (obj, path) {
60
59
  }
61
60
  return result;
62
61
  };
63
- export const makeResolveSubtree = defaultOptions => async function (obj, path) {
64
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
62
+ export const makeResolveSubtree = defaultOptions => async (obj, path, options = {}) => {
65
63
  const mergedOptions = {
66
64
  ...defaultOptions,
67
65
  ...options
@@ -78,19 +78,18 @@ const self = exports.self = {
78
78
 
79
79
  // Execute request, with the given operationId and parameters
80
80
  // pathName/method or operationId is optional
81
- function execute(_ref) {
82
- let {
83
- http: userHttp,
84
- fetch,
85
- // This is legacy
86
- spec,
87
- operationId,
88
- pathName,
89
- method,
90
- parameters,
91
- securities,
92
- ...extras
93
- } = _ref;
81
+ function execute({
82
+ http: userHttp,
83
+ fetch,
84
+ // This is legacy
85
+ spec,
86
+ operationId,
87
+ pathName,
88
+ method,
89
+ parameters,
90
+ securities,
91
+ ...extras
92
+ }) {
94
93
  // Provide default fetch implementation
95
94
  const http = userHttp || fetch || _index.default; // Default to _our_ http
96
95
 
@@ -293,16 +292,15 @@ function baseUrl(obj) {
293
292
  return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
294
293
  }
295
294
  const isNonEmptyServerList = value => Array.isArray(value) && value.length > 0;
296
- function oas3BaseUrl(_ref2) {
295
+ function oas3BaseUrl({
296
+ spec,
297
+ pathName,
298
+ method,
299
+ server,
300
+ contextUrl,
301
+ serverVariables = {}
302
+ }) {
297
303
  var _spec$paths, _spec$paths2;
298
- let {
299
- spec,
300
- pathName,
301
- method,
302
- server,
303
- contextUrl,
304
- serverVariables = {}
305
- } = _ref2;
306
304
  let servers = [];
307
305
  let selectedServerUrl = '';
308
306
  let selectedServerObj;
@@ -341,13 +339,7 @@ function oas3BaseUrl(_ref2) {
341
339
  }
342
340
  return buildOas3UrlWithContext(selectedServerUrl, contextUrl);
343
341
  }
344
- function buildOas3UrlWithContext(ourUrl, contextUrl) {
345
- if (ourUrl === void 0) {
346
- ourUrl = '';
347
- }
348
- if (contextUrl === void 0) {
349
- contextUrl = '';
350
- }
342
+ function buildOas3UrlWithContext(ourUrl = '', contextUrl = '') {
351
343
  // relative server url should be resolved against contextUrl
352
344
  const parsedUrl = ourUrl && contextUrl ? parseURIReference(_empty.url.resolve(contextUrl, ourUrl)) : parseURIReference(ourUrl);
353
345
  const parsedContextUrl = parseURIReference(contextUrl);
@@ -377,12 +369,11 @@ function getVariableTemplateNames(str) {
377
369
  }
378
370
 
379
371
  // Compose the baseUrl ( scheme + host + basePath )
380
- function swagger2BaseUrl(_ref3) {
381
- let {
382
- spec,
383
- scheme,
384
- contextUrl = ''
385
- } = _ref3;
372
+ function swagger2BaseUrl({
373
+ spec,
374
+ scheme,
375
+ contextUrl = ''
376
+ }) {
386
377
  const parsedContextUrl = parseURIReference(contextUrl);
387
378
  const firstSchemeInSpec = Array.isArray(spec.schemes) ? spec.schemes[0] : null;
388
379
  const computedScheme = scheme || firstSchemeInSpec || stripNonAlpha(parsedContextUrl.protocol) || 'http';