swagger-client 3.37.2 → 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 +15 -16
  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
  import { identity, has } from 'ramda';
2
3
  import { isPlainObject, isNonEmptyString } from 'ramda-adjunct';
3
4
  import { test as testServerURLTemplate, substitute as substituteServerURLTemplate } from 'openapi-server-url-templating';
@@ -18,10 +19,11 @@ const findObjectOrArraySchema = (schema, {
18
19
  recurse = true,
19
20
  depth = 1
20
21
  } = {}) => {
22
+ var _context, _context2;
21
23
  if (!isPlainObject(schema)) return undefined;
22
24
 
23
25
  // check if the schema is an object or array type
24
- if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && (schema.type.includes('object') || schema.type.includes('array'))) {
26
+ if (schema.type === 'object' || schema.type === 'array' || Array.isArray(schema.type) && (_includesInstanceProperty(_context = schema.type).call(_context, 'object') || _includesInstanceProperty(_context2 = schema.type).call(_context2, 'array'))) {
25
27
  return schema;
26
28
  }
27
29
  if (depth > TRAVERSE_LIMIT) return undefined;
@@ -213,7 +215,7 @@ export function buildRequest(options) {
213
215
  method,
214
216
  pathName
215
217
  } = operationRaw;
216
- baseURL = baseURL !== null && baseURL !== void 0 ? baseURL : baseUrl({
218
+ baseURL = baseURL ?? baseUrl({
217
219
  spec,
218
220
  scheme,
219
221
  contextUrl,
@@ -359,15 +361,14 @@ function oas3BaseUrl({
359
361
  serverVariables = {},
360
362
  serverVariableEncoder
361
363
  }) {
362
- var _spec$paths, _spec$paths2;
363
364
  let servers = [];
364
365
  let selectedServerUrl = '';
365
366
  let selectedServerObj;
366
367
 
367
368
  // compute the servers (this will be taken care of by ApiDOM refrator plugins in future
368
- const operationLevelServers = spec === null || spec === void 0 || (_spec$paths = spec.paths) === null || _spec$paths === void 0 || (_spec$paths = _spec$paths[pathName]) === null || _spec$paths === void 0 || (_spec$paths = _spec$paths[(method || '').toLowerCase()]) === null || _spec$paths === void 0 ? void 0 : _spec$paths.servers;
369
- const pathItemLevelServers = spec === null || spec === void 0 || (_spec$paths2 = spec.paths) === null || _spec$paths2 === void 0 || (_spec$paths2 = _spec$paths2[pathName]) === null || _spec$paths2 === void 0 ? void 0 : _spec$paths2.servers;
370
- const rootLevelServers = spec === null || spec === void 0 ? void 0 : spec.servers;
369
+ const operationLevelServers = spec?.paths?.[pathName]?.[(method || '').toLowerCase()]?.servers;
370
+ const pathItemLevelServers = spec?.paths?.[pathName]?.servers;
371
+ const rootLevelServers = spec?.servers;
371
372
  servers = isNonEmptyServerList(operationLevelServers) // eslint-disable-line no-nested-ternary
372
373
  ? operationLevelServers : isNonEmptyServerList(pathItemLevelServers) // eslint-disable-line no-nested-ternary
373
374
  ? pathItemLevelServers : isNonEmptyServerList(rootLevelServers) ? rootLevelServers : [DEFAULT_OPENAPI_3_SERVER];
@@ -57,8 +57,7 @@ export default function buildRequest(options, req) {
57
57
  // contentType that has been explicitly set
58
58
  if (requestContentType === 'application/x-www-form-urlencoded' || requestContentType === 'multipart/form-data') {
59
59
  if (typeof requestBody === 'object') {
60
- var _requestBodyDef$conte, _requestBodyDef$conte2;
61
- const encoding = (_requestBodyDef$conte = (_requestBodyDef$conte2 = requestBodyDef.content[requestContentType]) === null || _requestBodyDef$conte2 === void 0 ? void 0 : _requestBodyDef$conte2.encoding) !== null && _requestBodyDef$conte !== void 0 ? _requestBodyDef$conte : {};
60
+ const encoding = requestBodyDef.content[requestContentType]?.encoding ?? {};
62
61
  req.form = {};
63
62
  Object.keys(requestBody).forEach(k => {
64
63
  let value;
@@ -73,8 +72,7 @@ export default function buildRequest(options, req) {
73
72
  };
74
73
  });
75
74
  } else if (typeof requestBody === 'string') {
76
- var _requestBodyDef$conte3, _requestBodyDef$conte4;
77
- const encoding = (_requestBodyDef$conte3 = (_requestBodyDef$conte4 = requestBodyDef.content[requestContentType]) === null || _requestBodyDef$conte4 === void 0 ? void 0 : _requestBodyDef$conte4.encoding) !== null && _requestBodyDef$conte3 !== void 0 ? _requestBodyDef$conte3 : {};
75
+ const encoding = requestBodyDef.content[requestContentType]?.encoding ?? {};
78
76
  try {
79
77
  req.form = {};
80
78
  const form = JSON.parse(requestBody);
@@ -109,7 +107,6 @@ export function applySecurities({
109
107
  operation = {},
110
108
  spec
111
109
  }) {
112
- var _spec$components;
113
110
  const result = {
114
111
  ...request
115
112
  };
@@ -118,7 +115,7 @@ export function applySecurities({
118
115
  } = securities;
119
116
  const security = operation.security || spec.security || [];
120
117
  const isAuthorized = authorized && !!Object.keys(authorized).length;
121
- const securityDef = (spec === null || spec === void 0 || (_spec$components = spec.components) === null || _spec$components === void 0 ? void 0 : _spec$components.securitySchemes) || {};
118
+ const securityDef = spec?.components?.securitySchemes || {};
122
119
  result.headers = result.headers || {};
123
120
  result.query = result.query || {};
124
121
  if (!Object.keys(securities).length || !isAuthorized || !security || Array.isArray(operation.security) && !operation.security.length) {
@@ -1,10 +1,11 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  /*
2
3
  Serializer that serializes according to a media type instead of OpenAPI's
3
4
  `style` + `explode` constructs.
4
5
  */
5
6
 
6
7
  export default function serialize(value, mediaType) {
7
- if (mediaType.includes('application/json')) {
8
+ if (_includesInstanceProperty(mediaType).call(mediaType, 'application/json')) {
8
9
  if (typeof value === 'string') {
9
10
  // Assume the user has a JSON string
10
11
  return value;
@@ -32,7 +32,7 @@ export function path({
32
32
  key: parameter.name,
33
33
  value: val,
34
34
  style: style || 'simple',
35
- explode: explode !== null && explode !== void 0 ? explode : false,
35
+ explode: explode ?? false,
36
36
  escape: 'reserved'
37
37
  })
38
38
  });
@@ -126,13 +126,12 @@ export function cookie({
126
126
  return;
127
127
  }
128
128
  if (value !== undefined && !(Array.isArray(value) && value.length === 0)) {
129
- var _parameter$explode;
130
129
  const serializedValue = stylize({
131
130
  key: parameter.name,
132
131
  value,
133
132
  escape: false,
134
133
  style: parameter.style || 'form',
135
- explode: (_parameter$explode = parameter.explode) !== null && _parameter$explode !== void 0 ? _parameter$explode : false
134
+ explode: parameter.explode ?? false
136
135
  });
137
136
  const cookieValue = Array.isArray(value) && parameter.explode ? `${cookieName}=${serializedValue}` : serializedValue;
138
137
  req.headers.Cookie = serializeCookie({
@@ -40,7 +40,7 @@ export function valueEncoder(value, escape = false) {
40
40
  if (escape && typeof value === 'string' && value.length > 0) {
41
41
  return encodeCharacters(value, escape);
42
42
  }
43
- return value !== null && value !== void 0 ? value : '';
43
+ return value ?? '';
44
44
  }
45
45
  function encodeArray({
46
46
  key,
package/es/http/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import '../helpers/fetch-polyfill.node.js';
2
1
  import { serializeRequest } from './serializers/request/index.js';
3
2
  import { serializeResponse } from './serializers/response/index.js';
4
3
  export { serializeResponse as serializeRes };
@@ -1,3 +1,4 @@
1
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
2
  import jsYaml from 'js-yaml';
2
3
  export const shouldDownloadAsText = (contentType = '') => /(json|xml|yaml|text)\b/.test(contentType);
3
4
  function parseBody(body, contentType) {
@@ -12,7 +13,7 @@ function parseBody(body, contentType) {
12
13
  return jsYaml.load(body);
13
14
  }
14
15
  function serializeHeaderValue(value) {
15
- const isMulti = value.includes(', ');
16
+ const isMulti = _includesInstanceProperty(value).call(value, ', ');
16
17
  return isMulti ? value.split(', ') : value;
17
18
  }
18
19
 
@@ -30,9 +30,8 @@ class OpenAPI3_1SwaggerClientDereferenceStrategy extends OpenAPI3_1DereferenceSt
30
30
  this.ancestors = [...ancestors];
31
31
  }
32
32
  async dereference(file, options) {
33
- var _options$dereference$;
34
33
  const namespace = createNamespace(openApi3_1Namespace);
35
- const immutableRefSet = (_options$dereference$ = options.dereference.refSet) !== null && _options$dereference$ !== void 0 ? _options$dereference$ : new ReferenceSet();
34
+ const immutableRefSet = options.dereference.refSet ?? new ReferenceSet();
36
35
  const mutableRefsSet = new ReferenceSet();
37
36
  let refSet = immutableRefSet;
38
37
  let reference;
@@ -11,10 +11,9 @@ class AllOfVisitor {
11
11
 
12
12
  // collect error and return if allOf keyword is not an array
13
13
  if (!isArrayElement(schemaElement.allOf)) {
14
- var _this$options$derefer, _this$options$derefer2;
15
14
  const error = new TypeError('allOf must be an array');
16
15
  error.fullPath = [...toPath([...ancestors, parent, schemaElement]), 'allOf'];
17
- (_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, error);
16
+ this.options.dereference.dereferenceOpts?.errors?.push?.(error);
18
17
  return undefined;
19
18
  }
20
19
 
@@ -27,10 +26,9 @@ class AllOfVisitor {
27
26
  // collect errors if allOf keyword contains anything else than Schema Object
28
27
  const includesSchemaElementOnly = schemaElement.allOf.content.every(isSchemaElement);
29
28
  if (!includesSchemaElementOnly) {
30
- var _this$options$derefer3, _this$options$derefer4;
31
29
  const error = new TypeError('Elements in allOf must be objects');
32
30
  error.fullPath = [...toPath([...ancestors, parent, schemaElement]), 'allOf'];
33
- (_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, error);
31
+ this.options.dereference.dereferenceOpts?.errors?.push?.(error);
34
32
  return undefined;
35
33
  }
36
34
  while (schemaElement.hasKey('allOf')) {
@@ -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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
113
114
  baseURI: $refBaseURI,
114
115
  referencingElement
115
116
  });
116
- const replacer = (_this$options$derefer = (_this$options$derefer2 = this.options.dereference.strategyOpts['openapi-3-1']) === 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-1']?.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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor({
@@ -144,7 +144,7 @@ class OpenAPI3_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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-1']) === 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-1']?.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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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-1']) === 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-1']?.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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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_1SwaggerClientDereferenceVisitor extends OpenAPI3_1DereferenceVis
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
  }
@@ -30,9 +30,8 @@ class OpenAPI3_2SwaggerClientDereferenceStrategy extends OpenAPI3_2DereferenceSt
30
30
  this.ancestors = [...ancestors];
31
31
  }
32
32
  async dereference(file, options) {
33
- var _options$dereference$;
34
33
  const namespace = createNamespace(openApi3_2Namespace);
35
- const immutableRefSet = (_options$dereference$ = options.dereference.refSet) !== null && _options$dereference$ !== void 0 ? _options$dereference$ : new ReferenceSet();
34
+ const immutableRefSet = options.dereference.refSet ?? new ReferenceSet();
36
35
  const mutableRefsSet = new ReferenceSet();
37
36
  let refSet = immutableRefSet;
38
37
  let reference;
@@ -11,10 +11,9 @@ class AllOfVisitor {
11
11
 
12
12
  // collect error and return if allOf keyword is not an array
13
13
  if (!isArrayElement(schemaElement.allOf)) {
14
- var _this$options$derefer, _this$options$derefer2;
15
14
  const error = new TypeError('allOf must be an array');
16
15
  error.fullPath = [...toPath([...ancestors, parent, schemaElement]), 'allOf'];
17
- (_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, error);
16
+ this.options.dereference.dereferenceOpts?.errors?.push?.(error);
18
17
  return undefined;
19
18
  }
20
19
 
@@ -27,10 +26,9 @@ class AllOfVisitor {
27
26
  // collect errors if allOf keyword contains anything else than Schema Object
28
27
  const includesSchemaElementOnly = schemaElement.allOf.content.every(isSchemaElement);
29
28
  if (!includesSchemaElementOnly) {
30
- var _this$options$derefer3, _this$options$derefer4;
31
29
  const error = new TypeError('Elements in allOf must be objects');
32
30
  error.fullPath = [...toPath([...ancestors, parent, schemaElement]), 'allOf'];
33
- (_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, error);
31
+ this.options.dereference.dereferenceOpts?.errors?.push?.(error);
34
32
  return undefined;
35
33
  }
36
34
  while (schemaElement.hasKey('allOf')) {