swagger-client 3.22.2 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/swagger-client.browser.js +1521 -2260
  2. package/dist/swagger-client.browser.min.js +1 -1
  3. package/dist/swagger-client.browser.min.js.map +1 -1
  4. package/es/constants.js +2 -2
  5. package/es/execute/index.js +2 -1
  6. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/utils/to-path.js +2 -2
  7. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +2 -2
  8. package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +168 -146
  9. package/es/resolver/strategies/openapi-3-1-apidom/resolve.js +2 -1
  10. package/es/specmap/helpers.js +4 -3
  11. package/lib/constants.js +3 -4
  12. package/lib/execute/index.js +3 -3
  13. package/lib/execute/swagger2/parameter-builders.js +1 -2
  14. package/lib/helpers/btoa.browser.js +1 -2
  15. package/lib/helpers/btoa.node.js +1 -2
  16. package/lib/helpers/fetch-ponyfill-undici.node.js +1 -2
  17. package/lib/helpers/replace-special-chars-with-underscore.js +1 -2
  18. package/lib/http/index.js +1 -2
  19. package/lib/index.js +2 -3
  20. package/lib/interfaces.js +1 -2
  21. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/errors/index.js +2 -3
  22. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js +2 -3
  23. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/utils/compose.js +2 -3
  24. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/utils/get-root-cause.js +1 -2
  25. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/utils/to-path.js +2 -3
  26. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/all-of.js +2 -3
  27. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +169 -148
  28. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/parameters.js +1 -2
  29. package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/properties.js +1 -2
  30. package/lib/resolver/apidom/reference/parse/parsers/json/index.js +1 -2
  31. package/lib/resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js +2 -3
  32. package/lib/resolver/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js +2 -3
  33. package/lib/resolver/apidom/reference/parse/parsers/yaml-1-2/index.js +1 -2
  34. package/lib/resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js +1 -2
  35. package/lib/resolver/index.js +2 -3
  36. package/lib/resolver/strategies/generic/index.js +1 -2
  37. package/lib/resolver/strategies/openapi-2/index.js +1 -2
  38. package/lib/resolver/strategies/openapi-3-0/index.js +1 -2
  39. package/lib/resolver/strategies/openapi-3-1-apidom/index.js +1 -2
  40. package/lib/resolver/strategies/openapi-3-1-apidom/normalize.js +2 -3
  41. package/lib/resolver/strategies/openapi-3-1-apidom/resolve.js +4 -4
  42. package/lib/specmap/helpers.js +4 -3
  43. package/lib/specmap/index.js +2 -3
  44. package/lib/specmap/lib/all-of.js +2 -3
  45. package/lib/specmap/lib/index.js +1 -2
  46. package/lib/specmap/lib/parameters.js +2 -3
  47. package/lib/specmap/lib/properties.js +2 -3
  48. package/lib/specmap/lib/refs.js +1 -2
  49. package/lib/subtree-resolver/index.js +2 -3
  50. package/package.json +8 -8
@@ -37,53 +37,47 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
37
37
  this.basePath = basePath;
38
38
  },
39
39
  methods: {
40
- async ReferenceElement(referenceElement, key, parent, path, ancestors) {
40
+ async ReferenceElement(referencingElement, key, parent, path, ancestors) {
41
41
  try {
42
- var _this$basePath, _referenceElement$$re, _referenceElement$des, _referenceElement$sum;
42
+ var _this$basePath;
43
43
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
44
44
 
45
- // skip already identified cycled Path Item Objects
46
- if ((0, _apidomCore.includesClasses)(['cycle'], referenceElement.$ref)) {
47
- return false;
48
- }
49
-
50
45
  // detect possible cycle in traversal and avoid it
51
- if (ancestorsLineage.some(ancs => ancs.has(referenceElement))) {
52
- // skip processing this schema and all it's child schemas
46
+ if (ancestorsLineage.includesCycle(referencingElement)) {
53
47
  return false;
54
48
  }
55
49
 
56
50
  // ignore resolving external Reference Objects
57
- if (!this.options.resolve.external && (0, _apidomNsOpenapi.isReferenceElementExternal)(referenceElement)) {
51
+ if (!this.options.resolve.external && (0, _apidomNsOpenapi.isReferenceElementExternal)(referencingElement)) {
58
52
  return false;
59
53
  }
60
- const reference = await this.toReference(referenceElement.$ref.toValue());
54
+ const reference = await this.toReference((0, _apidomCore.toValue)(referencingElement.$ref));
61
55
  const {
62
56
  uri: retrievalURI
63
57
  } = reference;
64
- const $refBaseURI = _empty.url.resolve(retrievalURI, referenceElement.$ref.toValue());
65
- this.indirections.push(referenceElement);
58
+ const $refBaseURI = _empty.url.resolve(retrievalURI, (0, _apidomCore.toValue)(referencingElement.$ref));
59
+ this.indirections.push(referencingElement);
66
60
  const jsonPointer = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
67
61
 
68
62
  // possibly non-semantic fragment
69
- let fragment = (0, _apidomJsonPointer.evaluate)(jsonPointer, reference.value.result);
63
+ let referencedElement = (0, _apidomJsonPointer.evaluate)(jsonPointer, reference.value.result);
70
64
 
71
65
  // applying semantics to a fragment
72
- if ((0, _apidomCore.isPrimitiveElement)(fragment)) {
73
- const referencedElementType = referenceElement.meta.get('referenced-element').toValue();
74
- if ((0, _apidomNsOpenapi.isReferenceLikeElement)(fragment)) {
66
+ if ((0, _apidomCore.isPrimitiveElement)(referencedElement)) {
67
+ const referencedElementType = (0, _apidomCore.toValue)(referencingElement.meta.get('referenced-element'));
68
+ if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
75
69
  // handling indirect references
76
- fragment = _apidomNsOpenapi.ReferenceElement.refract(fragment);
77
- fragment.setMetaProperty('referenced-element', referencedElementType);
70
+ referencedElement = _apidomNsOpenapi.ReferenceElement.refract(referencedElement);
71
+ referencedElement.setMetaProperty('referenced-element', referencedElementType);
78
72
  } else {
79
73
  // handling direct references
80
74
  const ElementClass = this.namespace.getElementClass(referencedElementType);
81
- fragment = ElementClass.refract(fragment);
75
+ referencedElement = ElementClass.refract(referencedElement);
82
76
  }
83
77
  }
84
78
 
85
79
  // detect direct or indirect reference
86
- if (this.indirections.includes(fragment)) {
80
+ if (this.indirections.includes(referencedElement)) {
87
81
  throw new Error('Recursive JSON Pointer detected');
88
82
  }
89
83
 
@@ -92,23 +86,21 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
92
86
  throw new _empty.MaximumDereferenceDepthError(`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
93
87
  }
94
88
  if (!this.useCircularStructures) {
95
- const hasCycles = ancestorsLineage.some(ancs => ancs.has(fragment));
89
+ const hasCycles = ancestorsLineage.includes(referencedElement);
96
90
  if (hasCycles) {
97
91
  if (_empty.url.isHttpUrl(retrievalURI) || _empty.url.isFileSystemPath(retrievalURI)) {
98
92
  // make the referencing URL or file system path absolute
99
- const cycledReferenceElement = new _apidomNsOpenapi.ReferenceElement({
93
+ return new _apidomNsOpenapi.ReferenceElement({
100
94
  $ref: $refBaseURI
101
- }, referenceElement.meta.clone(), referenceElement.attributes.clone());
102
- cycledReferenceElement.get('$ref').classes.push('cycle');
103
- return cycledReferenceElement;
95
+ }, (0, _apidomCore.cloneDeep)(referencingElement.meta), (0, _apidomCore.cloneDeep)(referencingElement.attributes));
104
96
  }
105
- // skip processing this schema and all it's child schemas
97
+ // skip processing this reference
106
98
  return false;
107
99
  }
108
100
  }
109
101
 
110
102
  // append referencing schema to ancestors lineage
111
- directAncestors.add(referenceElement);
103
+ directAncestors.add(referencingElement);
112
104
 
113
105
  // dive deep into the fragment
114
106
  const visitor = OpenApi3_1SwaggerClientDereferenceVisitor({
@@ -119,55 +111,78 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
119
111
  ancestors: ancestorsLineage,
120
112
  allowMetaPatches: this.allowMetaPatches,
121
113
  useCircularStructures: this.useCircularStructures,
122
- basePath: (_this$basePath = this.basePath) != null ? _this$basePath : [...(0, _toPath.default)([...ancestors, parent, referenceElement]), '$ref']
114
+ basePath: (_this$basePath = this.basePath) != null ? _this$basePath : [...(0, _toPath.default)([...ancestors, parent, referencingElement]), '$ref']
123
115
  });
124
- fragment = await visitAsync(fragment, visitor, {
116
+ referencedElement = await visitAsync(referencedElement, visitor, {
125
117
  keyMap: _apidomNsOpenapi.keyMap,
126
118
  nodeTypeGetter: _apidomNsOpenapi.getNodeType
127
119
  });
128
120
 
129
121
  // remove referencing schema from ancestors lineage
130
- directAncestors.delete(referenceElement);
122
+ directAncestors.delete(referencingElement);
131
123
  this.indirections.pop();
132
- fragment = fragment.clone();
133
- fragment.setMetaProperty('ref-fields', {
134
- $ref: (_referenceElement$$re = referenceElement.$ref) == null ? void 0 : _referenceElement$$re.toValue(),
135
- description: (_referenceElement$des = referenceElement.description) == null ? void 0 : _referenceElement$des.toValue(),
136
- summary: (_referenceElement$sum = referenceElement.summary) == null ? void 0 : _referenceElement$sum.toValue()
137
- });
138
- // annotate fragment with info about origin
139
- fragment.setMetaProperty('ref-origin', reference.uri);
140
-
141
- // override description and summary (outer has higher priority then inner)
142
- const hasDescription = typeof referenceElement.description !== 'undefined';
143
- const hasSummary = typeof referenceElement.summary !== 'undefined';
144
- if (hasDescription && 'description' in fragment) {
145
- fragment.description = referenceElement.description;
146
- }
147
- if (hasSummary && 'summary' in fragment) {
148
- fragment.summary = referenceElement.summary;
149
- }
124
+ const mergeAndAnnotateReferencedElement = refedElement => {
125
+ const copy = (0, _apidomCore.cloneShallow)(refedElement);
126
+
127
+ // annotate fragment with info about original Reference element
128
+ copy.setMetaProperty('ref-fields', {
129
+ $ref: (0, _apidomCore.toValue)(referencingElement.$ref),
130
+ // @ts-ignore
131
+ description: (0, _apidomCore.toValue)(referencingElement.description),
132
+ // @ts-ignore
133
+ summary: (0, _apidomCore.toValue)(referencingElement.summary)
134
+ });
135
+ // annotate fragment with info about origin
136
+ copy.setMetaProperty('ref-origin', reference.uri);
137
+
138
+ // override description and summary (outer has higher priority then inner)
139
+ if ((0, _apidomCore.isObjectElement)(refedElement)) {
140
+ if (referencingElement.hasKey('description') && 'description' in refedElement) {
141
+ // @ts-ignore
142
+ copy.remove('description');
143
+ // @ts-ignore
144
+ copy.set('description', referencingElement.get('description'));
145
+ }
146
+ if (referencingElement.hasKey('summary') && 'summary' in refedElement) {
147
+ // @ts-ignore
148
+ copy.remove('summary');
149
+ // @ts-ignore
150
+ copy.set('summary', referencingElement.get('summary'));
151
+ }
152
+ }
150
153
 
151
- // apply meta patches
152
- if (this.allowMetaPatches && (0, _apidomCore.isObjectElement)(fragment)) {
153
- const objectFragment = fragment;
154
- // apply meta patch only when not already applied
155
- if (typeof objectFragment.get('$$ref') === 'undefined') {
156
- const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
157
- objectFragment.set('$$ref', baseURI);
154
+ // apply meta patches
155
+ if (this.allowMetaPatches && (0, _apidomCore.isObjectElement)(copy)) {
156
+ // apply meta patch only when not already applied
157
+ if (!copy.hasKey('$$ref')) {
158
+ const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
159
+ copy.set('$$ref', baseURI);
160
+ }
161
+ }
162
+ return copy;
163
+ };
164
+
165
+ // attempting to create cycle
166
+ if (ancestorsLineage.includes(referencedElement)) {
167
+ if ((0, _apidomCore.isMemberElement)(parent)) {
168
+ parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
169
+ } else if (Array.isArray(parent)) {
170
+ parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
158
171
  }
172
+
173
+ return false;
159
174
  }
160
175
 
161
176
  // transclude the element for a fragment
162
- return fragment;
177
+ return mergeAndAnnotateReferencedElement(referencedElement);
163
178
  } catch (error) {
164
179
  var _this$basePath2, _this$options$derefer;
165
180
  const rootCause = (0, _getRootCause.default)(error);
166
181
  const wrappedError = wrapError(rootCause, {
167
182
  baseDoc: this.reference.uri,
168
- $ref: referenceElement.$ref.toValue(),
169
- pointer: (0, _apidomJsonPointer.uriToPointer)(referenceElement.$ref.toValue()),
170
- fullPath: (_this$basePath2 = this.basePath) != null ? _this$basePath2 : [...(0, _toPath.default)([...ancestors, parent, referenceElement]), '$ref']
183
+ $ref: (0, _apidomCore.toValue)(referencingElement.$ref),
184
+ pointer: (0, _apidomJsonPointer.uriToPointer)((0, _apidomCore.toValue)(referencingElement.$ref)),
185
+ fullPath: (_this$basePath2 = this.basePath) != null ? _this$basePath2 : [...(0, _toPath.default)([...ancestors, parent, referencingElement]), '$ref']
171
186
  });
172
187
  (_this$options$derefer = this.options.dereference.dereferenceOpts) == null || (_this$options$derefer = _this$options$derefer.errors) == null || _this$options$derefer.push == null || _this$options$derefer.push(wrappedError);
173
188
  return undefined;
@@ -175,7 +190,7 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
175
190
  },
176
191
  async PathItemElement(pathItemElement, key, parent, path, ancestors) {
177
192
  try {
178
- var _this$basePath3, _pathItemElement$$ref;
193
+ var _this$basePath3;
179
194
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
180
195
 
181
196
  // ignore PathItemElement without $ref field
@@ -183,14 +198,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
183
198
  return undefined;
184
199
  }
185
200
 
186
- // skip already identified cycled Path Item Objects
187
- if ((0, _apidomCore.includesClasses)(['cycle'], pathItemElement.$ref)) {
188
- return false;
189
- }
190
-
191
201
  // detect possible cycle in traversal and avoid it
192
- if (ancestorsLineage.some(ancs => ancs.has(pathItemElement))) {
193
- // skip processing this schema and all it's child schemas
202
+ if (ancestorsLineage.includesCycle(pathItemElement)) {
194
203
  return false;
195
204
  }
196
205
 
@@ -198,11 +207,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
198
207
  if (!this.options.resolve.external && (0, _apidomNsOpenapi.isPathItemElementExternal)(pathItemElement)) {
199
208
  return undefined;
200
209
  }
201
- const reference = await this.toReference(pathItemElement.$ref.toValue());
210
+ const reference = await this.toReference((0, _apidomCore.toValue)(pathItemElement.$ref));
202
211
  const {
203
212
  uri: retrievalURI
204
213
  } = reference;
205
- const $refBaseURI = _empty.url.resolve(retrievalURI, pathItemElement.$ref.toValue());
214
+ const $refBaseURI = _empty.url.resolve(retrievalURI, (0, _apidomCore.toValue)(pathItemElement.$ref));
206
215
  this.indirections.push(pathItemElement);
207
216
  const jsonPointer = (0, _apidomJsonPointer.uriToPointer)($refBaseURI);
208
217
 
@@ -224,17 +233,15 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
224
233
  throw new _empty.MaximumDereferenceDepthError(`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
225
234
  }
226
235
  if (!this.useCircularStructures) {
227
- const hasCycles = ancestorsLineage.some(ancs => ancs.has(referencedElement));
236
+ const hasCycles = ancestorsLineage.includes(referencedElement);
228
237
  if (hasCycles) {
229
238
  if (_empty.url.isHttpUrl(retrievalURI) || _empty.url.isFileSystemPath(retrievalURI)) {
230
239
  // make the referencing URL or file system path absolute
231
- const cycledPathItemElement = new _apidomNsOpenapi.PathItemElement({
240
+ return new _apidomNsOpenapi.PathItemElement({
232
241
  $ref: $refBaseURI
233
- }, pathItemElement.meta.clone(), pathItemElement.attributes.clone());
234
- cycledPathItemElement.get('$ref').classes.push('cycle');
235
- return cycledPathItemElement;
242
+ }, (0, _apidomCore.cloneDeep)(pathItemElement.meta), (0, _apidomCore.cloneDeep)(pathItemElement.attributes));
236
243
  }
237
- // skip processing this schema and all it's child schemas
244
+ // skip processing this path item and all it's child elements
238
245
  return false;
239
246
  }
240
247
  }
@@ -261,41 +268,54 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
261
268
  // remove referencing schema from ancestors lineage
262
269
  directAncestors.delete(pathItemElement);
263
270
  this.indirections.pop();
271
+ const mergeAndAnnotateReferencedElement = refedElement => {
272
+ // merge fields from referenced Path Item with referencing one
273
+ const mergedElement = new _apidomNsOpenapi.PathItemElement([...refedElement.content], (0, _apidomCore.cloneDeep)(refedElement.meta), (0, _apidomCore.cloneDeep)(refedElement.attributes));
274
+ // existing keywords from referencing PathItemElement overrides ones from referenced element
275
+ pathItemElement.forEach((value, keyElement, item) => {
276
+ mergedElement.remove((0, _apidomCore.toValue)(keyElement));
277
+ mergedElement.content.push(item);
278
+ });
279
+ mergedElement.remove('$ref');
264
280
 
265
- // merge fields from referenced Path Item with referencing one
266
- const mergedPathItemElement = new _apidomNsOpenapi.PathItemElement([...referencedElement.content], referencedElement.meta.clone(), referencedElement.attributes.clone());
267
- // existing keywords from referencing PathItemElement overrides ones from referenced element
268
- pathItemElement.forEach((valueElement, keyElement, item) => {
269
- mergedPathItemElement.remove(keyElement.toValue());
270
- mergedPathItemElement.content.push(item);
271
- });
272
- mergedPathItemElement.remove('$ref');
281
+ // annotate referenced element with info about original referencing element
282
+ mergedElement.setMetaProperty('ref-fields', {
283
+ $ref: (0, _apidomCore.toValue)(pathItemElement.$ref)
284
+ });
285
+ // annotate referenced element with info about origin
286
+ mergedElement.setMetaProperty('ref-origin', reference.uri);
273
287
 
274
- // annotate referenced element with info about original referencing element
275
- mergedPathItemElement.setMetaProperty('ref-fields', {
276
- $ref: (_pathItemElement$$ref = pathItemElement.$ref) == null ? void 0 : _pathItemElement$$ref.toValue()
277
- });
278
- // annotate referenced element with info about origin
279
- mergedPathItemElement.setMetaProperty('ref-origin', reference.uri);
280
-
281
- // apply meta patches
282
- if (this.allowMetaPatches) {
283
- // apply meta patch only when not already applied
284
- if (typeof mergedPathItemElement.get('$$ref') === 'undefined') {
285
- const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
286
- mergedPathItemElement.set('$$ref', baseURI);
288
+ // apply meta patches
289
+ if (this.allowMetaPatches) {
290
+ // apply meta patch only when not already applied
291
+ if (typeof mergedElement.get('$$ref') === 'undefined') {
292
+ const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
293
+ mergedElement.set('$$ref', baseURI);
294
+ }
295
+ }
296
+ return mergedElement;
297
+ };
298
+
299
+ // attempting to create cycle
300
+ if (ancestorsLineage.includes(referencedElement)) {
301
+ if ((0, _apidomCore.isMemberElement)(parent)) {
302
+ parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
303
+ } else if (Array.isArray(parent)) {
304
+ parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
287
305
  }
306
+
307
+ return false;
288
308
  }
289
309
 
290
310
  // transclude referencing element with merged referenced element
291
- return mergedPathItemElement;
311
+ return mergeAndAnnotateReferencedElement(referencedElement);
292
312
  } catch (error) {
293
313
  var _this$basePath4, _this$options$derefer2;
294
314
  const rootCause = (0, _getRootCause.default)(error);
295
315
  const wrappedError = wrapError(rootCause, {
296
316
  baseDoc: this.reference.uri,
297
- $ref: pathItemElement.$ref.toValue(),
298
- pointer: (0, _apidomJsonPointer.uriToPointer)(pathItemElement.$ref.toValue()),
317
+ $ref: (0, _apidomCore.toValue)(pathItemElement.$ref),
318
+ pointer: (0, _apidomJsonPointer.uriToPointer)((0, _apidomCore.toValue)(pathItemElement.$ref)),
299
319
  fullPath: (_this$basePath4 = this.basePath) != null ? _this$basePath4 : [...(0, _toPath.default)([...ancestors, parent, pathItemElement]), '$ref']
300
320
  });
301
321
  (_this$options$derefer2 = this.options.dereference.dereferenceOpts) == null || (_this$options$derefer2 = _this$options$derefer2.errors) == null || _this$options$derefer2.push == null || _this$options$derefer2.push(wrappedError);
@@ -304,7 +324,7 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
304
324
  },
305
325
  async SchemaElement(referencingElement, key, parent, path, ancestors) {
306
326
  try {
307
- var _this$basePath5, _referencingElement$$2;
327
+ var _this$basePath5;
308
328
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
309
329
 
310
330
  // skip current referencing schema as $ref keyword was not defined
@@ -313,14 +333,8 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
313
333
  return undefined;
314
334
  }
315
335
 
316
- // skip already identified cycled schemas
317
- if ((0, _apidomCore.includesClasses)(['cycle'], referencingElement.$ref)) {
318
- return false;
319
- }
320
-
321
336
  // detect possible cycle in traversal and avoid it
322
- if (ancestorsLineage.some(ancs => ancs.has(referencingElement))) {
323
- // skip processing this schema and all it's child schemas
337
+ if (ancestorsLineage.includesCycle(referencingElement)) {
324
338
  return false;
325
339
  }
326
340
 
@@ -400,11 +414,9 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
400
414
  if (_empty.url.isHttpUrl(retrievalURI) || _empty.url.isFileSystemPath(retrievalURI)) {
401
415
  // make the referencing URL or file system path absolute
402
416
  const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
403
- const cycledSchemaElement = new _apidomNsOpenapi.SchemaElement({
417
+ return new _apidomNsOpenapi.SchemaElement({
404
418
  $ref: baseURI
405
- }, referencingElement.meta.clone(), referencingElement.attributes.clone());
406
- cycledSchemaElement.get('$ref').classes.push('cycle');
407
- return cycledSchemaElement;
419
+ }, (0, _apidomCore.cloneDeep)(referencingElement.meta), (0, _apidomCore.cloneDeep)(referencingElement.attributes));
408
420
  }
409
421
  // skip processing this schema and all it's child schemas
410
422
  return false;
@@ -434,51 +446,61 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
434
446
  directAncestors.delete(referencingElement);
435
447
  this.indirections.pop();
436
448
  if ((0, _apidomNsOpenapi.isBooleanJsonSchemaElement)(referencedElement)) {
437
- var _referencingElement$$;
438
- // Boolean JSON Schema
439
- const jsonSchemaBooleanElement = referencedElement.clone();
449
+ const booleanJsonSchemaElement = (0, _apidomCore.cloneDeep)(referencedElement);
440
450
  // annotate referenced element with info about original referencing element
441
- jsonSchemaBooleanElement.setMetaProperty('ref-fields', {
442
- $ref: (_referencingElement$$ = referencingElement.$ref) == null ? void 0 : _referencingElement$$.toValue()
451
+ booleanJsonSchemaElement.setMetaProperty('ref-fields', {
452
+ $ref: (0, _apidomCore.toValue)(referencingElement.$ref)
443
453
  });
444
454
  // annotate referenced element with info about origin
445
- jsonSchemaBooleanElement.setMetaProperty('ref-origin', retrievalURI);
446
- return jsonSchemaBooleanElement;
455
+ booleanJsonSchemaElement.setMetaProperty('ref-origin', reference.uri);
456
+ return booleanJsonSchemaElement;
447
457
  }
458
+ const mergeAndAnnotateReferencedElement = refedElement => {
459
+ // Schema Object - merge keywords from referenced schema with referencing schema
460
+ const mergedElement = new _apidomNsOpenapi.SchemaElement([...refedElement.content], (0, _apidomCore.cloneDeep)(refedElement.meta), (0, _apidomCore.cloneDeep)(refedElement.attributes));
461
+ // existing keywords from referencing schema overrides ones from referenced schema
462
+ referencingElement.forEach((value, keyElement, item) => {
463
+ mergedElement.remove((0, _apidomCore.toValue)(keyElement));
464
+ mergedElement.content.push(item);
465
+ });
466
+ mergedElement.remove('$ref');
467
+ // annotate referenced element with info about original referencing element
468
+ mergedElement.setMetaProperty('ref-fields', {
469
+ $ref: (0, _apidomCore.toValue)(referencingElement.$ref)
470
+ });
471
+ // annotate fragment with info about origin
472
+ mergedElement.setMetaProperty('ref-origin', reference.uri);
448
473
 
449
- // Schema Object - merge keywords from referenced schema with referencing schema
450
- const mergedSchemaElement = new _apidomNsOpenapi.SchemaElement([...referencedElement.content], referencedElement.meta.clone(), referencedElement.attributes.clone());
451
- // existing keywords from referencing schema overrides ones from referenced schema
452
- referencingElement.forEach((memberValue, memberKey, member) => {
453
- mergedSchemaElement.remove(memberKey.toValue());
454
- mergedSchemaElement.content.push(member);
455
- });
456
- mergedSchemaElement.remove('$ref');
457
-
458
- // annotate referenced element with info about original referencing element
459
- mergedSchemaElement.setMetaProperty('ref-fields', {
460
- $ref: (_referencingElement$$2 = referencingElement.$ref) == null ? void 0 : _referencingElement$$2.toValue()
461
- });
462
- // annotate fragment with info about origin
463
- mergedSchemaElement.setMetaProperty('ref-origin', retrievalURI);
464
-
465
- // allowMetaPatches option processing
466
- if (this.allowMetaPatches) {
467
- // apply meta patch only when not already applied
468
- if (typeof mergedSchemaElement.get('$$ref') === 'undefined') {
469
- const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
470
- mergedSchemaElement.set('$$ref', baseURI);
474
+ // allowMetaPatches option processing
475
+ if (this.allowMetaPatches) {
476
+ // apply meta patch only when not already applied
477
+ if (typeof mergedElement.get('$$ref') === 'undefined') {
478
+ const baseURI = _empty.url.resolve(retrievalURI, $refBaseURI);
479
+ mergedElement.set('$$ref', baseURI);
480
+ }
471
481
  }
482
+ return mergedElement;
483
+ };
484
+
485
+ // attempting to create cycle
486
+ if (ancestorsLineage.includes(referencedElement)) {
487
+ if ((0, _apidomCore.isMemberElement)(parent)) {
488
+ parent.value = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
489
+ } else if (Array.isArray(parent)) {
490
+ parent[key] = mergeAndAnnotateReferencedElement(referencedElement); // eslint-disable-line no-param-reassign
491
+ }
492
+
493
+ return false;
472
494
  }
473
495
 
474
496
  // transclude referencing element with merged referenced element
475
- return mergedSchemaElement;
497
+ return mergeAndAnnotateReferencedElement(referencedElement);
476
498
  } catch (error) {
477
499
  var _this$basePath6, _this$options$derefer3;
478
500
  const rootCause = (0, _getRootCause.default)(error);
479
501
  const wrappedError = new _index.SchemaRefError(`Could not resolve reference: ${rootCause.message}`, {
480
502
  baseDoc: this.reference.uri,
481
- $ref: referencingElement.$ref.toValue(),
503
+ $ref: (0, _apidomCore.toValue)(referencingElement.$ref),
482
504
  fullPath: (_this$basePath6 = this.basePath) != null ? _this$basePath6 : [...(0, _toPath.default)([...ancestors, parent, referencingElement]), '$ref']
483
505
  }, rootCause);
484
506
  (_this$options$derefer3 = this.options.dereference.dereferenceOpts) == null || (_this$options$derefer3 = _this$options$derefer3.errors) == null || _this$options$derefer3.push == null || _this$options$derefer3.push(wrappedError);
@@ -497,11 +519,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
497
519
  try {
498
520
  return await _openapi.OpenApi3_1DereferenceVisitor.compose.methods.ExampleElement.call(this, exampleElement, key, parent, path, ancestors);
499
521
  } catch (error) {
500
- var _exampleElement$exter, _this$basePath7, _this$options$derefer4;
522
+ var _this$basePath7, _this$options$derefer4;
501
523
  const rootCause = (0, _getRootCause.default)(error);
502
524
  const wrappedError = wrapError(rootCause, {
503
525
  baseDoc: this.reference.uri,
504
- externalValue: (_exampleElement$exter = exampleElement.externalValue) == null ? void 0 : _exampleElement$exter.toValue(),
526
+ externalValue: (0, _apidomCore.toValue)(exampleElement.externalValue),
505
527
  fullPath: (_this$basePath7 = this.basePath) != null ? _this$basePath7 : [...(0, _toPath.default)([...ancestors, parent, exampleElement]), 'externalValue']
506
528
  });
507
529
  (_this$options$derefer4 = this.options.dereference.dereferenceOpts) == null || (_this$options$derefer4 = _this$options$derefer4.errors) == null || _this$options$derefer4.push == null || _this$options$derefer4.push(wrappedError);
@@ -510,6 +532,5 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _openapi.OpenApi3_1Dereference
510
532
  }
511
533
  }
512
534
  });
513
- var _default = OpenApi3_1SwaggerClientDereferenceVisitor;
514
- /* eslint-enable camelcase */
515
- exports.default = _default;
535
+ var _default = exports.default = OpenApi3_1SwaggerClientDereferenceVisitor;
536
+ /* eslint-enable camelcase */
@@ -46,5 +46,4 @@ const ParameterMacroVisitor = (0, _compose.default)({
46
46
  }
47
47
  }
48
48
  });
49
- var _default = ParameterMacroVisitor;
50
- exports.default = _default;
49
+ var _default = exports.default = ParameterMacroVisitor;
@@ -40,5 +40,4 @@ const ModelPropertyMacroVisitor = (0, _compose.default)({
40
40
  }
41
41
  }
42
42
  });
43
- var _default = ModelPropertyMacroVisitor;
44
- exports.default = _default;
43
+ var _default = exports.default = ModelPropertyMacroVisitor;
@@ -50,5 +50,4 @@ const JsonParser = _empty.Parser.compose({
50
50
  }
51
51
  }
52
52
  });
53
- var _default = JsonParser;
54
- exports.default = _default;
53
+ var _default = exports.default = JsonParser;
@@ -56,6 +56,5 @@ const OpenApiJson3_1Parser = _empty.Parser.compose({
56
56
  }
57
57
  }
58
58
  });
59
- var _default = OpenApiJson3_1Parser;
60
- /* eslint-enable camelcase */
61
- exports.default = _default;
59
+ var _default = exports.default = OpenApiJson3_1Parser;
60
+ /* eslint-enable camelcase */
@@ -58,6 +58,5 @@ const OpenApiYaml3_1Parser = _empty.Parser.compose({
58
58
  }
59
59
  }
60
60
  });
61
- var _default = OpenApiYaml3_1Parser;
62
- /* eslint-enable camelcase */
63
- exports.default = _default;
61
+ var _default = exports.default = OpenApiYaml3_1Parser;
62
+ /* eslint-enable camelcase */
@@ -55,5 +55,4 @@ const YamlParser = _empty.Parser.compose({
55
55
  }
56
56
  }
57
57
  });
58
- var _default = YamlParser;
59
- exports.default = _default;
58
+ var _default = exports.default = YamlParser;
@@ -70,5 +70,4 @@ const HttpResolverSwaggerClient = _empty.HttpResolver.compose({
70
70
  }
71
71
  }
72
72
  });
73
- var _default = HttpResolverSwaggerClient;
74
- exports.default = _default;
73
+ var _default = exports.default = HttpResolverSwaggerClient;
@@ -36,7 +36,6 @@ const makeResolve = defaultOptions => async options => {
36
36
  return resolve(mergedOptions);
37
37
  };
38
38
  exports.makeResolve = makeResolve;
39
- var _default = makeResolve({
39
+ var _default = exports.default = makeResolve({
40
40
  strategies: [_index4.default, _index3.default, _index2.default]
41
- });
42
- exports.default = _default;
41
+ });
@@ -30,5 +30,4 @@ const genericStrategy = {
30
30
  return (0, _resolve.default)(options);
31
31
  }
32
32
  };
33
- var _default = genericStrategy;
34
- exports.default = _default;
33
+ var _default = exports.default = genericStrategy;
@@ -31,5 +31,4 @@ const openApi2Strategy = {
31
31
  return (0, _resolve.default)(options);
32
32
  }
33
33
  };
34
- var _default = openApi2Strategy;
35
- exports.default = _default;
34
+ var _default = exports.default = openApi2Strategy;
@@ -31,5 +31,4 @@ const openApi30Strategy = {
31
31
  return (0, _resolve.default)(options);
32
32
  }
33
33
  };
34
- var _default = openApi30Strategy;
35
- exports.default = _default;
34
+ var _default = exports.default = openApi30Strategy;
@@ -25,5 +25,4 @@ const openApi31ApiDOMStrategy = {
25
25
  return (0, _resolve.default)(options);
26
26
  }
27
27
  };
28
- var _default = openApi31ApiDOMStrategy;
29
- exports.default = _default;
28
+ var _default = exports.default = openApi31ApiDOMStrategy;
@@ -45,6 +45,5 @@ const pojoAdapter = normalizeFn => spec => {
45
45
  };
46
46
  exports.pojoAdapter = pojoAdapter;
47
47
  pojoAdapter.cache = new WeakMap();
48
- var _default = normalize;
49
- /* eslint-enable camelcase */
50
- exports.default = _default;
48
+ var _default = exports.default = normalize;
49
+ /* eslint-enable camelcase */