swagger-client 3.37.3 → 3.37.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.
Files changed (67) hide show
  1. package/README.md +2 -5
  2. package/dist/swagger-client.browser.js +2044 -1806
  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 +7 -6
  6. package/es/execute/oas3/build-request.js +3 -6
  7. package/es/execute/oas3/content-serializer.js +2 -1
  8. package/es/execute/oas3/parameter-builders.js +2 -3
  9. package/es/execute/oas3/style-serializer.js +1 -1
  10. package/es/http/index.js +0 -1
  11. package/es/http/serializers/response/index.js +2 -1
  12. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +1 -2
  13. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +2 -4
  14. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +27 -33
  15. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +1 -2
  16. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +1 -2
  17. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/index.js +1 -2
  18. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/all-of.js +2 -4
  19. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/dereference.js +27 -33
  20. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/parameters.js +1 -2
  21. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/properties.js +1 -2
  22. package/es/resolver/apidom/reference/parse/parsers/json/index.js +4 -2
  23. package/es/resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js +4 -2
  24. package/es/resolver/apidom/reference/parse/parsers/openapi-json-3-2/index.js +4 -2
  25. package/es/resolver/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js +4 -2
  26. package/es/resolver/apidom/reference/parse/parsers/openapi-yaml-3-2/index.js +4 -2
  27. package/es/resolver/apidom/reference/parse/parsers/yaml-1-2/index.js +4 -2
  28. package/es/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +0 -1
  29. package/es/resolver/specmap/helpers.js +4 -3
  30. package/es/resolver/specmap/lib/refs.js +0 -1
  31. package/es/resolver/strategies/generic/normalize.js +5 -2
  32. package/es/resolver/utils/options.js +2 -3
  33. package/es/subtree-resolver/index.js +1 -1
  34. package/lib/execute/index.js +7 -6
  35. package/lib/execute/oas3/build-request.js +3 -6
  36. package/lib/execute/oas3/content-serializer.js +3 -1
  37. package/lib/execute/oas3/parameter-builders.js +2 -3
  38. package/lib/execute/oas3/style-serializer.js +1 -1
  39. package/lib/http/index.js +0 -1
  40. package/lib/http/serializers/response/index.js +2 -1
  41. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +1 -2
  42. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +2 -4
  43. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +27 -33
  44. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +1 -2
  45. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +1 -2
  46. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/index.js +1 -2
  47. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/all-of.js +2 -4
  48. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/dereference.js +27 -33
  49. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/parameters.js +1 -2
  50. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-2-swagger-client/visitors/properties.js +1 -2
  51. package/lib/resolver/apidom/reference/parse/parsers/json/index.js +5 -2
  52. package/lib/resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js +5 -2
  53. package/lib/resolver/apidom/reference/parse/parsers/openapi-json-3-2/index.js +5 -2
  54. package/lib/resolver/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js +5 -2
  55. package/lib/resolver/apidom/reference/parse/parsers/openapi-yaml-3-2/index.js +5 -2
  56. package/lib/resolver/apidom/reference/parse/parsers/yaml-1-2/index.js +5 -2
  57. package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +0 -1
  58. package/lib/resolver/specmap/helpers.js +4 -3
  59. package/lib/resolver/specmap/lib/refs.js +0 -1
  60. package/lib/resolver/strategies/generic/normalize.js +5 -2
  61. package/lib/resolver/utils/options.js +2 -3
  62. package/lib/subtree-resolver/index.js +1 -1
  63. package/package.json +9 -10
  64. package/es/helpers/fetch-polyfill.node.js +0 -22
  65. package/es/helpers/fetch-ponyfill-node-fetch.node.js +0 -3
  66. package/lib/helpers/fetch-polyfill.node.js +0 -24
  67. package/lib/helpers/fetch-ponyfill-node-fetch.node.js +0 -12
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /* eslint-disable camelcase */
2
3
  import { RefElement, isObjectElement, isPrimitiveElement, isStringElement, isMemberElement, IdentityManager, visit, includesClasses, toValue, cloneShallow, cloneDeep } from '@swagger-api/apidom-core';
3
4
  import { ApiDOMError } from '@swagger-api/apidom-error';
@@ -44,8 +45,9 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
44
45
  }
45
46
  async ReferenceElement(referencingElement, key, parent, path, ancestors, link) {
46
47
  try {
48
+ var _context, _context2;
47
49
  // skip current referencing element as it's already been access
48
- if (this.indirections.includes(referencingElement)) {
50
+ if (_includesInstanceProperty(_context = this.indirections).call(_context, referencingElement)) {
49
51
  return false;
50
52
  }
51
53
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
@@ -100,12 +102,11 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
100
102
  }
101
103
 
102
104
  // detect second deep dive into the same fragment and avoid it
103
- if (ancestorsLineage.includes(referencedElement)) {
105
+ if (_includesInstanceProperty(ancestorsLineage).call(ancestorsLineage, referencedElement)) {
104
106
  reference.refSet.circular = true;
105
107
  if (this.options.dereference.circular === 'error') {
106
108
  throw new ApiDOMError('Circular reference detected');
107
109
  } else if (this.options.dereference.circular === 'replace') {
108
- var _this$options$derefer, _this$options$derefer2;
109
110
  const refElement = new RefElement(referencedElement.id, {
110
111
  type: 'reference',
111
112
  uri: reference.uri,
@@ -113,7 +114,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
113
114
  baseURI: $refBaseURI,
114
115
  referencingElement
115
116
  });
116
- const replacer = (_this$options$derefer = (_this$options$derefer2 = this.options.dereference.strategyOpts['openapi-3-2']) === null || _this$options$derefer2 === void 0 ? void 0 : _this$options$derefer2.circularReplacer) !== null && _this$options$derefer !== void 0 ? _this$options$derefer : this.options.dereference.circularReplacer;
117
+ const replacer = this.options.dereference.strategyOpts['openapi-3-2']?.circularReplacer ?? this.options.dereference.circularReplacer;
117
118
  const replacement = replacer(refElement);
118
119
  link.replaceWith(refElement, mutationReplacer);
119
120
  return !parent ? replacement : false;
@@ -130,9 +131,8 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
130
131
  * 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
131
132
  */
132
133
  const isNonRootDocument = url.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
133
- const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
134
+ const shouldDetectCircular = _includesInstanceProperty(_context2 = ['error', 'replace']).call(_context2, this.options.dereference.circular);
134
135
  if ((isExternalReference || isNonRootDocument || isReferenceElement(referencedElement) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
135
- var _this$basePath;
136
136
  // append referencing reference to ancestors lineage
137
137
  directAncestors.add(referencingElement);
138
138
  const visitor = new OpenAPI3_2SwaggerClientDereferenceVisitor({
@@ -144,7 +144,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
144
144
  ancestors: ancestorsLineage,
145
145
  allowMetaPatches: this.allowMetaPatches,
146
146
  useCircularStructures: this.useCircularStructures,
147
- basePath: (_this$basePath = this.basePath) !== null && _this$basePath !== void 0 ? _this$basePath : [...toPath([...ancestors, parent, referencingElement]), '$ref']
147
+ basePath: this.basePath ?? [...toPath([...ancestors, parent, referencingElement]), '$ref']
148
148
  });
149
149
  referencedElement = await visitAsync(referencedElement, visitor, {
150
150
  keyMap,
@@ -199,27 +199,27 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
199
199
  */
200
200
  return !parent ? mergedElement : false;
201
201
  } catch (error) {
202
- var _this$basePath2, _this$options$derefer3, _this$options$derefer4;
203
202
  const rootCause = getRootCause(error);
204
203
  const wrappedError = wrapError(rootCause, {
205
204
  baseDoc: this.reference.uri,
206
205
  $ref: toValue(referencingElement.$ref),
207
206
  pointer: URIFragmentIdentifier.fromURIReference(toValue(referencingElement.$ref)),
208
- fullPath: (_this$basePath2 = this.basePath) !== null && _this$basePath2 !== void 0 ? _this$basePath2 : [...toPath([...ancestors, parent, referencingElement]), '$ref']
207
+ fullPath: this.basePath ?? [...toPath([...ancestors, parent, referencingElement]), '$ref']
209
208
  });
210
- (_this$options$derefer3 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer3 === void 0 || (_this$options$derefer3 = _this$options$derefer3.errors) === null || _this$options$derefer3 === void 0 || (_this$options$derefer4 = _this$options$derefer3.push) === null || _this$options$derefer4 === void 0 || _this$options$derefer4.call(_this$options$derefer3, wrappedError);
209
+ this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
211
210
  return undefined;
212
211
  }
213
212
  }
214
213
  async PathItemElement(pathItemElement, key, parent, path, ancestors, link) {
215
214
  try {
215
+ var _context3, _context4;
216
216
  // ignore PathItemElement without $ref field
217
217
  if (!isStringElement(pathItemElement.$ref)) {
218
218
  return undefined;
219
219
  }
220
220
 
221
221
  // skip current referencing element as it's already been access
222
- if (this.indirections.includes(pathItemElement)) {
222
+ if (_includesInstanceProperty(_context3 = this.indirections).call(_context3, pathItemElement)) {
223
223
  return false;
224
224
  }
225
225
 
@@ -271,12 +271,11 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
271
271
  }
272
272
 
273
273
  // detect second deep dive into the same fragment and avoid it
274
- if (ancestorsLineage.includes(referencedElement)) {
274
+ if (_includesInstanceProperty(ancestorsLineage).call(ancestorsLineage, referencedElement)) {
275
275
  reference.refSet.circular = true;
276
276
  if (this.options.dereference.circular === 'error') {
277
277
  throw new ApiDOMError('Circular reference detected');
278
278
  } else if (this.options.dereference.circular === 'replace') {
279
- var _this$options$derefer5, _this$options$derefer6;
280
279
  const refElement = new RefElement(referencedElement.id, {
281
280
  type: 'path-item',
282
281
  uri: reference.uri,
@@ -284,7 +283,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
284
283
  baseURI: $refBaseURI,
285
284
  referencingElement: pathItemElement
286
285
  });
287
- const replacer = (_this$options$derefer5 = (_this$options$derefer6 = this.options.dereference.strategyOpts['openapi-3-2']) === null || _this$options$derefer6 === void 0 ? void 0 : _this$options$derefer6.circularReplacer) !== null && _this$options$derefer5 !== void 0 ? _this$options$derefer5 : this.options.dereference.circularReplacer;
286
+ const replacer = this.options.dereference.strategyOpts['openapi-3-2']?.circularReplacer ?? this.options.dereference.circularReplacer;
288
287
  const replacement = replacer(refElement);
289
288
  link.replaceWith(refElement, mutationReplacer);
290
289
  return !parent ? replacement : false;
@@ -301,9 +300,8 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
301
300
  * 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
302
301
  */
303
302
  const isNonRootDocument = url.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
304
- const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
303
+ const shouldDetectCircular = _includesInstanceProperty(_context4 = ['error', 'replace']).call(_context4, this.options.dereference.circular);
305
304
  if ((isExternalReference || isNonRootDocument || isPathItemElement(referencedElement) && isStringElement(referencedElement.$ref) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
306
- var _this$basePath3;
307
305
  // append referencing schema to ancestors lineage
308
306
  directAncestors.add(pathItemElement);
309
307
 
@@ -316,7 +314,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
316
314
  ancestors: ancestorsLineage,
317
315
  allowMetaPatches: this.allowMetaPatches,
318
316
  useCircularStructures: this.useCircularStructures,
319
- basePath: (_this$basePath3 = this.basePath) !== null && _this$basePath3 !== void 0 ? _this$basePath3 : [...toPath([...ancestors, parent, pathItemElement]), '$ref']
317
+ basePath: this.basePath ?? [...toPath([...ancestors, parent, pathItemElement]), '$ref']
320
318
  });
321
319
  referencedElement = await visitAsync(referencedElement, visitor, {
322
320
  keyMap,
@@ -370,20 +368,20 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
370
368
  */
371
369
  return !parent ? referencedElement : undefined;
372
370
  } catch (error) {
373
- var _this$basePath4, _this$options$derefer7, _this$options$derefer8;
374
371
  const rootCause = getRootCause(error);
375
372
  const wrappedError = wrapError(rootCause, {
376
373
  baseDoc: this.reference.uri,
377
374
  $ref: toValue(pathItemElement.$ref),
378
375
  pointer: URIFragmentIdentifier.fromURIReference(toValue(pathItemElement.$ref)),
379
- fullPath: (_this$basePath4 = this.basePath) !== null && _this$basePath4 !== void 0 ? _this$basePath4 : [...toPath([...ancestors, parent, pathItemElement]), '$ref']
376
+ fullPath: this.basePath ?? [...toPath([...ancestors, parent, pathItemElement]), '$ref']
380
377
  });
381
- (_this$options$derefer7 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer7 === void 0 || (_this$options$derefer7 = _this$options$derefer7.errors) === null || _this$options$derefer7 === void 0 || (_this$options$derefer8 = _this$options$derefer7.push) === null || _this$options$derefer8 === void 0 || _this$options$derefer8.call(_this$options$derefer7, wrappedError);
378
+ this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
382
379
  return undefined;
383
380
  }
384
381
  }
385
382
  async SchemaElement(referencingElement, key, parent, path, ancestors, link) {
386
383
  try {
384
+ var _context5, _context6;
387
385
  // skip current referencing schema as $ref keyword was not defined
388
386
  if (!isStringElement(referencingElement.$ref)) {
389
387
  // skip traversing this schema but traverse all it's child schemas
@@ -391,7 +389,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
391
389
  }
392
390
 
393
391
  // skip current referencing element as it's already been access
394
- if (this.indirections.includes(referencingElement)) {
392
+ if (_includesInstanceProperty(_context5 = this.indirections).call(_context5, referencingElement)) {
395
393
  return false;
396
394
  }
397
395
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
@@ -523,12 +521,11 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
523
521
  }
524
522
 
525
523
  // detect second deep dive into the same fragment and avoid it
526
- if (ancestorsLineage.includes(referencedElement)) {
524
+ if (_includesInstanceProperty(ancestorsLineage).call(ancestorsLineage, referencedElement)) {
527
525
  reference.refSet.circular = true;
528
526
  if (this.options.dereference.circular === 'error') {
529
527
  throw new ApiDOMError('Circular reference detected');
530
528
  } else if (this.options.dereference.circular === 'replace') {
531
- var _this$options$derefer9, _this$options$derefer0;
532
529
  const refElement = new RefElement(referencedElement.id, {
533
530
  type: 'json-schema',
534
531
  uri: reference.uri,
@@ -536,7 +533,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
536
533
  baseURI: url.resolve(retrievalURI, $refBaseURI),
537
534
  referencingElement
538
535
  });
539
- const replacer = (_this$options$derefer9 = (_this$options$derefer0 = this.options.dereference.strategyOpts['openapi-3-2']) === null || _this$options$derefer0 === void 0 ? void 0 : _this$options$derefer0.circularReplacer) !== null && _this$options$derefer9 !== void 0 ? _this$options$derefer9 : this.options.dereference.circularReplacer;
536
+ const replacer = this.options.dereference.strategyOpts['openapi-3-2']?.circularReplacer ?? this.options.dereference.circularReplacer;
540
537
  const replacement = replacer(refElement);
541
538
  link.replaceWith(replacement, mutationReplacer);
542
539
  return !parent ? replacement : false;
@@ -553,9 +550,8 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
553
550
  * 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
554
551
  */
555
552
  const isNonRootDocument = url.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
556
- const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
553
+ const shouldDetectCircular = _includesInstanceProperty(_context6 = ['error', 'replace']).call(_context6, this.options.dereference.circular);
557
554
  if ((isExternalReference || isNonRootDocument || isSchemaElement(referencedElement) && isStringElement(referencedElement.$ref) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
558
- var _this$basePath5;
559
555
  // append referencing schema to ancestors lineage
560
556
  directAncestors.add(referencingElement);
561
557
 
@@ -568,7 +564,7 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
568
564
  useCircularStructures: this.useCircularStructures,
569
565
  allowMetaPatches: this.allowMetaPatches,
570
566
  ancestors: ancestorsLineage,
571
- basePath: (_this$basePath5 = this.basePath) !== null && _this$basePath5 !== void 0 ? _this$basePath5 : [...toPath([...ancestors, parent, referencingElement]), '$ref']
567
+ basePath: this.basePath ?? [...toPath([...ancestors, parent, referencingElement]), '$ref']
572
568
  });
573
569
  referencedElement = await visitAsync(referencedElement, mergeVisitor, {
574
570
  keyMap,
@@ -635,15 +631,14 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
635
631
  */
636
632
  return !parent ? referencedElement : undefined;
637
633
  } catch (error) {
638
- var _this$basePath6, _this$options$derefer1, _this$options$derefer10;
639
634
  const rootCause = getRootCause(error);
640
635
  const wrappedError = new SchemaRefError(`Could not resolve reference: ${rootCause.message}`, {
641
636
  baseDoc: this.reference.uri,
642
637
  $ref: toValue(referencingElement.$ref),
643
- fullPath: (_this$basePath6 = this.basePath) !== null && _this$basePath6 !== void 0 ? _this$basePath6 : [...toPath([...ancestors, parent, referencingElement]), '$ref'],
638
+ fullPath: this.basePath ?? [...toPath([...ancestors, parent, referencingElement]), '$ref'],
644
639
  cause: rootCause
645
640
  });
646
- (_this$options$derefer1 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer1 === void 0 || (_this$options$derefer1 = _this$options$derefer1.errors) === null || _this$options$derefer1 === void 0 || (_this$options$derefer10 = _this$options$derefer1.push) === null || _this$options$derefer10 === void 0 || _this$options$derefer10.call(_this$options$derefer1, wrappedError);
641
+ this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
647
642
  return undefined;
648
643
  }
649
644
  }
@@ -661,14 +656,13 @@ class OpenAPI3_2SwaggerClientDereferenceVisitor extends OpenAPI3_2DereferenceVis
661
656
  try {
662
657
  return await super.ExampleElement(exampleElement, key, parent, path, ancestors, link);
663
658
  } catch (error) {
664
- var _this$basePath7, _this$options$derefer11, _this$options$derefer12;
665
659
  const rootCause = getRootCause(error);
666
660
  const wrappedError = wrapError(rootCause, {
667
661
  baseDoc: this.reference.uri,
668
662
  externalValue: toValue(exampleElement.externalValue),
669
- fullPath: (_this$basePath7 = this.basePath) !== null && _this$basePath7 !== void 0 ? _this$basePath7 : [...toPath([...ancestors, parent, exampleElement]), 'externalValue']
663
+ fullPath: this.basePath ?? [...toPath([...ancestors, parent, exampleElement]), 'externalValue']
670
664
  });
671
- (_this$options$derefer11 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer11 === void 0 || (_this$options$derefer11 = _this$options$derefer11.errors) === null || _this$options$derefer11 === void 0 || (_this$options$derefer12 = _this$options$derefer11.push) === null || _this$options$derefer12 === void 0 || _this$options$derefer12.call(_this$options$derefer11, wrappedError);
665
+ this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
672
666
  return undefined;
673
667
  }
674
668
  }
@@ -20,12 +20,11 @@ class ParameterMacroVisitor {
20
20
  const macroValue = this.parameterMacro(pojoOperation, pojoParameter);
21
21
  parameterElement.set('default', macroValue);
22
22
  } catch (error) {
23
- var _this$options$derefer, _this$options$derefer2;
24
23
  const macroError = new Error(error, {
25
24
  cause: error
26
25
  });
27
26
  macroError.fullPath = toPath([...ancestors, parent]);
28
- (_this$options$derefer = this.options.dereference.dereferenceOpts) === null || _this$options$derefer === void 0 || (_this$options$derefer = _this$options$derefer.errors) === null || _this$options$derefer === void 0 || (_this$options$derefer2 = _this$options$derefer.push) === null || _this$options$derefer2 === void 0 || _this$options$derefer2.call(_this$options$derefer, macroError);
27
+ this.options.dereference.dereferenceOpts?.errors?.push?.(macroError);
29
28
  }
30
29
  }
31
30
  };
@@ -13,12 +13,11 @@ class ModelPropertyMacroVisitor {
13
13
  const macroValue = this.modelPropertyMacro(toValue(property));
14
14
  property.set('default', macroValue);
15
15
  } catch (error) {
16
- var _this$options$derefer, _this$options$derefer2;
17
16
  const macroError = new Error(error, {
18
17
  cause: error
19
18
  });
20
19
  macroError.fullPath = [...toPath([...ancestors, parent, schemaElement]), 'properties'];
21
- (_this$options$derefer = this.options.dereference.dereferenceOpts) === null || _this$options$derefer === void 0 || (_this$options$derefer = _this$options$derefer.errors) === null || _this$options$derefer === void 0 || (_this$options$derefer2 = _this$options$derefer.push) === null || _this$options$derefer2 === void 0 || _this$options$derefer2.call(_this$options$derefer, macroError);
20
+ this.options.dereference.dereferenceOpts?.errors?.push?.(macroError);
22
21
  }
23
22
  });
24
23
  }
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  import { from, ParseResultElement } from '@swagger-api/apidom-core';
2
3
  import { ParserError, Parser } from '@swagger-api/apidom-reference/configuration/empty';
3
4
  class JSONParser extends Parser {
@@ -9,8 +10,9 @@ class JSONParser extends Parser {
9
10
  });
10
11
  }
11
12
  async canParse(file) {
12
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
13
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
13
+ var _context, _context2;
14
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
15
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
14
16
  if (!hasSupportedFileExtension) return false;
15
17
  if (hasSupportedMediaType) return true;
16
18
  if (!hasSupportedMediaType) {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /* eslint-disable camelcase */
2
3
  import { ParseResultElement } from '@swagger-api/apidom-core';
3
4
  import { ParserError, Parser } from '@swagger-api/apidom-reference/configuration/empty';
@@ -12,8 +13,9 @@ class OpenAPIJSON3_1Parser extends Parser {
12
13
  });
13
14
  }
14
15
  async canParse(file) {
15
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
16
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
16
+ var _context, _context2;
17
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
18
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
17
19
  if (!hasSupportedFileExtension) return false;
18
20
  if (hasSupportedMediaType) return true;
19
21
  if (!hasSupportedMediaType) {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /* eslint-disable camelcase */
2
3
  import { ParseResultElement } from '@swagger-api/apidom-core';
3
4
  import { ParserError, Parser } from '@swagger-api/apidom-reference/configuration/empty';
@@ -12,8 +13,9 @@ class OpenAPIJSON3_2Parser extends Parser {
12
13
  });
13
14
  }
14
15
  async canParse(file) {
15
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
16
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
16
+ var _context, _context2;
17
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
18
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
17
19
  if (!hasSupportedFileExtension) return false;
18
20
  if (hasSupportedMediaType) return true;
19
21
  if (!hasSupportedMediaType) {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /* eslint-disable camelcase */
2
3
  import YAML, { JSON_SCHEMA } from 'js-yaml';
3
4
  import { ParseResultElement } from '@swagger-api/apidom-core';
@@ -13,8 +14,9 @@ class OpenAPIYAML31Parser extends Parser {
13
14
  });
14
15
  }
15
16
  async canParse(file) {
16
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
17
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
17
+ var _context, _context2;
18
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
19
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
18
20
  if (!hasSupportedFileExtension) return false;
19
21
  if (hasSupportedMediaType) return true;
20
22
  if (!hasSupportedMediaType) {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /* eslint-disable camelcase */
2
3
  import YAML, { JSON_SCHEMA } from 'js-yaml';
3
4
  import { ParseResultElement } from '@swagger-api/apidom-core';
@@ -13,8 +14,9 @@ class OpenAPIYAML32Parser extends Parser {
13
14
  });
14
15
  }
15
16
  async canParse(file) {
16
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
17
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
17
+ var _context, _context2;
18
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
19
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
18
20
  if (!hasSupportedFileExtension) return false;
19
21
  if (hasSupportedMediaType) return true;
20
22
  if (!hasSupportedMediaType) {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  import YAML, { JSON_SCHEMA } from 'js-yaml';
2
3
  import { from, ParseResultElement } from '@swagger-api/apidom-core';
3
4
  import { ParserError, Parser } from '@swagger-api/apidom-reference/configuration/empty';
@@ -10,8 +11,9 @@ class YAMLParser extends Parser {
10
11
  });
11
12
  }
12
13
  async canParse(file) {
13
- const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : this.fileExtensions.includes(file.extension);
14
- const hasSupportedMediaType = this.mediaTypes.includes(file.mediaType);
14
+ var _context, _context2;
15
+ const hasSupportedFileExtension = this.fileExtensions.length === 0 ? true : _includesInstanceProperty(_context = this.fileExtensions).call(_context, file.extension);
16
+ const hasSupportedMediaType = _includesInstanceProperty(_context2 = this.mediaTypes).call(_context2, file.mediaType);
15
17
  if (!hasSupportedFileExtension) return false;
16
18
  if (hasSupportedMediaType) return true;
17
19
  if (!hasSupportedMediaType) {
@@ -1,5 +1,4 @@
1
1
  import { ResolverError, HTTPResolver } from '@swagger-api/apidom-reference/configuration/empty';
2
- import '../../../../../../helpers/fetch-polyfill.node.js';
3
2
  import '../../../../../../helpers/abortcontroller-polyfill.node.js';
4
3
  import Http from '../../../../../../http/index.js';
5
4
  class HTTPResolverSwaggerClient extends HTTPResolver {
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  import traverse from 'neotraverse/legacy';
2
3
  import { url } from '@swagger-api/apidom-reference/configuration/empty';
3
4
  import { DEFAULT_BASE_URL } from '../../constants.js';
@@ -40,7 +41,7 @@ export function generateAbsoluteRefPatches(obj, basePath, {
40
41
  } = {}) {
41
42
  const patches = [];
42
43
  traverse(obj).forEach(function callback() {
43
- if (targetKeys.includes(this.key) && typeof this.node === 'string') {
44
+ if (_includesInstanceProperty(targetKeys).call(targetKeys, this.key) && typeof this.node === 'string') {
44
45
  const nodePath = this.path; // this node's path, relative to `obj`
45
46
  const fullPath = basePath.concat(this.path);
46
47
  const absolutifiedRefValue = absolutifyPointer(this.node, getBaseUrlForNodePath(nodePath));
@@ -51,8 +52,8 @@ export function generateAbsoluteRefPatches(obj, basePath, {
51
52
  }
52
53
  export function absolutifyPointer(pointer, baseUrl) {
53
54
  const [urlPart, fragmentPart] = pointer.split('#');
54
- const safeBaseUrl = baseUrl !== null && baseUrl !== void 0 ? baseUrl : '';
55
- const safeUrlPart = urlPart !== null && urlPart !== void 0 ? urlPart : '';
55
+ const safeBaseUrl = baseUrl ?? '';
56
+ const safeUrlPart = urlPart ?? '';
56
57
  let newRefUrlPart;
57
58
  if (!url.isHttpUrl(safeBaseUrl)) {
58
59
  const absoluteBaseUrl = url.resolve(DEFAULT_BASE_URL, safeBaseUrl);
@@ -1,7 +1,6 @@
1
1
  import jsYaml from 'js-yaml';
2
2
  import { ApiDOMStructuredError } from '@swagger-api/apidom-error';
3
3
  import { url } from '@swagger-api/apidom-reference/configuration/empty';
4
- import '../../../helpers/fetch-polyfill.node.js';
5
4
  import lib from './index.js';
6
5
  import { isFreelyNamed, absolutifyPointer } from '../helpers.js';
7
6
  import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../../constants.js';
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  import { isPlainObject } from 'ramda-adjunct';
2
3
  import opId from '../../../helpers/op-id.js';
3
4
  export default function normalize(parsedSpec) {
@@ -14,16 +15,18 @@ export default function normalize(parsedSpec) {
14
15
 
15
16
  // eslint-disable-next-line no-restricted-syntax, guard-for-in
16
17
  for (const pathName in paths) {
18
+ var _context;
17
19
  const path = paths[pathName];
18
- if (path == null || !['object', 'function'].includes(typeof path)) {
20
+ if (path == null || !_includesInstanceProperty(_context = ['object', 'function']).call(_context, typeof path)) {
19
21
  continue; // eslint-disable-line no-continue
20
22
  }
21
23
  const pathParameters = path.parameters;
22
24
 
23
25
  // eslint-disable-next-line no-restricted-syntax, guard-for-in
24
26
  for (const method in path) {
27
+ var _context2;
25
28
  const operation = path[method];
26
- if (operation == null || !['object', 'function'].includes(typeof operation)) {
29
+ if (operation == null || !_includesInstanceProperty(_context2 = ['object', 'function']).call(_context2, typeof operation)) {
27
30
  continue; // eslint-disable-line no-continue
28
31
  }
29
32
  const oid = opId(operation, pathName, method);
@@ -1,6 +1,5 @@
1
1
  import Http from '../../http/index.js';
2
2
  export const retrievalURI = options => {
3
- var _ref, _globalThis$document;
4
3
  /**
5
4
  * Swagger-UI uses baseDoc instead of url, this helper function exists
6
5
  * to allow both.
@@ -13,8 +12,8 @@ export const retrievalURI = options => {
13
12
  baseDoc,
14
13
  url
15
14
  } = options;
16
- const retrievalURL = (_ref = baseDoc !== null && baseDoc !== void 0 ? baseDoc : url) !== null && _ref !== void 0 ? _ref : '';
17
- return typeof ((_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.baseURI) === 'string' ? String(new URL(retrievalURL, globalThis.document.baseURI)) : retrievalURL;
15
+ const retrievalURL = baseDoc ?? url ?? '';
16
+ return typeof globalThis.document?.baseURI === 'string' ? String(new URL(retrievalURL, globalThis.document.baseURI)) : retrievalURL;
18
17
  };
19
18
  export const httpClient = options => {
20
19
  const {
@@ -56,7 +56,7 @@ const resolveSubtree = async (obj, path, options = {}) => {
56
56
  skipNormalization: !isOpenAPI31(obj)
57
57
  });
58
58
  if (!returnEntireTree && Array.isArray(path) && path.length) {
59
- result.spec = path.reduce((acc, pathSegment) => acc === null || acc === void 0 ? void 0 : acc[pathSegment], result.spec) || null;
59
+ result.spec = path.reduce((acc, pathSegment) => acc?.[pathSegment], result.spec) || null;
60
60
  }
61
61
  return result;
62
62
  };
@@ -7,6 +7,7 @@ exports.baseUrl = baseUrl;
7
7
  exports.buildRequest = buildRequest;
8
8
  exports.execute = execute;
9
9
  exports.self = void 0;
10
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
10
11
  var _ramda = require("ramda");
11
12
  var _ramdaAdjunct = require("ramda-adjunct");
12
13
  var _openapiServerUrlTemplating = require("openapi-server-url-templating");
@@ -27,10 +28,11 @@ const findObjectOrArraySchema = (schema, {
27
28
  recurse = true,
28
29
  depth = 1
29
30
  } = {}) => {
31
+ var _context, _context2;
30
32
  if (!(0, _ramdaAdjunct.isPlainObject)(schema)) return undefined;
31
33
 
32
34
  // check if the schema is an object or array type
33
- if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && (schema.type.includes('object') || schema.type.includes('array'))) {
35
+ if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && ((0, _includes.default)(_context = schema.type).call(_context, 'object') || (0, _includes.default)(_context2 = schema.type).call(_context2, 'array'))) {
34
36
  return schema;
35
37
  }
36
38
  if (depth > _constants.TRAVERSE_LIMIT) return undefined;
@@ -222,7 +224,7 @@ function buildRequest(options) {
222
224
  method,
223
225
  pathName
224
226
  } = operationRaw;
225
- baseURL = baseURL != null ? baseURL : baseUrl({
227
+ baseURL = baseURL ?? baseUrl({
226
228
  spec,
227
229
  scheme,
228
230
  contextUrl,
@@ -368,15 +370,14 @@ function oas3BaseUrl({
368
370
  serverVariables = {},
369
371
  serverVariableEncoder
370
372
  }) {
371
- var _spec$paths, _spec$paths2;
372
373
  let servers = [];
373
374
  let selectedServerUrl = '';
374
375
  let selectedServerObj;
375
376
 
376
377
  // compute the servers (this will be taken care of by ApiDOM refrator plugins in future
377
- const operationLevelServers = spec == null || (_spec$paths = spec.paths) == null || (_spec$paths = _spec$paths[pathName]) == null || (_spec$paths = _spec$paths[(method || '').toLowerCase()]) == null ? void 0 : _spec$paths.servers;
378
- const pathItemLevelServers = spec == null || (_spec$paths2 = spec.paths) == null || (_spec$paths2 = _spec$paths2[pathName]) == null ? void 0 : _spec$paths2.servers;
379
- const rootLevelServers = spec == null ? void 0 : spec.servers;
378
+ const operationLevelServers = spec?.paths?.[pathName]?.[(method || '').toLowerCase()]?.servers;
379
+ const pathItemLevelServers = spec?.paths?.[pathName]?.servers;
380
+ const rootLevelServers = spec?.servers;
380
381
  servers = isNonEmptyServerList(operationLevelServers) // eslint-disable-line no-nested-ternary
381
382
  ? operationLevelServers : isNonEmptyServerList(pathItemLevelServers) // eslint-disable-line no-nested-ternary
382
383
  ? pathItemLevelServers : isNonEmptyServerList(rootLevelServers) ? rootLevelServers : [_constants.DEFAULT_OPENAPI_3_SERVER];
@@ -64,8 +64,7 @@ function buildRequest(options, req) {
64
64
  // contentType that has been explicitly set
65
65
  if (requestContentType === 'application/x-www-form-urlencoded' || requestContentType === 'multipart/form-data') {
66
66
  if (typeof requestBody === 'object') {
67
- var _requestBodyDef$conte, _requestBodyDef$conte2;
68
- const encoding = (_requestBodyDef$conte = (_requestBodyDef$conte2 = requestBodyDef.content[requestContentType]) == null ? void 0 : _requestBodyDef$conte2.encoding) != null ? _requestBodyDef$conte : {};
67
+ const encoding = requestBodyDef.content[requestContentType]?.encoding ?? {};
69
68
  req.form = {};
70
69
  Object.keys(requestBody).forEach(k => {
71
70
  let value;
@@ -80,8 +79,7 @@ function buildRequest(options, req) {
80
79
  };
81
80
  });
82
81
  } else if (typeof requestBody === 'string') {
83
- var _requestBodyDef$conte3, _requestBodyDef$conte4;
84
- const encoding = (_requestBodyDef$conte3 = (_requestBodyDef$conte4 = requestBodyDef.content[requestContentType]) == null ? void 0 : _requestBodyDef$conte4.encoding) != null ? _requestBodyDef$conte3 : {};
82
+ const encoding = requestBodyDef.content[requestContentType]?.encoding ?? {};
85
83
  try {
86
84
  req.form = {};
87
85
  const form = JSON.parse(requestBody);
@@ -116,7 +114,6 @@ function applySecurities({
116
114
  operation = {},
117
115
  spec
118
116
  }) {
119
- var _spec$components;
120
117
  const result = {
121
118
  ...request
122
119
  };
@@ -125,7 +122,7 @@ function applySecurities({
125
122
  } = securities;
126
123
  const security = operation.security || spec.security || [];
127
124
  const isAuthorized = authorized && !!Object.keys(authorized).length;
128
- const securityDef = (spec == null || (_spec$components = spec.components) == null ? void 0 : _spec$components.securitySchemes) || {};
125
+ const securityDef = spec?.components?.securitySchemes || {};
129
126
  result.headers = result.headers || {};
130
127
  result.query = result.query || {};
131
128
  if (!Object.keys(securities).length || !isAuthorized || !security || Array.isArray(operation.security) && !operation.security.length) {
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
3
4
  exports.__esModule = true;
4
5
  exports.default = serialize;
6
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
5
7
  /*
6
8
  Serializer that serializes according to a media type instead of OpenAPI's
7
9
  `style` + `explode` constructs.
8
10
  */
9
11
 
10
12
  function serialize(value, mediaType) {
11
- if (mediaType.includes('application/json')) {
13
+ if ((0, _includes.default)(mediaType).call(mediaType, 'application/json')) {
12
14
  if (typeof value === 'string') {
13
15
  // Assume the user has a JSON string
14
16
  return value;
@@ -41,7 +41,7 @@ function path({
41
41
  key: parameter.name,
42
42
  value: val,
43
43
  style: style || 'simple',
44
- explode: explode != null ? explode : false,
44
+ explode: explode ?? false,
45
45
  escape: 'reserved'
46
46
  })
47
47
  });
@@ -135,13 +135,12 @@ function cookie({
135
135
  return;
136
136
  }
137
137
  if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
138
- var _parameter$explode;
139
138
  const serializedValue = (0, _styleSerializer.default)({
140
139
  key: parameter.name,
141
140
  value,
142
141
  escape: false,
143
142
  style: parameter.style || 'form',
144
- explode: (_parameter$explode = parameter.explode) != null ? _parameter$explode : false
143
+ explode: parameter.explode ?? false
145
144
  });
146
145
  const cookieValue = Array.isArray(value) && parameter.explode ? `${cookieName}=${serializedValue}` : serializedValue;
147
146
  req.headers.Cookie = (0, _cookie.serialize)({
@@ -46,7 +46,7 @@ function valueEncoder(value, escape = false) {
46
46
  if (escape && typeof value === 'string' && value.length > 0) {
47
47
  return encodeCharacters(value, escape);
48
48
  }
49
- return value != null ? value : '';
49
+ return value ?? '';
50
50
  }
51
51
  function encodeArray({
52
52
  key,
package/lib/http/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = http;
5
5
  exports.makeHttp = makeHttp;
6
- require("../helpers/fetch-polyfill.node.js");
7
6
  var _index = require("./serializers/request/index.js");
8
7
  var _index2 = require("./serializers/response/index.js");
9
8
  exports.serializeRes = _index2.serializeResponse;