swagger-client 3.36.0 → 3.36.1

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.
@@ -15567,6 +15567,45 @@ class OpenAPI3_1DereferenceVisitor {
15567
15567
  this.refractCache = refractCache;
15568
15568
  this.allOfDiscriminatorMapping = allOfDiscriminatorMapping;
15569
15569
  }
15570
+ handleDereferenceError(error, refEl, directAncestors) {
15571
+ var _this$options$derefer;
15572
+ if ((_this$options$derefer = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer !== void 0 && _this$options$derefer.continueOnError) {
15573
+ var _this$options$derefer3;
15574
+ if (directAncestors) {
15575
+ const ancestorWithRef = [...directAncestors].find(ancestor => (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isObjectElement)(ancestor) && ancestor.getMetaProperty('ref-referencing-element'));
15576
+ if (ancestorWithRef) {
15577
+ var _this$options$derefer2;
15578
+ (_this$options$derefer2 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer2 === void 0 || _this$options$derefer2.errors.push({
15579
+ error,
15580
+ refEl: ancestorWithRef.getMetaProperty('ref-referencing-element')
15581
+ });
15582
+ }
15583
+ }
15584
+ (_this$options$derefer3 = this.options.dereference.dereferenceOpts) === null || _this$options$derefer3 === void 0 || _this$options$derefer3.errors.push({
15585
+ error,
15586
+ refEl
15587
+ });
15588
+ return undefined;
15589
+ }
15590
+ throw error;
15591
+ }
15592
+ getNestedVisitorOptions(referencingElement) {
15593
+ var _this$options$derefer4, _this$options$derefer5;
15594
+ return {
15595
+ ...this.options,
15596
+ resolve: {
15597
+ ...this.options.resolve,
15598
+ external: (_this$options$derefer4 = this.options.dereference) !== null && _this$options$derefer4 !== void 0 && (_this$options$derefer4 = _this$options$derefer4.dereferenceOpts) !== null && _this$options$derefer4 !== void 0 && _this$options$derefer4.skipNestedExternal && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.get('$ref')).startsWith('#') ? false : this.options.resolve.external
15599
+ },
15600
+ dereference: {
15601
+ ...this.options.dereference,
15602
+ dereferenceOpts: {
15603
+ ...((_this$options$derefer5 = this.options.dereference) === null || _this$options$derefer5 === void 0 ? void 0 : _this$options$derefer5.dereferenceOpts),
15604
+ continueOnError: false
15605
+ }
15606
+ }
15607
+ };
15608
+ }
15570
15609
  toBaseURI(uri) {
15571
15610
  return _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.resolve(this.reference.uri, _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.sanitize(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(uri)));
15572
15611
  }
@@ -15621,8 +15660,8 @@ class OpenAPI3_1DereferenceVisitor {
15621
15660
  }
15622
15661
  OpenApi3_1Element = {
15623
15662
  leave: (openApi3_1Element, key, parent, path, ancestors, link) => {
15624
- var _this$options$derefer;
15625
- if (!((_this$options$derefer = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer !== void 0 && _this$options$derefer.dereferenceDiscriminatorMapping)) {
15663
+ var _this$options$derefer6;
15664
+ if (!((_this$options$derefer6 = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer6 !== void 0 && _this$options$derefer6.dereferenceDiscriminatorMapping)) {
15626
15665
  return undefined;
15627
15666
  }
15628
15667
  const openApi3_1ElementCopy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneShallow)(openApi3_1Element);
@@ -15632,6 +15671,7 @@ class OpenAPI3_1DereferenceVisitor {
15632
15671
  }
15633
15672
  };
15634
15673
  async ReferenceElement(referencingElement, key, parent, path, ancestors, link) {
15674
+ var _this$options$derefer9, _this$options$derefer0;
15635
15675
  // skip current referencing element as it's already been access
15636
15676
  if (this.indirections.includes(referencingElement)) {
15637
15677
  return false;
@@ -15651,13 +15691,23 @@ class OpenAPI3_1DereferenceVisitor {
15651
15691
  // skip traversing this reference element and all it's child elements
15652
15692
  return false;
15653
15693
  }
15654
- const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15694
+ let reference;
15695
+ try {
15696
+ reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15697
+ } catch (error) {
15698
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15699
+ }
15655
15700
  const $refBaseURI = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15656
15701
  this.indirections.push(referencingElement);
15657
15702
  const jsonPointer = _swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference($refBaseURI);
15658
-
15659
- // possibly non-semantic fragment
15660
- let referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
15703
+ let referencedElement;
15704
+ try {
15705
+ // possibly non-semantic fragment
15706
+ referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
15707
+ } catch (error) {
15708
+ this.indirections.pop();
15709
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15710
+ }
15661
15711
  referencedElement.id = identityManager.identify(referencedElement);
15662
15712
 
15663
15713
  // applying semantics to a fragment
@@ -15681,27 +15731,34 @@ class OpenAPI3_1DereferenceVisitor {
15681
15731
 
15682
15732
  // detect direct or indirect reference
15683
15733
  if (referencingElement === referencedElement) {
15684
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Reference Object detected');
15734
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Reference Object detected');
15735
+ this.indirections.pop();
15736
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15685
15737
  }
15686
15738
 
15687
15739
  // detect maximum depth of dereferencing
15688
15740
  if (this.indirections.length > this.options.dereference.maxDepth) {
15689
- throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
15741
+ const error = new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
15742
+ this.indirections.pop();
15743
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15690
15744
  }
15691
15745
 
15692
15746
  // detect second deep dive into the same fragment and avoid it
15693
15747
  if (ancestorsLineage.includes(referencedElement)) {
15694
15748
  reference.refSet.circular = true;
15695
15749
  if (this.options.dereference.circular === 'error') {
15696
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
15697
- } else if (this.options.dereference.circular === 'replace') {
15698
- var _this$options$derefer2, _this$options$derefer3;
15750
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
15751
+ this.indirections.pop();
15752
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15753
+ }
15754
+ if (this.options.dereference.circular === 'replace') {
15755
+ var _this$options$derefer7, _this$options$derefer8;
15699
15756
  const refElement = new _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__.RefElement(referencedElement.id, {
15700
15757
  type: 'reference',
15701
15758
  uri: reference.uri,
15702
15759
  $ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref)
15703
15760
  });
15704
- const replacer = (_this$options$derefer2 = (_this$options$derefer3 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer3 === void 0 ? void 0 : _this$options$derefer3.circularReplacer) !== null && _this$options$derefer2 !== void 0 ? _this$options$derefer2 : this.options.dereference.circularReplacer;
15761
+ const replacer = (_this$options$derefer7 = (_this$options$derefer8 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer8 === void 0 ? void 0 : _this$options$derefer8.circularReplacer) !== null && _this$options$derefer7 !== void 0 ? _this$options$derefer7 : this.options.dereference.circularReplacer;
15705
15762
  const replacement = replacer(refElement);
15706
15763
  link.replaceWith(replacement, mutationReplacer);
15707
15764
  return !parent ? replacement : false;
@@ -15719,22 +15776,27 @@ class OpenAPI3_1DereferenceVisitor {
15719
15776
  */
15720
15777
  const isNonRootDocument = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
15721
15778
  const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
15722
- if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isReferenceElement)(referencedElement) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
15779
+ if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isReferenceElement)(referencedElement) || shouldDetectCircular || (_this$options$derefer9 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer9 !== void 0 && _this$options$derefer9.continueOnError) && !ancestorsLineage.includesCycle(referencedElement)) {
15723
15780
  // append referencing reference to ancestors lineage
15724
15781
  directAncestors.add(referencingElement);
15725
15782
  const visitor = new OpenAPI3_1DereferenceVisitor({
15726
15783
  reference,
15727
15784
  namespace: this.namespace,
15728
15785
  indirections: [...this.indirections],
15729
- options: this.options,
15786
+ options: this.getNestedVisitorOptions(referencingElement),
15730
15787
  refractCache: this.refractCache,
15731
15788
  ancestors: ancestorsLineage,
15732
15789
  allOfDiscriminatorMapping: this.allOfDiscriminatorMapping
15733
15790
  });
15734
- referencedElement = await visitAsync(referencedElement, visitor, {
15735
- keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
15736
- nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
15737
- });
15791
+ try {
15792
+ referencedElement = await visitAsync(referencedElement, visitor, {
15793
+ keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
15794
+ nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
15795
+ });
15796
+ } catch (error) {
15797
+ this.indirections.pop();
15798
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15799
+ }
15738
15800
 
15739
15801
  // remove referencing reference from ancestors lineage
15740
15802
  directAncestors.delete(referencingElement);
@@ -15759,6 +15821,9 @@ class OpenAPI3_1DereferenceVisitor {
15759
15821
  mergedElement.setMetaProperty('ref-origin', reference.uri);
15760
15822
  // annotate fragment with info about referencing element
15761
15823
  mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(identityManager.identify(referencingElement)));
15824
+ if ((_this$options$derefer0 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer0 !== void 0 && _this$options$derefer0.continueOnError) {
15825
+ mergedElement.setMetaProperty('ref-referencing-element', referencingElement);
15826
+ }
15762
15827
 
15763
15828
  // override description and summary (outer has higher priority then inner)
15764
15829
  if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isObjectElement)(referencedElement) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isObjectElement)(mergedElement)) {
@@ -15783,6 +15848,7 @@ class OpenAPI3_1DereferenceVisitor {
15783
15848
  return !parent ? mergedElement : false;
15784
15849
  }
15785
15850
  async PathItemElement(referencingElement, key, parent, path, ancestors, link) {
15851
+ var _this$options$derefer11;
15786
15852
  // ignore PathItemElement without $ref field
15787
15853
  if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencingElement.$ref)) {
15788
15854
  return undefined;
@@ -15807,13 +15873,23 @@ class OpenAPI3_1DereferenceVisitor {
15807
15873
  // skip traversing this Path Item element but traverse all it's child elements
15808
15874
  return undefined;
15809
15875
  }
15810
- const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15876
+ let reference;
15877
+ try {
15878
+ reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15879
+ } catch (error) {
15880
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15881
+ }
15811
15882
  const $refBaseURI = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref));
15812
15883
  this.indirections.push(referencingElement);
15813
15884
  const jsonPointer = _swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference($refBaseURI);
15814
-
15815
- // possibly non-semantic referenced element
15816
- let referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
15885
+ let referencedElement;
15886
+ try {
15887
+ // possibly non-semantic referenced element
15888
+ referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
15889
+ } catch (error) {
15890
+ this.indirections.pop();
15891
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15892
+ }
15817
15893
  referencedElement.id = identityManager.identify(referencedElement);
15818
15894
 
15819
15895
  /**
@@ -15831,27 +15907,34 @@ class OpenAPI3_1DereferenceVisitor {
15831
15907
 
15832
15908
  // detect direct or indirect reference
15833
15909
  if (referencingElement === referencedElement) {
15834
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Path Item Object reference detected');
15910
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Path Item Object reference detected');
15911
+ this.indirections.pop();
15912
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15835
15913
  }
15836
15914
 
15837
15915
  // detect maximum depth of dereferencing
15838
15916
  if (this.indirections.length > this.options.dereference.maxDepth) {
15839
- throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
15917
+ const error = new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
15918
+ this.indirections.pop();
15919
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15840
15920
  }
15841
15921
 
15842
15922
  // detect second deep dive into the same fragment and avoid it
15843
15923
  if (ancestorsLineage.includes(referencedElement)) {
15844
15924
  reference.refSet.circular = true;
15845
15925
  if (this.options.dereference.circular === 'error') {
15846
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
15847
- } else if (this.options.dereference.circular === 'replace') {
15848
- var _this$options$derefer4, _this$options$derefer5;
15926
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
15927
+ this.indirections.pop();
15928
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15929
+ }
15930
+ if (this.options.dereference.circular === 'replace') {
15931
+ var _this$options$derefer1, _this$options$derefer10;
15849
15932
  const refElement = new _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__.RefElement(referencedElement.id, {
15850
15933
  type: 'path-item',
15851
15934
  uri: reference.uri,
15852
15935
  $ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref)
15853
15936
  });
15854
- const replacer = (_this$options$derefer4 = (_this$options$derefer5 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer5 === void 0 ? void 0 : _this$options$derefer5.circularReplacer) !== null && _this$options$derefer4 !== void 0 ? _this$options$derefer4 : this.options.dereference.circularReplacer;
15937
+ const replacer = (_this$options$derefer1 = (_this$options$derefer10 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer10 === void 0 ? void 0 : _this$options$derefer10.circularReplacer) !== null && _this$options$derefer1 !== void 0 ? _this$options$derefer1 : this.options.dereference.circularReplacer;
15855
15938
  const replacement = replacer(refElement);
15856
15939
  link.replaceWith(replacement, mutationReplacer);
15857
15940
  return !parent ? replacement : false;
@@ -15869,22 +15952,27 @@ class OpenAPI3_1DereferenceVisitor {
15869
15952
  */
15870
15953
  const isNonRootDocument = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
15871
15954
  const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
15872
- if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isPathItemElement)(referencedElement) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencedElement.$ref) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
15955
+ if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isPathItemElement)(referencedElement) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencedElement.$ref) || shouldDetectCircular || (_this$options$derefer11 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer11 !== void 0 && _this$options$derefer11.continueOnError) && !ancestorsLineage.includesCycle(referencedElement)) {
15873
15956
  // append referencing reference to ancestors lineage
15874
15957
  directAncestors.add(referencingElement);
15875
15958
  const visitor = new OpenAPI3_1DereferenceVisitor({
15876
15959
  reference,
15877
15960
  namespace: this.namespace,
15878
15961
  indirections: [...this.indirections],
15879
- options: this.options,
15962
+ options: this.getNestedVisitorOptions(referencingElement),
15880
15963
  refractCache: this.refractCache,
15881
15964
  ancestors: ancestorsLineage,
15882
15965
  allOfDiscriminatorMapping: this.allOfDiscriminatorMapping
15883
15966
  });
15884
- referencedElement = await visitAsync(referencedElement, visitor, {
15885
- keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
15886
- nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
15887
- });
15967
+ try {
15968
+ referencedElement = await visitAsync(referencedElement, visitor, {
15969
+ keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
15970
+ nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
15971
+ });
15972
+ } catch (error) {
15973
+ this.indirections.pop();
15974
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
15975
+ }
15888
15976
 
15889
15977
  // remove referencing reference from ancestors lineage
15890
15978
  directAncestors.delete(referencingElement);
@@ -15895,6 +15983,7 @@ class OpenAPI3_1DereferenceVisitor {
15895
15983
  * Creating a new version of Path Item by merging fields from referenced Path Item with referencing one.
15896
15984
  */
15897
15985
  if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isPathItemElement)(referencedElement)) {
15986
+ var _this$options$derefer12;
15898
15987
  const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__.PathItemElement([...referencedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(referencedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(referencedElement.attributes));
15899
15988
  // assign unique id to merged element
15900
15989
  mergedElement.setMetaProperty('id', identityManager.generateId());
@@ -15913,6 +16002,9 @@ class OpenAPI3_1DereferenceVisitor {
15913
16002
  mergedElement.setMetaProperty('ref-origin', reference.uri);
15914
16003
  // annotate fragment with info about referencing element
15915
16004
  mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(identityManager.identify(referencingElement)));
16005
+ if ((_this$options$derefer12 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer12 !== void 0 && _this$options$derefer12.continueOnError) {
16006
+ mergedElement.setMetaProperty('ref-referencing-element', referencingElement);
16007
+ }
15916
16008
  referencedElement = mergedElement;
15917
16009
  }
15918
16010
 
@@ -15934,7 +16026,8 @@ class OpenAPI3_1DereferenceVisitor {
15934
16026
 
15935
16027
  // operationRef and operationId fields are mutually exclusive
15936
16028
  if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(linkElement.operationRef) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(linkElement.operationId)) {
15937
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('LinkElement operationRef and operationId fields are mutually exclusive.');
16029
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('LinkElement operationRef and operationId fields are mutually exclusive.');
16030
+ return this.handleDereferenceError(error, linkElement);
15938
16031
  }
15939
16032
  let operationElement;
15940
16033
  if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(linkElement.operationRef)) {
@@ -15955,8 +16048,14 @@ class OpenAPI3_1DereferenceVisitor {
15955
16048
  // skip traversing this Link element but traverse all it's child elements
15956
16049
  return undefined;
15957
16050
  }
15958
- const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(linkElement.operationRef));
15959
- operationElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
16051
+ let reference;
16052
+ try {
16053
+ reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(linkElement.operationRef));
16054
+ operationElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
16055
+ } catch (error) {
16056
+ return this.handleDereferenceError(error, linkElement);
16057
+ }
16058
+
15960
16059
  // applying semantics to a referenced element
15961
16060
  if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isPrimitiveElement)(operationElement)) {
15962
16061
  const cacheKey = `operation-${(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(identityManager.identify(operationElement))}`;
@@ -15987,11 +16086,17 @@ class OpenAPI3_1DereferenceVisitor {
15987
16086
  if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(linkElement.operationId)) {
15988
16087
  var _linkElementCopy$oper2;
15989
16088
  const operationId = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(linkElement.operationId);
15990
- const reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize(this.reference.uri));
16089
+ let reference;
16090
+ try {
16091
+ reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize(this.reference.uri));
16092
+ } catch (error) {
16093
+ return this.handleDereferenceError(error, linkElement);
16094
+ }
15991
16095
  operationElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(e => (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isOperationElement)(e) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isElement)(e.operationId) && e.operationId.equals(operationId), reference.value.result);
15992
16096
  // OperationElement not found by its operationId
15993
16097
  if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_2__["default"])(operationElement)) {
15994
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"](`OperationElement(operationId=${operationId}) not found.`);
16098
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"](`OperationElement(operationId=${operationId}) not found.`);
16099
+ return this.handleDereferenceError(error, linkElement);
15995
16100
  }
15996
16101
  const linkElementCopy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneShallow)(linkElement);
15997
16102
  (_linkElementCopy$oper2 = linkElementCopy.operationId) === null || _linkElementCopy$oper2 === void 0 || _linkElementCopy$oper2.meta.set('operation', operationElement);
@@ -16016,7 +16121,8 @@ class OpenAPI3_1DereferenceVisitor {
16016
16121
 
16017
16122
  // value and externalValue fields are mutually exclusive
16018
16123
  if (exampleElement.hasKey('value') && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(exampleElement.externalValue)) {
16019
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('ExampleElement value and externalValue fields are mutually exclusive.');
16124
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('ExampleElement value and externalValue fields are mutually exclusive.');
16125
+ return this.handleDereferenceError(error, exampleElement);
16020
16126
  }
16021
16127
  const retrievalURI = this.toBaseURI((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(exampleElement.externalValue));
16022
16128
  const isInternalReference = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(this.reference.uri) === retrievalURI;
@@ -16032,7 +16138,12 @@ class OpenAPI3_1DereferenceVisitor {
16032
16138
  // skip traversing this Example element but traverse all it's child elements
16033
16139
  return undefined;
16034
16140
  }
16035
- const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(exampleElement.externalValue));
16141
+ let reference;
16142
+ try {
16143
+ reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(exampleElement.externalValue));
16144
+ } catch (error) {
16145
+ return this.handleDereferenceError(error, exampleElement);
16146
+ }
16036
16147
 
16037
16148
  // shallow clone of the referenced element
16038
16149
  const valueElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneShallow)(reference.value.result);
@@ -16052,7 +16163,7 @@ class OpenAPI3_1DereferenceVisitor {
16052
16163
  return !parent ? exampleElementCopy : undefined;
16053
16164
  }
16054
16165
  async MemberElement(memberElement, key, parent, path, ancestors, link) {
16055
- var _this$options$derefer6;
16166
+ var _this$options$derefer13;
16056
16167
  const parentElement = ancestors[ancestors.length - 1];
16057
16168
 
16058
16169
  // skip current MemberElement if its parent is not a DiscriminatorElement
@@ -16061,7 +16172,7 @@ class OpenAPI3_1DereferenceVisitor {
16061
16172
  }
16062
16173
 
16063
16174
  // skip current MemberElement if discriminator mapping dereferencing option is not enabled
16064
- if (!((_this$options$derefer6 = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer6 !== void 0 && _this$options$derefer6.dereferenceDiscriminatorMapping)) {
16175
+ if (!((_this$options$derefer13 = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer13 !== void 0 && _this$options$derefer13.dereferenceDiscriminatorMapping)) {
16065
16176
  return false;
16066
16177
  }
16067
16178
 
@@ -16096,15 +16207,20 @@ class OpenAPI3_1DereferenceVisitor {
16096
16207
  reference: this.reference,
16097
16208
  namespace: this.namespace,
16098
16209
  indirections: [...this.indirections],
16099
- options: this.options,
16210
+ options: this.getNestedVisitorOptions(schemaElement),
16100
16211
  refractCache: this.refractCache,
16101
16212
  ancestors: ancestorsLineage,
16102
16213
  allOfDiscriminatorMapping: this.allOfDiscriminatorMapping
16103
16214
  });
16104
- const referencedElement = await visitAsync(schemaElement, visitor, {
16105
- keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
16106
- nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
16107
- });
16215
+ let referencedElement;
16216
+ try {
16217
+ referencedElement = await visitAsync(schemaElement, visitor, {
16218
+ keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
16219
+ nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
16220
+ });
16221
+ } catch (error) {
16222
+ return this.handleDereferenceError(error, schemaElement, directAncestors);
16223
+ }
16108
16224
 
16109
16225
  // remove referencing reference from ancestors lineage
16110
16226
  directAncestors.delete(schemaElement);
@@ -16125,6 +16241,7 @@ class OpenAPI3_1DereferenceVisitor {
16125
16241
  return !parent ? memberElementCopy : undefined;
16126
16242
  }
16127
16243
  async SchemaElement(referencingElement, key, parent, path, ancestors, link) {
16244
+ var _this$options$derefer16;
16128
16245
  // skip current referencing schema as $ref keyword was not defined
16129
16246
  if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencingElement.$ref)) {
16130
16247
  return undefined;
@@ -16137,7 +16254,12 @@ class OpenAPI3_1DereferenceVisitor {
16137
16254
  const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
16138
16255
 
16139
16256
  // compute baseURI using rules around $id and $ref keywords
16140
- let reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize(this.reference.uri));
16257
+ let reference;
16258
+ try {
16259
+ reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize(this.reference.uri));
16260
+ } catch (error) {
16261
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16262
+ }
16141
16263
  let {
16142
16264
  uri: retrievalURI
16143
16265
  } = reference;
@@ -16218,10 +16340,20 @@ class OpenAPI3_1DereferenceVisitor {
16218
16340
  // skip traversing this schema element but traverse all it's child elements
16219
16341
  return undefined;
16220
16342
  }
16221
- reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize($refBaseURI));
16343
+ try {
16344
+ reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize($refBaseURI));
16345
+ } catch (toReferenceError) {
16346
+ this.indirections.pop();
16347
+ return this.handleDereferenceError(toReferenceError, referencingElement, directAncestors);
16348
+ }
16222
16349
  const selector = (0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_17__.uriToAnchor)($refBaseURI);
16223
16350
  const referenceAsSchema = (0,_util_mjs__WEBPACK_IMPORTED_MODULE_25__.maybeRefractToSchemaElement)(reference.value.result);
16224
- referencedElement = (0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_17__.evaluate)(selector, referenceAsSchema);
16351
+ try {
16352
+ referencedElement = (0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_17__.evaluate)(selector, referenceAsSchema);
16353
+ } catch (evaluateError) {
16354
+ this.indirections.pop();
16355
+ return this.handleDereferenceError(evaluateError, referencingElement, directAncestors);
16356
+ }
16225
16357
  referencedElement = (0,_util_mjs__WEBPACK_IMPORTED_MODULE_25__.maybeRefractToSchemaElement)(referencedElement);
16226
16358
  referencedElement.id = identityManager.identify(referencedElement);
16227
16359
  } else {
@@ -16240,41 +16372,59 @@ class OpenAPI3_1DereferenceVisitor {
16240
16372
  // skip traversing this schema element but traverse all it's child elements
16241
16373
  return undefined;
16242
16374
  }
16243
- reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize($refBaseURI));
16375
+ try {
16376
+ reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.unsanitize($refBaseURI));
16377
+ } catch (toReferenceError) {
16378
+ this.indirections.pop();
16379
+ return this.handleDereferenceError(toReferenceError, referencingElement, directAncestors);
16380
+ }
16244
16381
  const selector = _swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference($refBaseURI);
16245
16382
  const referenceAsSchema = (0,_util_mjs__WEBPACK_IMPORTED_MODULE_25__.maybeRefractToSchemaElement)(reference.value.result);
16246
- referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(referenceAsSchema, selector);
16383
+ try {
16384
+ referencedElement = (0,_swagger_api_apidom_json_pointer_modern__WEBPACK_IMPORTED_MODULE_12__.evaluate)(referenceAsSchema, selector);
16385
+ } catch (evaluateError) {
16386
+ this.indirections.pop();
16387
+ return this.handleDereferenceError(evaluateError, referencingElement, directAncestors);
16388
+ }
16247
16389
  referencedElement = (0,_util_mjs__WEBPACK_IMPORTED_MODULE_25__.maybeRefractToSchemaElement)(referencedElement);
16248
16390
  referencedElement.id = identityManager.identify(referencedElement);
16249
16391
  }
16250
16392
  } else {
16251
- throw error;
16393
+ this.indirections.pop();
16394
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16252
16395
  }
16253
16396
  }
16254
16397
 
16255
16398
  // detect direct or indirect reference
16256
16399
  if (referencingElement === referencedElement) {
16257
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Schema Object reference detected');
16400
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Schema Object reference detected');
16401
+ this.indirections.pop();
16402
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16258
16403
  }
16259
16404
 
16260
16405
  // detect maximum depth of dereferencing
16261
16406
  if (this.indirections.length > this.options.dereference.maxDepth) {
16262
- throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
16407
+ const error = new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_19__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
16408
+ this.indirections.pop();
16409
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16263
16410
  }
16264
16411
 
16265
16412
  // detect second deep dive into the same fragment and avoid it
16266
16413
  if (ancestorsLineage.includes(referencedElement)) {
16267
16414
  reference.refSet.circular = true;
16268
16415
  if (this.options.dereference.circular === 'error') {
16269
- throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
16270
- } else if (this.options.dereference.circular === 'replace') {
16271
- var _this$options$derefer7, _this$options$derefer8;
16416
+ const error = new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected');
16417
+ this.indirections.pop();
16418
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16419
+ }
16420
+ if (this.options.dereference.circular === 'replace') {
16421
+ var _this$options$derefer14, _this$options$derefer15;
16272
16422
  const refElement = new _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__.RefElement(referencedElement.id, {
16273
16423
  type: 'json-schema',
16274
16424
  uri: reference.uri,
16275
16425
  $ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement.$ref)
16276
16426
  });
16277
- const replacer = (_this$options$derefer7 = (_this$options$derefer8 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer8 === void 0 ? void 0 : _this$options$derefer8.circularReplacer) !== null && _this$options$derefer7 !== void 0 ? _this$options$derefer7 : this.options.dereference.circularReplacer;
16427
+ const replacer = (_this$options$derefer14 = (_this$options$derefer15 = this.options.dereference.strategyOpts['openapi-3-1']) === null || _this$options$derefer15 === void 0 ? void 0 : _this$options$derefer15.circularReplacer) !== null && _this$options$derefer14 !== void 0 ? _this$options$derefer14 : this.options.dereference.circularReplacer;
16278
16428
  const replacement = replacer(refElement);
16279
16429
  link.replaceWith(replacement, mutationReplacer);
16280
16430
  return !parent ? replacement : false;
@@ -16292,22 +16442,27 @@ class OpenAPI3_1DereferenceVisitor {
16292
16442
  */
16293
16443
  const isNonRootDocument = _util_url_mjs__WEBPACK_IMPORTED_MODULE_21__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
16294
16444
  const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
16295
- if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isSchemaElement)(referencedElement) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencedElement.$ref) || shouldDetectCircular) && !ancestorsLineage.includesCycle(referencedElement)) {
16445
+ if ((isExternalReference || isNonRootDocument || (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isSchemaElement)(referencedElement) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__.isStringElement)(referencedElement.$ref) || shouldDetectCircular || (_this$options$derefer16 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer16 !== void 0 && _this$options$derefer16.continueOnError) && !ancestorsLineage.includesCycle(referencedElement)) {
16296
16446
  // append referencing reference to ancestors lineage
16297
16447
  directAncestors.add(referencingElement);
16298
16448
  const visitor = new OpenAPI3_1DereferenceVisitor({
16299
16449
  reference,
16300
16450
  namespace: this.namespace,
16301
16451
  indirections: [...this.indirections],
16302
- options: this.options,
16452
+ options: this.getNestedVisitorOptions(referencingElement),
16303
16453
  refractCache: this.refractCache,
16304
16454
  ancestors: ancestorsLineage,
16305
16455
  allOfDiscriminatorMapping: this.allOfDiscriminatorMapping
16306
16456
  });
16307
- referencedElement = await visitAsync(referencedElement, visitor, {
16308
- keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
16309
- nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
16310
- });
16457
+ try {
16458
+ referencedElement = await visitAsync(referencedElement, visitor, {
16459
+ keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.keyMap,
16460
+ nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.getNodeType
16461
+ });
16462
+ } catch (error) {
16463
+ this.indirections.pop();
16464
+ return this.handleDereferenceError(error, referencingElement, directAncestors);
16465
+ }
16311
16466
 
16312
16467
  // remove referencing reference from ancestors lineage
16313
16468
  directAncestors.delete(referencingElement);
@@ -16336,7 +16491,7 @@ class OpenAPI3_1DereferenceVisitor {
16336
16491
  * Creating a new version of Schema Object by merging fields from referenced Schema Object with referencing one.
16337
16492
  */
16338
16493
  if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isSchemaElement)(referencedElement)) {
16339
- var _this$options$derefer9;
16494
+ var _this$options$derefer17, _this$options$derefer18;
16340
16495
  const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__.SchemaElement([...referencedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(referencedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(referencedElement.attributes));
16341
16496
  // assign unique id to merged element
16342
16497
  mergedElement.setMetaProperty('id', identityManager.generateId());
@@ -16355,9 +16510,12 @@ class OpenAPI3_1DereferenceVisitor {
16355
16510
  mergedElement.setMetaProperty('ref-origin', reference.uri);
16356
16511
  // annotate fragment with info about referencing element
16357
16512
  mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_7__.cloneDeep)(identityManager.identify(referencingElement)));
16513
+ if ((_this$options$derefer17 = this.options.dereference.dereferenceOpts) !== null && _this$options$derefer17 !== void 0 && _this$options$derefer17.continueOnError) {
16514
+ mergedElement.setMetaProperty('ref-referencing-element', referencingElement);
16515
+ }
16358
16516
 
16359
16517
  // creating mapping for allOf discriminator
16360
- if ((_this$options$derefer9 = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer9 !== void 0 && _this$options$derefer9.dereferenceDiscriminatorMapping) {
16518
+ if ((_this$options$derefer18 = this.options.dereference.strategyOpts['openapi-3-1']) !== null && _this$options$derefer18 !== void 0 && _this$options$derefer18.dereferenceDiscriminatorMapping) {
16361
16519
  var _parentElement$classe;
16362
16520
  const parentElement = ancestors[ancestors.length - 1];
16363
16521
  const parentSchemaElement = [...directAncestors].findLast(_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isSchemaElement);
@@ -16549,7 +16707,7 @@ __webpack_require__.r(__webpack_exports__);
16549
16707
  /* harmony export */ Schema: () => (/* binding */ Schema),
16550
16708
  /* harmony export */ Type: () => (/* binding */ Type),
16551
16709
  /* harmony export */ YAMLException: () => (/* binding */ YAMLException),
16552
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
16710
+ /* harmony export */ "default": () => (/* binding */ jsYaml),
16553
16711
  /* harmony export */ dump: () => (/* binding */ dump),
16554
16712
  /* harmony export */ load: () => (/* binding */ load),
16555
16713
  /* harmony export */ loadAll: () => (/* binding */ loadAll),
@@ -16559,7 +16717,7 @@ __webpack_require__.r(__webpack_exports__);
16559
16717
  /* harmony export */ types: () => (/* binding */ types)
16560
16718
  /* harmony export */ });
16561
16719
 
16562
- /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
16720
+ /*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
16563
16721
  function isNothing(subject) {
16564
16722
  return (typeof subject === 'undefined') || (subject === null);
16565
16723
  }
@@ -17770,6 +17928,22 @@ function charFromCodepoint(c) {
17770
17928
  );
17771
17929
  }
17772
17930
 
17931
+ // set a property of a literal object, while protecting against prototype pollution,
17932
+ // see https://github.com/nodeca/js-yaml/issues/164 for more details
17933
+ function setProperty(object, key, value) {
17934
+ // used for this specific key only because Object.defineProperty is slow
17935
+ if (key === '__proto__') {
17936
+ Object.defineProperty(object, key, {
17937
+ configurable: true,
17938
+ enumerable: true,
17939
+ writable: true,
17940
+ value: value
17941
+ });
17942
+ } else {
17943
+ object[key] = value;
17944
+ }
17945
+ }
17946
+
17773
17947
  var simpleEscapeCheck = new Array(256); // integer, for fast access
17774
17948
  var simpleEscapeMap = new Array(256);
17775
17949
  for (var i = 0; i < 256; i++) {
@@ -17948,7 +18122,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
17948
18122
  key = sourceKeys[index];
17949
18123
 
17950
18124
  if (!_hasOwnProperty$1.call(destination, key)) {
17951
- destination[key] = source[key];
18125
+ setProperty(destination, key, source[key]);
17952
18126
  overridableKeys[key] = true;
17953
18127
  }
17954
18128
  }
@@ -18008,17 +18182,7 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
18008
18182
  throwError(state, 'duplicated mapping key');
18009
18183
  }
18010
18184
 
18011
- // used for this specific key only because Object.defineProperty is slow
18012
- if (keyNode === '__proto__') {
18013
- Object.defineProperty(_result, keyNode, {
18014
- configurable: true,
18015
- enumerable: true,
18016
- writable: true,
18017
- value: valueNode
18018
- });
18019
- } else {
18020
- _result[keyNode] = valueNode;
18021
- }
18185
+ setProperty(_result, keyNode, valueNode);
18022
18186
  delete overridableKeys[keyNode];
18023
18187
  }
18024
18188
 
@@ -20407,7 +20571,6 @@ var jsYaml = {
20407
20571
  safeDump: safeDump
20408
20572
  };
20409
20573
 
20410
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (jsYaml);
20411
20574
 
20412
20575
 
20413
20576
 
@@ -50695,35 +50858,145 @@ __webpack_require__.r(__webpack_exports__);
50695
50858
  /* harmony export */ readFile: () => (/* binding */ readFile)
50696
50859
  /* harmony export */ });
50697
50860
  /* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23557);
50698
- /* harmony import */ var _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(17955);
50699
- /* harmony import */ var _errors_ResolveError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35416);
50700
- /* harmony import */ var _errors_UnmatchedResolverError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12207);
50861
+ /* harmony import */ var _File_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38396);
50862
+ /* harmony import */ var _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17955);
50863
+ /* harmony import */ var _errors_ResolveError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(35416);
50864
+ /* harmony import */ var _errors_UnmatchedResolverError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12207);
50865
+
50701
50866
 
50702
50867
 
50703
50868
 
50704
50869
 
50870
+ const CACHE_NAME = 'apidom-file-cache';
50871
+ const getCacheFileResult = async ({
50872
+ cacheKey,
50873
+ cacheTTL
50874
+ }) => {
50875
+ if (cacheTTL === 0) {
50876
+ return {
50877
+ cachedResult: null,
50878
+ cachedError: null
50879
+ };
50880
+ }
50881
+ try {
50882
+ const cache = await caches.open(CACHE_NAME);
50883
+ const response = await cache.match(cacheKey);
50884
+ if (response) {
50885
+ const {
50886
+ cachedResult,
50887
+ cachedError,
50888
+ timestamp
50889
+ } = await response.json();
50890
+ const now = Date.now();
50891
+
50892
+ // Check if the cache is still valid
50893
+ if (now - timestamp < cacheTTL) {
50894
+ return {
50895
+ cachedResult,
50896
+ cachedError
50897
+ };
50898
+ }
50899
+ await cache.delete(cacheKey);
50900
+ }
50901
+ } catch (error) {
50902
+ // If parsing cache fails, continue with normal parsing
50903
+ console.log('There was an error parsing the response');
50904
+ return {
50905
+ cachedResult: null,
50906
+ cachedError: null
50907
+ };
50908
+ }
50909
+ return {
50910
+ cachedResult: null,
50911
+ cachedError: null
50912
+ };
50913
+ };
50914
+ const setCacheFileResult = async ({
50915
+ cacheKey,
50916
+ result,
50917
+ error,
50918
+ cacheTTL
50919
+ }) => {
50920
+ if (cacheTTL === 0) {
50921
+ return;
50922
+ }
50923
+ try {
50924
+ const cacheData = {
50925
+ cachedResult: result,
50926
+ cachedError: error,
50927
+ timestamp: Date.now()
50928
+ };
50929
+ const cache = await caches.open(CACHE_NAME);
50930
+ const response = new Response(JSON.stringify(cacheData), {
50931
+ headers: {
50932
+ 'Content-Type': 'application/json'
50933
+ }
50934
+ });
50935
+ await cache.put(cacheKey, response);
50936
+ } catch (err) {
50937
+ // Silently fail if CacheStorage is not available
50938
+ console.error('CacheStorage is not available');
50939
+ }
50940
+ };
50941
+
50705
50942
  /**
50706
50943
  * Reads the given file, using the configured resolver plugins.
50707
50944
  */
50708
50945
  // eslint-disable-next-line import/prefer-default-export
50709
50946
  const readFile = async (file, options) => {
50947
+ const {
50948
+ cacheTTL = 0
50949
+ } = options.resolve.resolverOpts;
50950
+ const cacheKey = `read_${file.uri}`;
50951
+ const {
50952
+ cachedResult,
50953
+ cachedError
50954
+ } = await getCacheFileResult({
50955
+ cacheKey,
50956
+ cacheTTL
50957
+ });
50958
+ if (cachedResult !== null) {
50959
+ return cachedResult;
50960
+ }
50961
+ if (cachedError !== null) {
50962
+ throw new _errors_ResolveError_mjs__WEBPACK_IMPORTED_MODULE_3__["default"](`Error while reading file "${file.uri}"`, {
50963
+ cause: cachedError
50964
+ });
50965
+ }
50710
50966
  const optsBoundResolvers = options.resolve.resolvers.map(resolver => {
50711
50967
  const clonedResolver = Object.create(resolver);
50712
50968
  return Object.assign(clonedResolver, options.resolve.resolverOpts);
50713
50969
  });
50714
- const resolvers = await _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_1__.filter('canRead', [file, options], optsBoundResolvers);
50970
+ const resolvers = await _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_2__.filter('canRead', [file, options], optsBoundResolvers);
50715
50971
 
50716
50972
  // we couldn't find any resolver for this File
50717
50973
  if ((0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(resolvers)) {
50718
- throw new _errors_UnmatchedResolverError_mjs__WEBPACK_IMPORTED_MODULE_3__["default"](file.uri);
50974
+ throw new _errors_UnmatchedResolverError_mjs__WEBPACK_IMPORTED_MODULE_4__["default"](file.uri);
50719
50975
  }
50720
50976
  try {
50721
50977
  const {
50722
50978
  result
50723
- } = await _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_1__.run('read', [file], resolvers);
50979
+ } = await _util_plugins_mjs__WEBPACK_IMPORTED_MODULE_2__.run('read', [file], resolvers);
50980
+ const stringifiedData = new _File_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]({
50981
+ ...file,
50982
+ data: result
50983
+ }).toString();
50984
+ await setCacheFileResult({
50985
+ cacheKey,
50986
+ result: stringifiedData,
50987
+ error: null,
50988
+ cacheTTL
50989
+ });
50724
50990
  return result;
50725
50991
  } catch (error) {
50726
- throw new _errors_ResolveError_mjs__WEBPACK_IMPORTED_MODULE_2__["default"](`Error while reading file "${file.uri}"`, {
50992
+ var _ref, _error$cause$cause, _error$cause;
50993
+ await setCacheFileResult({
50994
+ cacheKey,
50995
+ result: null,
50996
+ error: (_ref = (_error$cause$cause = error === null || error === void 0 || (_error$cause = error.cause) === null || _error$cause === void 0 ? void 0 : _error$cause.cause) !== null && _error$cause$cause !== void 0 ? _error$cause$cause : error === null || error === void 0 ? void 0 : error.cause) !== null && _ref !== void 0 ? _ref : error,
50997
+ cacheTTL
50998
+ });
50999
+ throw new _errors_ResolveError_mjs__WEBPACK_IMPORTED_MODULE_3__["default"](`Error while reading file "${file.uri}"`, {
50727
51000
  cause: error
50728
51001
  });
50729
51002
  }
@@ -53925,7 +54198,11 @@ const defaultOptions = {
53925
54198
  * true - the dereferencing process will be immutable (deep cloning of ApiDOM is involved)
53926
54199
  * false - the dereferencing process will be mutable
53927
54200
  */
53928
- immutable: true
54201
+ immutable: true,
54202
+ /**
54203
+ * These options are available in dereference strategy visitors.
54204
+ */
54205
+ dereferenceOpts: {}
53929
54206
  },
53930
54207
  bundle: {
53931
54208
  /**