swagger-client 3.24.4 → 3.24.5
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.
- package/dist/swagger-client.browser.js +913 -269
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +62 -23
- package/es/resolver/strategies/openapi-3-1-apidom/resolve.js +1 -1
- package/lib/resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/visitors/dereference.js +61 -22
- package/lib/resolver/strategies/openapi-3-1-apidom/resolve.js +1 -1
- package/package.json +6 -5
|
@@ -2550,25 +2550,27 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2550
2550
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2551
2551
|
/* harmony export */ });
|
|
2552
2552
|
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(87395);
|
|
2553
|
-
/* harmony import */ var
|
|
2554
|
-
/* harmony import */ var
|
|
2555
|
-
/* harmony import */ var
|
|
2556
|
-
/* harmony import */ var
|
|
2557
|
-
/* harmony import */ var
|
|
2558
|
-
/* harmony import */ var
|
|
2559
|
-
/* harmony import */ var
|
|
2560
|
-
/* harmony import */ var
|
|
2561
|
-
/* harmony import */ var
|
|
2562
|
-
/* harmony import */ var
|
|
2563
|
-
/* harmony import */ var
|
|
2564
|
-
/* harmony import */ var
|
|
2565
|
-
/* harmony import */ var
|
|
2566
|
-
/* harmony import */ var
|
|
2567
|
-
/* harmony import */ var
|
|
2568
|
-
/* harmony import */ var
|
|
2569
|
-
/* harmony import */ var
|
|
2570
|
-
/* harmony import */ var
|
|
2571
|
-
/* harmony import */ var
|
|
2553
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(47644);
|
|
2554
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(50334);
|
|
2555
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28552);
|
|
2556
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(50308);
|
|
2557
|
+
/* harmony import */ var _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(42455);
|
|
2558
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(66316);
|
|
2559
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(74144);
|
|
2560
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(94481);
|
|
2561
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(84714);
|
|
2562
|
+
/* harmony import */ var _swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3608);
|
|
2563
|
+
/* harmony import */ var _swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8647);
|
|
2564
|
+
/* harmony import */ var _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(69239);
|
|
2565
|
+
/* harmony import */ var _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(67625);
|
|
2566
|
+
/* harmony import */ var _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(35059);
|
|
2567
|
+
/* harmony import */ var _swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(71550);
|
|
2568
|
+
/* harmony import */ var _swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(77079);
|
|
2569
|
+
/* harmony import */ var _swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$anchor__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(90609);
|
|
2570
|
+
/* harmony import */ var _swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_uri__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(14726);
|
|
2571
|
+
/* harmony import */ var _swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_uri__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(552);
|
|
2572
|
+
/* harmony import */ var _utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(21352);
|
|
2573
|
+
/* harmony import */ var _utils_get_root_cause_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(28495);
|
|
2572
2574
|
/* harmony import */ var _specmap_lib_refs_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58569);
|
|
2573
2575
|
/* harmony import */ var _errors_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(75754);
|
|
2574
2576
|
/* eslint-disable camelcase */
|
|
@@ -2583,11 +2585,21 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2583
2585
|
|
|
2584
2586
|
|
|
2585
2587
|
|
|
2588
|
+
|
|
2586
2589
|
const {
|
|
2587
2590
|
wrapError
|
|
2588
2591
|
} = _specmap_lib_refs_js__WEBPACK_IMPORTED_MODULE_0__["default"];
|
|
2589
2592
|
const visitAsync = _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_2__.visit[Symbol.for('nodejs.util.promisify.custom')];
|
|
2590
|
-
|
|
2593
|
+
|
|
2594
|
+
// initialize element identity manager
|
|
2595
|
+
const identityManager = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_3__.IdentityManager)();
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* Predicate for detecting if element was created by merging referencing
|
|
2599
|
+
* element with particular element identity with a referenced element.
|
|
2600
|
+
*/
|
|
2601
|
+
const wasReferencedBy = referencingElement => element => element.meta.hasKey('ref-referencing-element-id') && element.meta.get('ref-referencing-element-id').equals((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(identityManager.identify(referencingElement)));
|
|
2602
|
+
const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_5__["default"].compose({
|
|
2591
2603
|
props: {
|
|
2592
2604
|
useCircularStructures: true,
|
|
2593
2605
|
allowMetaPatches: false,
|
|
@@ -2608,32 +2620,37 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2608
2620
|
try {
|
|
2609
2621
|
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
|
|
2610
2622
|
|
|
2623
|
+
// skip already identified cycled Path Item Objects
|
|
2624
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.includesClasses)(['cycle'], referencingElement.$ref)) {
|
|
2625
|
+
return false;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2611
2628
|
// detect possible cycle in traversal and avoid it
|
|
2612
2629
|
if (ancestorsLineage.includesCycle(referencingElement)) {
|
|
2613
2630
|
return false;
|
|
2614
2631
|
}
|
|
2615
2632
|
|
|
2616
2633
|
// ignore resolving external Reference Objects
|
|
2617
|
-
if (!this.options.resolve.external && (0,
|
|
2634
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_7__.isReferenceElementExternal)(referencingElement)) {
|
|
2618
2635
|
return false;
|
|
2619
2636
|
}
|
|
2620
|
-
const reference = await this.toReference((0,
|
|
2637
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
2621
2638
|
const {
|
|
2622
2639
|
uri: retrievalURI
|
|
2623
2640
|
} = reference;
|
|
2624
|
-
const $refBaseURI =
|
|
2641
|
+
const $refBaseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
2625
2642
|
this.indirections.push(referencingElement);
|
|
2626
|
-
const jsonPointer = (0,
|
|
2643
|
+
const jsonPointer = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)($refBaseURI);
|
|
2627
2644
|
|
|
2628
2645
|
// possibly non-semantic fragment
|
|
2629
|
-
let referencedElement = (0,
|
|
2646
|
+
let referencedElement = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__["default"])(jsonPointer, reference.value.result);
|
|
2630
2647
|
|
|
2631
2648
|
// applying semantics to a fragment
|
|
2632
|
-
if ((0,
|
|
2633
|
-
const referencedElementType = (0,
|
|
2634
|
-
if ((0,
|
|
2649
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isPrimitiveElement)(referencedElement)) {
|
|
2650
|
+
const referencedElementType = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.meta.get('referenced-element'));
|
|
2651
|
+
if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isReferenceLikeElement)(referencedElement)) {
|
|
2635
2652
|
// handling indirect references
|
|
2636
|
-
referencedElement =
|
|
2653
|
+
referencedElement = _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.ReferenceElement.refract(referencedElement);
|
|
2637
2654
|
referencedElement.setMetaProperty('referenced-element', referencedElementType);
|
|
2638
2655
|
} else {
|
|
2639
2656
|
// handling direct references
|
|
@@ -2644,21 +2661,23 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2644
2661
|
|
|
2645
2662
|
// detect direct or indirect reference
|
|
2646
2663
|
if (this.indirections.includes(referencedElement)) {
|
|
2647
|
-
throw new
|
|
2664
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_13__["default"]('Recursive JSON Pointer detected');
|
|
2648
2665
|
}
|
|
2649
2666
|
|
|
2650
2667
|
// detect maximum depth of dereferencing
|
|
2651
2668
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
2652
|
-
throw new
|
|
2669
|
+
throw new _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_14__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
2653
2670
|
}
|
|
2654
2671
|
if (!this.useCircularStructures) {
|
|
2655
2672
|
const hasCycles = ancestorsLineage.includes(referencedElement);
|
|
2656
2673
|
if (hasCycles) {
|
|
2657
|
-
if (
|
|
2674
|
+
if (_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isHttpUrl(retrievalURI) || _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isFileSystemPath(retrievalURI)) {
|
|
2658
2675
|
// make the referencing URL or file system path absolute
|
|
2659
|
-
|
|
2676
|
+
const cycledReferenceElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.ReferenceElement({
|
|
2660
2677
|
$ref: $refBaseURI
|
|
2661
|
-
}, (0,
|
|
2678
|
+
}, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(referencingElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(referencingElement.attributes));
|
|
2679
|
+
cycledReferenceElement.get('$ref').classes.push('cycle');
|
|
2680
|
+
return cycledReferenceElement;
|
|
2662
2681
|
}
|
|
2663
2682
|
// skip processing this reference
|
|
2664
2683
|
return false;
|
|
@@ -2677,51 +2696,47 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2677
2696
|
ancestors: ancestorsLineage,
|
|
2678
2697
|
allowMetaPatches: this.allowMetaPatches,
|
|
2679
2698
|
useCircularStructures: this.useCircularStructures,
|
|
2680
|
-
basePath: this.basePath ?? [...(0,
|
|
2699
|
+
basePath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, referencingElement]), '$ref']
|
|
2681
2700
|
});
|
|
2682
2701
|
referencedElement = await visitAsync(referencedElement, visitor, {
|
|
2683
|
-
keyMap:
|
|
2684
|
-
nodeTypeGetter:
|
|
2702
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.keyMap,
|
|
2703
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.getNodeType
|
|
2685
2704
|
});
|
|
2686
2705
|
|
|
2687
2706
|
// remove referencing schema from ancestors lineage
|
|
2688
2707
|
directAncestors.delete(referencingElement);
|
|
2689
2708
|
this.indirections.pop();
|
|
2690
2709
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
2691
|
-
const copy = (0,
|
|
2710
|
+
const copy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneShallow)(refedElement);
|
|
2692
2711
|
|
|
2693
2712
|
// annotate fragment with info about original Reference element
|
|
2694
2713
|
copy.setMetaProperty('ref-fields', {
|
|
2695
|
-
$ref: (0,
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
// @ts-ignore
|
|
2699
|
-
summary: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_5__["default"])(referencingElement.summary)
|
|
2714
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref),
|
|
2715
|
+
description: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.description),
|
|
2716
|
+
summary: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.summary)
|
|
2700
2717
|
});
|
|
2701
2718
|
// annotate fragment with info about origin
|
|
2702
2719
|
copy.setMetaProperty('ref-origin', reference.uri);
|
|
2720
|
+
// annotate fragment with info about referencing element
|
|
2721
|
+
copy.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
2703
2722
|
|
|
2704
2723
|
// override description and summary (outer has higher priority then inner)
|
|
2705
|
-
if ((0,
|
|
2724
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isObjectElement)(refedElement)) {
|
|
2706
2725
|
if (referencingElement.hasKey('description') && 'description' in refedElement) {
|
|
2707
|
-
// @ts-ignore
|
|
2708
2726
|
copy.remove('description');
|
|
2709
|
-
// @ts-ignore
|
|
2710
2727
|
copy.set('description', referencingElement.get('description'));
|
|
2711
2728
|
}
|
|
2712
2729
|
if (referencingElement.hasKey('summary') && 'summary' in refedElement) {
|
|
2713
|
-
// @ts-ignore
|
|
2714
2730
|
copy.remove('summary');
|
|
2715
|
-
// @ts-ignore
|
|
2716
2731
|
copy.set('summary', referencingElement.get('summary'));
|
|
2717
2732
|
}
|
|
2718
2733
|
}
|
|
2719
2734
|
|
|
2720
2735
|
// apply meta patches
|
|
2721
|
-
if (this.allowMetaPatches && (0,
|
|
2736
|
+
if (this.allowMetaPatches && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isObjectElement)(copy)) {
|
|
2722
2737
|
// apply meta patch only when not already applied
|
|
2723
2738
|
if (!copy.hasKey('$$ref')) {
|
|
2724
|
-
const baseURI =
|
|
2739
|
+
const baseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, $refBaseURI);
|
|
2725
2740
|
copy.set('$$ref', baseURI);
|
|
2726
2741
|
}
|
|
2727
2742
|
}
|
|
@@ -2729,11 +2744,12 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2729
2744
|
};
|
|
2730
2745
|
|
|
2731
2746
|
// attempting to create cycle
|
|
2732
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
2733
|
-
|
|
2734
|
-
|
|
2747
|
+
if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
|
|
2748
|
+
const replaceWith = ancestorsLineage.findItem(wasReferencedBy(referencingElement)) ?? mergeAndAnnotateReferencedElement(referencedElement);
|
|
2749
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isMemberElement)(parent)) {
|
|
2750
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
2735
2751
|
} else if (Array.isArray(parent)) {
|
|
2736
|
-
parent[key] =
|
|
2752
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
2737
2753
|
}
|
|
2738
2754
|
|
|
2739
2755
|
return false;
|
|
@@ -2742,12 +2758,12 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2742
2758
|
// transclude the element for a fragment
|
|
2743
2759
|
return mergeAndAnnotateReferencedElement(referencedElement);
|
|
2744
2760
|
} catch (error) {
|
|
2745
|
-
const rootCause = (0,
|
|
2761
|
+
const rootCause = (0,_utils_get_root_cause_js__WEBPACK_IMPORTED_MODULE_18__["default"])(error);
|
|
2746
2762
|
const wrappedError = wrapError(rootCause, {
|
|
2747
2763
|
baseDoc: this.reference.uri,
|
|
2748
|
-
$ref: (0,
|
|
2749
|
-
pointer: (0,
|
|
2750
|
-
fullPath: this.basePath ?? [...(0,
|
|
2764
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref),
|
|
2765
|
+
pointer: (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)),
|
|
2766
|
+
fullPath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, referencingElement]), '$ref']
|
|
2751
2767
|
});
|
|
2752
2768
|
this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
|
|
2753
2769
|
return undefined;
|
|
@@ -2758,52 +2774,59 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2758
2774
|
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
|
|
2759
2775
|
|
|
2760
2776
|
// ignore PathItemElement without $ref field
|
|
2761
|
-
if (!(0,
|
|
2777
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isStringElement)(pathItemElement.$ref)) {
|
|
2762
2778
|
return undefined;
|
|
2763
2779
|
}
|
|
2764
2780
|
|
|
2781
|
+
// skip already identified cycled Path Item Objects
|
|
2782
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.includesClasses)(['cycle'], pathItemElement.$ref)) {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2765
2786
|
// detect possible cycle in traversal and avoid it
|
|
2766
2787
|
if (ancestorsLineage.includesCycle(pathItemElement)) {
|
|
2767
2788
|
return false;
|
|
2768
2789
|
}
|
|
2769
2790
|
|
|
2770
2791
|
// ignore resolving external Path Item Elements
|
|
2771
|
-
if (!this.options.resolve.external && (0,
|
|
2792
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_7__.isPathItemElementExternal)(pathItemElement)) {
|
|
2772
2793
|
return undefined;
|
|
2773
2794
|
}
|
|
2774
|
-
const reference = await this.toReference((0,
|
|
2795
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(pathItemElement.$ref));
|
|
2775
2796
|
const {
|
|
2776
2797
|
uri: retrievalURI
|
|
2777
2798
|
} = reference;
|
|
2778
|
-
const $refBaseURI =
|
|
2799
|
+
const $refBaseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(pathItemElement.$ref));
|
|
2779
2800
|
this.indirections.push(pathItemElement);
|
|
2780
|
-
const jsonPointer = (0,
|
|
2801
|
+
const jsonPointer = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)($refBaseURI);
|
|
2781
2802
|
|
|
2782
2803
|
// possibly non-semantic referenced element
|
|
2783
|
-
let referencedElement = (0,
|
|
2804
|
+
let referencedElement = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__["default"])(jsonPointer, reference.value.result);
|
|
2784
2805
|
|
|
2785
2806
|
// applying semantics to a referenced element
|
|
2786
|
-
if ((0,
|
|
2787
|
-
referencedElement =
|
|
2807
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isPrimitiveElement)(referencedElement)) {
|
|
2808
|
+
referencedElement = _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.PathItemElement.refract(referencedElement);
|
|
2788
2809
|
}
|
|
2789
2810
|
|
|
2790
2811
|
// detect direct or indirect reference
|
|
2791
2812
|
if (this.indirections.includes(referencedElement)) {
|
|
2792
|
-
throw new
|
|
2813
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_13__["default"]('Recursive JSON Pointer detected');
|
|
2793
2814
|
}
|
|
2794
2815
|
|
|
2795
2816
|
// detect maximum depth of dereferencing
|
|
2796
2817
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
2797
|
-
throw new
|
|
2818
|
+
throw new _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_14__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
2798
2819
|
}
|
|
2799
2820
|
if (!this.useCircularStructures) {
|
|
2800
2821
|
const hasCycles = ancestorsLineage.includes(referencedElement);
|
|
2801
2822
|
if (hasCycles) {
|
|
2802
|
-
if (
|
|
2823
|
+
if (_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isHttpUrl(retrievalURI) || _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isFileSystemPath(retrievalURI)) {
|
|
2803
2824
|
// make the referencing URL or file system path absolute
|
|
2804
|
-
|
|
2825
|
+
const cycledPathItemElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.PathItemElement({
|
|
2805
2826
|
$ref: $refBaseURI
|
|
2806
|
-
}, (0,
|
|
2827
|
+
}, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(pathItemElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(pathItemElement.attributes));
|
|
2828
|
+
cycledPathItemElement.get('$ref').classes.push('cycle');
|
|
2829
|
+
return cycledPathItemElement;
|
|
2807
2830
|
}
|
|
2808
2831
|
// skip processing this path item and all it's child elements
|
|
2809
2832
|
return false;
|
|
@@ -2822,11 +2845,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2822
2845
|
ancestors: ancestorsLineage,
|
|
2823
2846
|
allowMetaPatches: this.allowMetaPatches,
|
|
2824
2847
|
useCircularStructures: this.useCircularStructures,
|
|
2825
|
-
basePath: this.basePath ?? [...(0,
|
|
2848
|
+
basePath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, pathItemElement]), '$ref']
|
|
2826
2849
|
});
|
|
2827
2850
|
referencedElement = await visitAsync(referencedElement, visitor, {
|
|
2828
|
-
keyMap:
|
|
2829
|
-
nodeTypeGetter:
|
|
2851
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.keyMap,
|
|
2852
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.getNodeType
|
|
2830
2853
|
});
|
|
2831
2854
|
|
|
2832
2855
|
// remove referencing schema from ancestors lineage
|
|
@@ -2834,26 +2857,28 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2834
2857
|
this.indirections.pop();
|
|
2835
2858
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
2836
2859
|
// merge fields from referenced Path Item with referencing one
|
|
2837
|
-
const mergedElement = new
|
|
2860
|
+
const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.PathItemElement([...refedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(refedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(refedElement.attributes));
|
|
2838
2861
|
// existing keywords from referencing PathItemElement overrides ones from referenced element
|
|
2839
2862
|
pathItemElement.forEach((value, keyElement, item) => {
|
|
2840
|
-
mergedElement.remove((0,
|
|
2863
|
+
mergedElement.remove((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(keyElement));
|
|
2841
2864
|
mergedElement.content.push(item);
|
|
2842
2865
|
});
|
|
2843
2866
|
mergedElement.remove('$ref');
|
|
2844
2867
|
|
|
2845
2868
|
// annotate referenced element with info about original referencing element
|
|
2846
2869
|
mergedElement.setMetaProperty('ref-fields', {
|
|
2847
|
-
$ref: (0,
|
|
2870
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(pathItemElement.$ref)
|
|
2848
2871
|
});
|
|
2849
2872
|
// annotate referenced element with info about origin
|
|
2850
2873
|
mergedElement.setMetaProperty('ref-origin', reference.uri);
|
|
2874
|
+
// annotate fragment with info about referencing element
|
|
2875
|
+
mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(identityManager.identify(pathItemElement)));
|
|
2851
2876
|
|
|
2852
2877
|
// apply meta patches
|
|
2853
2878
|
if (this.allowMetaPatches) {
|
|
2854
2879
|
// apply meta patch only when not already applied
|
|
2855
2880
|
if (typeof mergedElement.get('$$ref') === 'undefined') {
|
|
2856
|
-
const baseURI =
|
|
2881
|
+
const baseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, $refBaseURI);
|
|
2857
2882
|
mergedElement.set('$$ref', baseURI);
|
|
2858
2883
|
}
|
|
2859
2884
|
}
|
|
@@ -2861,11 +2886,12 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2861
2886
|
};
|
|
2862
2887
|
|
|
2863
2888
|
// attempting to create cycle
|
|
2864
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
2865
|
-
|
|
2866
|
-
|
|
2889
|
+
if (ancestorsLineage.includes(pathItemElement) || ancestorsLineage.includes(referencedElement)) {
|
|
2890
|
+
const replaceWith = ancestorsLineage.findItem(wasReferencedBy(pathItemElement)) ?? mergeAndAnnotateReferencedElement(referencedElement);
|
|
2891
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isMemberElement)(parent)) {
|
|
2892
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
2867
2893
|
} else if (Array.isArray(parent)) {
|
|
2868
|
-
parent[key] =
|
|
2894
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
2869
2895
|
}
|
|
2870
2896
|
|
|
2871
2897
|
return false;
|
|
@@ -2874,12 +2900,12 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2874
2900
|
// transclude referencing element with merged referenced element
|
|
2875
2901
|
return mergeAndAnnotateReferencedElement(referencedElement);
|
|
2876
2902
|
} catch (error) {
|
|
2877
|
-
const rootCause = (0,
|
|
2903
|
+
const rootCause = (0,_utils_get_root_cause_js__WEBPACK_IMPORTED_MODULE_18__["default"])(error);
|
|
2878
2904
|
const wrappedError = wrapError(rootCause, {
|
|
2879
2905
|
baseDoc: this.reference.uri,
|
|
2880
|
-
$ref: (0,
|
|
2881
|
-
pointer: (0,
|
|
2882
|
-
fullPath: this.basePath ?? [...(0,
|
|
2906
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(pathItemElement.$ref),
|
|
2907
|
+
pointer: (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(pathItemElement.$ref)),
|
|
2908
|
+
fullPath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, pathItemElement]), '$ref']
|
|
2883
2909
|
});
|
|
2884
2910
|
this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
|
|
2885
2911
|
return undefined;
|
|
@@ -2890,24 +2916,29 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2890
2916
|
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
|
|
2891
2917
|
|
|
2892
2918
|
// skip current referencing schema as $ref keyword was not defined
|
|
2893
|
-
if (!(0,
|
|
2919
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isStringElement)(referencingElement.$ref)) {
|
|
2894
2920
|
// skip traversing this schema but traverse all it's child schemas
|
|
2895
2921
|
return undefined;
|
|
2896
2922
|
}
|
|
2897
2923
|
|
|
2924
|
+
// skip already identified cycled Path Item Objects
|
|
2925
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.includesClasses)(['cycle'], referencingElement.$ref)) {
|
|
2926
|
+
return false;
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2898
2929
|
// detect possible cycle in traversal and avoid it
|
|
2899
2930
|
if (ancestorsLineage.includesCycle(referencingElement)) {
|
|
2900
2931
|
return false;
|
|
2901
2932
|
}
|
|
2902
2933
|
|
|
2903
2934
|
// compute baseURI using rules around $id and $ref keywords
|
|
2904
|
-
let reference = await this.toReference(
|
|
2935
|
+
let reference = await this.toReference(_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.unsanitize(this.reference.uri));
|
|
2905
2936
|
let {
|
|
2906
2937
|
uri: retrievalURI
|
|
2907
2938
|
} = reference;
|
|
2908
|
-
const $refBaseURI = (0,
|
|
2909
|
-
const $refBaseURIStrippedHash =
|
|
2910
|
-
const file = (0,
|
|
2939
|
+
const $refBaseURI = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.resolveSchema$refField)(retrievalURI, referencingElement);
|
|
2940
|
+
const $refBaseURIStrippedHash = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.stripHash($refBaseURI);
|
|
2941
|
+
const file = (0,_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_20__["default"])({
|
|
2911
2942
|
uri: $refBaseURIStrippedHash
|
|
2912
2943
|
});
|
|
2913
2944
|
const isUnknownURI = !this.options.resolve.resolvers.some(r => r.canRead(file));
|
|
@@ -2927,32 +2958,32 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2927
2958
|
if (isUnknownURI || isURL) {
|
|
2928
2959
|
// we're dealing with canonical URI or URL with possible fragment
|
|
2929
2960
|
const selector = $refBaseURI;
|
|
2930
|
-
referencedElement = (0,
|
|
2961
|
+
referencedElement = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_uri__WEBPACK_IMPORTED_MODULE_21__.evaluate)(selector, (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.maybeRefractToSchemaElement)(reference.value.result));
|
|
2931
2962
|
} else {
|
|
2932
2963
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
2933
|
-
reference = await this.toReference(
|
|
2964
|
+
reference = await this.toReference(_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.unsanitize($refBaseURI));
|
|
2934
2965
|
retrievalURI = reference.uri;
|
|
2935
|
-
const selector = (0,
|
|
2936
|
-
referencedElement = (0,
|
|
2966
|
+
const selector = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)($refBaseURI);
|
|
2967
|
+
referencedElement = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.maybeRefractToSchemaElement)((0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__["default"])(selector, reference.value.result));
|
|
2937
2968
|
}
|
|
2938
2969
|
} catch (error) {
|
|
2939
2970
|
/**
|
|
2940
2971
|
* No SchemaElement($id=URL) was not found, so we're going to try to resolve
|
|
2941
2972
|
* the URL and assume the returned response is a JSON Schema.
|
|
2942
2973
|
*/
|
|
2943
|
-
if (isURL && error instanceof
|
|
2944
|
-
if ((0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$
|
|
2974
|
+
if (isURL && error instanceof _swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_uri__WEBPACK_IMPORTED_MODULE_22__["default"]) {
|
|
2975
|
+
if ((0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$anchor__WEBPACK_IMPORTED_MODULE_23__.isAnchor)((0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$anchor__WEBPACK_IMPORTED_MODULE_23__.uriToAnchor)($refBaseURI))) {
|
|
2945
2976
|
// we're dealing with JSON Schema $anchor here
|
|
2946
|
-
reference = await this.toReference(
|
|
2977
|
+
reference = await this.toReference(_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.unsanitize($refBaseURI));
|
|
2947
2978
|
retrievalURI = reference.uri;
|
|
2948
|
-
const selector = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$
|
|
2949
|
-
referencedElement = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$
|
|
2979
|
+
const selector = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$anchor__WEBPACK_IMPORTED_MODULE_23__.uriToAnchor)($refBaseURI);
|
|
2980
|
+
referencedElement = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1_selectors_$anchor__WEBPACK_IMPORTED_MODULE_23__.evaluate)(selector, (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.maybeRefractToSchemaElement)(reference.value.result));
|
|
2950
2981
|
} else {
|
|
2951
2982
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
2952
|
-
reference = await this.toReference(
|
|
2983
|
+
reference = await this.toReference(_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.unsanitize($refBaseURI));
|
|
2953
2984
|
retrievalURI = reference.uri;
|
|
2954
|
-
const selector = (0,
|
|
2955
|
-
referencedElement = (0,
|
|
2985
|
+
const selector = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_9__.uriToPointer)($refBaseURI);
|
|
2986
|
+
referencedElement = (0,_swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.maybeRefractToSchemaElement)((0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__["default"])(selector, reference.value.result));
|
|
2956
2987
|
}
|
|
2957
2988
|
} else {
|
|
2958
2989
|
throw error;
|
|
@@ -2961,24 +2992,26 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2961
2992
|
|
|
2962
2993
|
// detect direct or indirect reference
|
|
2963
2994
|
if (this.indirections.includes(referencedElement)) {
|
|
2964
|
-
throw new
|
|
2995
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_13__["default"]('Recursive Schema Object reference detected');
|
|
2965
2996
|
}
|
|
2966
2997
|
|
|
2967
2998
|
// detect maximum depth of dereferencing
|
|
2968
2999
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
2969
|
-
throw new
|
|
3000
|
+
throw new _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_14__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
2970
3001
|
}
|
|
2971
3002
|
|
|
2972
3003
|
// useCircularStructures option processing
|
|
2973
3004
|
if (!this.useCircularStructures) {
|
|
2974
|
-
const hasCycles = ancestorsLineage.
|
|
3005
|
+
const hasCycles = ancestorsLineage.includes(referencedElement);
|
|
2975
3006
|
if (hasCycles) {
|
|
2976
|
-
if (
|
|
3007
|
+
if (_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isHttpUrl(retrievalURI) || _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.isFileSystemPath(retrievalURI)) {
|
|
2977
3008
|
// make the referencing URL or file system path absolute
|
|
2978
|
-
const baseURI =
|
|
2979
|
-
|
|
3009
|
+
const baseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, $refBaseURI);
|
|
3010
|
+
const cycledSchemaElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.SchemaElement({
|
|
2980
3011
|
$ref: baseURI
|
|
2981
|
-
}, (0,
|
|
3012
|
+
}, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(referencingElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(referencingElement.attributes));
|
|
3013
|
+
cycledSchemaElement.get('$ref').classes.push('cycle');
|
|
3014
|
+
return cycledSchemaElement;
|
|
2982
3015
|
}
|
|
2983
3016
|
// skip processing this schema and all it's child schemas
|
|
2984
3017
|
return false;
|
|
@@ -2997,47 +3030,51 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
2997
3030
|
useCircularStructures: this.useCircularStructures,
|
|
2998
3031
|
allowMetaPatches: this.allowMetaPatches,
|
|
2999
3032
|
ancestors: ancestorsLineage,
|
|
3000
|
-
basePath: this.basePath ?? [...(0,
|
|
3033
|
+
basePath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, referencingElement]), '$ref']
|
|
3001
3034
|
});
|
|
3002
3035
|
referencedElement = await visitAsync(referencedElement, mergeVisitor, {
|
|
3003
|
-
keyMap:
|
|
3004
|
-
nodeTypeGetter:
|
|
3036
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.keyMap,
|
|
3037
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.getNodeType
|
|
3005
3038
|
});
|
|
3006
3039
|
|
|
3007
3040
|
// remove referencing schema from ancestors lineage
|
|
3008
3041
|
directAncestors.delete(referencingElement);
|
|
3009
3042
|
this.indirections.pop();
|
|
3010
|
-
if ((0,
|
|
3011
|
-
const booleanJsonSchemaElement = (0,
|
|
3043
|
+
if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_7__.isBooleanJsonSchemaElement)(referencedElement)) {
|
|
3044
|
+
const booleanJsonSchemaElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(referencedElement);
|
|
3012
3045
|
// annotate referenced element with info about original referencing element
|
|
3013
3046
|
booleanJsonSchemaElement.setMetaProperty('ref-fields', {
|
|
3014
|
-
$ref: (0,
|
|
3047
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)
|
|
3015
3048
|
});
|
|
3016
3049
|
// annotate referenced element with info about origin
|
|
3017
3050
|
booleanJsonSchemaElement.setMetaProperty('ref-origin', reference.uri);
|
|
3051
|
+
// annotate fragment with info about referencing element
|
|
3052
|
+
booleanJsonSchemaElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
3018
3053
|
return booleanJsonSchemaElement;
|
|
3019
3054
|
}
|
|
3020
3055
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
3021
3056
|
// Schema Object - merge keywords from referenced schema with referencing schema
|
|
3022
|
-
const mergedElement = new
|
|
3057
|
+
const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_12__.SchemaElement([...refedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(refedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(refedElement.attributes));
|
|
3023
3058
|
// existing keywords from referencing schema overrides ones from referenced schema
|
|
3024
3059
|
referencingElement.forEach((value, keyElement, item) => {
|
|
3025
|
-
mergedElement.remove((0,
|
|
3060
|
+
mergedElement.remove((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(keyElement));
|
|
3026
3061
|
mergedElement.content.push(item);
|
|
3027
3062
|
});
|
|
3028
3063
|
mergedElement.remove('$ref');
|
|
3029
3064
|
// annotate referenced element with info about original referencing element
|
|
3030
3065
|
mergedElement.setMetaProperty('ref-fields', {
|
|
3031
|
-
$ref: (0,
|
|
3066
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)
|
|
3032
3067
|
});
|
|
3033
3068
|
// annotate fragment with info about origin
|
|
3034
3069
|
mergedElement.setMetaProperty('ref-origin', reference.uri);
|
|
3070
|
+
// annotate fragment with info about referencing element
|
|
3071
|
+
mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_15__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
3035
3072
|
|
|
3036
3073
|
// allowMetaPatches option processing
|
|
3037
3074
|
if (this.allowMetaPatches) {
|
|
3038
3075
|
// apply meta patch only when not already applied
|
|
3039
3076
|
if (typeof mergedElement.get('$$ref') === 'undefined') {
|
|
3040
|
-
const baseURI =
|
|
3077
|
+
const baseURI = _swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_8__.resolve(retrievalURI, $refBaseURI);
|
|
3041
3078
|
mergedElement.set('$$ref', baseURI);
|
|
3042
3079
|
}
|
|
3043
3080
|
}
|
|
@@ -3045,11 +3082,12 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
3045
3082
|
};
|
|
3046
3083
|
|
|
3047
3084
|
// attempting to create cycle
|
|
3048
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
3049
|
-
|
|
3050
|
-
|
|
3085
|
+
if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
|
|
3086
|
+
const replaceWith = ancestorsLineage.findItem(wasReferencedBy(referencingElement)) ?? mergeAndAnnotateReferencedElement(referencedElement);
|
|
3087
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_6__.isMemberElement)(parent)) {
|
|
3088
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
3051
3089
|
} else if (Array.isArray(parent)) {
|
|
3052
|
-
parent[key] =
|
|
3090
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
3053
3091
|
}
|
|
3054
3092
|
|
|
3055
3093
|
return false;
|
|
@@ -3058,11 +3096,11 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
3058
3096
|
// transclude referencing element with merged referenced element
|
|
3059
3097
|
return mergeAndAnnotateReferencedElement(referencedElement);
|
|
3060
3098
|
} catch (error) {
|
|
3061
|
-
const rootCause = (0,
|
|
3099
|
+
const rootCause = (0,_utils_get_root_cause_js__WEBPACK_IMPORTED_MODULE_18__["default"])(error);
|
|
3062
3100
|
const wrappedError = new _errors_index_js__WEBPACK_IMPORTED_MODULE_1__.SchemaRefError(`Could not resolve reference: ${rootCause.message}`, {
|
|
3063
3101
|
baseDoc: this.reference.uri,
|
|
3064
|
-
$ref: (0,
|
|
3065
|
-
fullPath: this.basePath ?? [...(0,
|
|
3102
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref),
|
|
3103
|
+
fullPath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, referencingElement]), '$ref']
|
|
3066
3104
|
}, rootCause);
|
|
3067
3105
|
this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
|
|
3068
3106
|
return undefined;
|
|
@@ -3078,13 +3116,13 @@ const OpenApi3_1SwaggerClientDereferenceVisitor = _swagger_api_apidom_reference_
|
|
|
3078
3116
|
},
|
|
3079
3117
|
async ExampleElement(exampleElement, key, parent, path, ancestors) {
|
|
3080
3118
|
try {
|
|
3081
|
-
return await
|
|
3119
|
+
return await _swagger_api_apidom_reference_dereference_strategies_openapi_3_1__WEBPACK_IMPORTED_MODULE_5__["default"].compose.methods.ExampleElement.call(this, exampleElement, key, parent, path, ancestors);
|
|
3082
3120
|
} catch (error) {
|
|
3083
|
-
const rootCause = (0,
|
|
3121
|
+
const rootCause = (0,_utils_get_root_cause_js__WEBPACK_IMPORTED_MODULE_18__["default"])(error);
|
|
3084
3122
|
const wrappedError = wrapError(rootCause, {
|
|
3085
3123
|
baseDoc: this.reference.uri,
|
|
3086
|
-
externalValue: (0,
|
|
3087
|
-
fullPath: this.basePath ?? [...(0,
|
|
3124
|
+
externalValue: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(exampleElement.externalValue),
|
|
3125
|
+
fullPath: this.basePath ?? [...(0,_utils_to_path_js__WEBPACK_IMPORTED_MODULE_16__["default"])([...ancestors, parent, exampleElement]), 'externalValue']
|
|
3088
3126
|
});
|
|
3089
3127
|
this.options.dereference.dereferenceOpts?.errors?.push?.(wrappedError);
|
|
3090
3128
|
return undefined;
|
|
@@ -4166,7 +4204,7 @@ const resolveOpenAPI31Strategy = async options => {
|
|
|
4166
4204
|
if (jsonPointer !== '') refSet.rootRef = null; // reset root reference as we want fragment to become the root reference
|
|
4167
4205
|
|
|
4168
4206
|
// prepare ancestors; needed for cases where fragment is not OpenAPI element
|
|
4169
|
-
const ancestors = [new
|
|
4207
|
+
const ancestors = [new Set([fragmentElement])];
|
|
4170
4208
|
const errors = [];
|
|
4171
4209
|
const dereferenced = await (0,_swagger_api_apidom_reference_configuration_empty__WEBPACK_IMPORTED_MODULE_16__.dereferenceApiDOM)(fragmentElement, {
|
|
4172
4210
|
resolve: {
|
|
@@ -18827,6 +18865,480 @@ var trimCharsStart = (0,ramda__WEBPACK_IMPORTED_MODULE_0__.curry)(function (char
|
|
|
18827
18865
|
|
|
18828
18866
|
/***/ }),
|
|
18829
18867
|
|
|
18868
|
+
/***/ 77913:
|
|
18869
|
+
/***/ ((module) => {
|
|
18870
|
+
|
|
18871
|
+
"use strict";
|
|
18872
|
+
|
|
18873
|
+
var ShortUniqueId = (() => {
|
|
18874
|
+
var __defProp = Object.defineProperty;
|
|
18875
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
18876
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18877
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
18878
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18879
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
18880
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18881
|
+
var __spreadValues = (a, b) => {
|
|
18882
|
+
for (var prop in b || (b = {}))
|
|
18883
|
+
if (__hasOwnProp.call(b, prop))
|
|
18884
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18885
|
+
if (__getOwnPropSymbols)
|
|
18886
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18887
|
+
if (__propIsEnum.call(b, prop))
|
|
18888
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18889
|
+
}
|
|
18890
|
+
return a;
|
|
18891
|
+
};
|
|
18892
|
+
var __export = (target, all) => {
|
|
18893
|
+
for (var name in all)
|
|
18894
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18895
|
+
};
|
|
18896
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18897
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18898
|
+
for (let key of __getOwnPropNames(from))
|
|
18899
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18900
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18901
|
+
}
|
|
18902
|
+
return to;
|
|
18903
|
+
};
|
|
18904
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18905
|
+
var __publicField = (obj, key, value) => {
|
|
18906
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
18907
|
+
return value;
|
|
18908
|
+
};
|
|
18909
|
+
|
|
18910
|
+
// src/index.ts
|
|
18911
|
+
var src_exports = {};
|
|
18912
|
+
__export(src_exports, {
|
|
18913
|
+
DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
|
|
18914
|
+
DEFAULT_UUID_LENGTH: () => DEFAULT_UUID_LENGTH,
|
|
18915
|
+
default: () => ShortUniqueId
|
|
18916
|
+
});
|
|
18917
|
+
|
|
18918
|
+
// package.json
|
|
18919
|
+
var version = "5.0.2";
|
|
18920
|
+
|
|
18921
|
+
// src/index.ts
|
|
18922
|
+
var DEFAULT_UUID_LENGTH = 6;
|
|
18923
|
+
var DEFAULT_OPTIONS = {
|
|
18924
|
+
dictionary: "alphanum",
|
|
18925
|
+
shuffle: true,
|
|
18926
|
+
debug: false,
|
|
18927
|
+
length: DEFAULT_UUID_LENGTH,
|
|
18928
|
+
counter: 0
|
|
18929
|
+
};
|
|
18930
|
+
var _ShortUniqueId = class _ShortUniqueId {
|
|
18931
|
+
constructor(argOptions = {}) {
|
|
18932
|
+
__publicField(this, "counter");
|
|
18933
|
+
__publicField(this, "debug");
|
|
18934
|
+
__publicField(this, "dict");
|
|
18935
|
+
__publicField(this, "version");
|
|
18936
|
+
__publicField(this, "dictIndex", 0);
|
|
18937
|
+
__publicField(this, "dictRange", []);
|
|
18938
|
+
__publicField(this, "lowerBound", 0);
|
|
18939
|
+
__publicField(this, "upperBound", 0);
|
|
18940
|
+
__publicField(this, "dictLength", 0);
|
|
18941
|
+
__publicField(this, "uuidLength");
|
|
18942
|
+
__publicField(this, "_digit_first_ascii", 48);
|
|
18943
|
+
__publicField(this, "_digit_last_ascii", 58);
|
|
18944
|
+
__publicField(this, "_alpha_lower_first_ascii", 97);
|
|
18945
|
+
__publicField(this, "_alpha_lower_last_ascii", 123);
|
|
18946
|
+
__publicField(this, "_hex_last_ascii", 103);
|
|
18947
|
+
__publicField(this, "_alpha_upper_first_ascii", 65);
|
|
18948
|
+
__publicField(this, "_alpha_upper_last_ascii", 91);
|
|
18949
|
+
__publicField(this, "_number_dict_ranges", {
|
|
18950
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii]
|
|
18951
|
+
});
|
|
18952
|
+
__publicField(this, "_alpha_dict_ranges", {
|
|
18953
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
18954
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
18955
|
+
});
|
|
18956
|
+
__publicField(this, "_alpha_lower_dict_ranges", {
|
|
18957
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
18958
|
+
});
|
|
18959
|
+
__publicField(this, "_alpha_upper_dict_ranges", {
|
|
18960
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
18961
|
+
});
|
|
18962
|
+
__publicField(this, "_alphanum_dict_ranges", {
|
|
18963
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
18964
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
|
|
18965
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
18966
|
+
});
|
|
18967
|
+
__publicField(this, "_alphanum_lower_dict_ranges", {
|
|
18968
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
18969
|
+
lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
|
|
18970
|
+
});
|
|
18971
|
+
__publicField(this, "_alphanum_upper_dict_ranges", {
|
|
18972
|
+
digits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
18973
|
+
upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
|
|
18974
|
+
});
|
|
18975
|
+
__publicField(this, "_hex_dict_ranges", {
|
|
18976
|
+
decDigits: [this._digit_first_ascii, this._digit_last_ascii],
|
|
18977
|
+
alphaDigits: [this._alpha_lower_first_ascii, this._hex_last_ascii]
|
|
18978
|
+
});
|
|
18979
|
+
__publicField(this, "_dict_ranges", {
|
|
18980
|
+
_number_dict_ranges: this._number_dict_ranges,
|
|
18981
|
+
_alpha_dict_ranges: this._alpha_dict_ranges,
|
|
18982
|
+
_alpha_lower_dict_ranges: this._alpha_lower_dict_ranges,
|
|
18983
|
+
_alpha_upper_dict_ranges: this._alpha_upper_dict_ranges,
|
|
18984
|
+
_alphanum_dict_ranges: this._alphanum_dict_ranges,
|
|
18985
|
+
_alphanum_lower_dict_ranges: this._alphanum_lower_dict_ranges,
|
|
18986
|
+
_alphanum_upper_dict_ranges: this._alphanum_upper_dict_ranges,
|
|
18987
|
+
_hex_dict_ranges: this._hex_dict_ranges
|
|
18988
|
+
});
|
|
18989
|
+
/* tslint:disable consistent-return */
|
|
18990
|
+
__publicField(this, "log", (...args) => {
|
|
18991
|
+
const finalArgs = [...args];
|
|
18992
|
+
finalArgs[0] = `[short-unique-id] ${args[0]}`;
|
|
18993
|
+
if (this.debug === true) {
|
|
18994
|
+
if (typeof console !== "undefined" && console !== null) {
|
|
18995
|
+
return console.log(...finalArgs);
|
|
18996
|
+
}
|
|
18997
|
+
}
|
|
18998
|
+
});
|
|
18999
|
+
/* tslint:enable consistent-return */
|
|
19000
|
+
/** Change the dictionary after initialization. */
|
|
19001
|
+
__publicField(this, "setDictionary", (dictionary, shuffle) => {
|
|
19002
|
+
let finalDict;
|
|
19003
|
+
if (dictionary && Array.isArray(dictionary) && dictionary.length > 1) {
|
|
19004
|
+
finalDict = dictionary;
|
|
19005
|
+
} else {
|
|
19006
|
+
finalDict = [];
|
|
19007
|
+
let i;
|
|
19008
|
+
this.dictIndex = i = 0;
|
|
19009
|
+
const rangesName = `_${dictionary}_dict_ranges`;
|
|
19010
|
+
const ranges = this._dict_ranges[rangesName];
|
|
19011
|
+
Object.keys(ranges).forEach((rangeType) => {
|
|
19012
|
+
const rangeTypeKey = rangeType;
|
|
19013
|
+
this.dictRange = ranges[rangeTypeKey];
|
|
19014
|
+
this.lowerBound = this.dictRange[0];
|
|
19015
|
+
this.upperBound = this.dictRange[1];
|
|
19016
|
+
for (this.dictIndex = i = this.lowerBound; this.lowerBound <= this.upperBound ? i < this.upperBound : i > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? i += 1 : i -= 1) {
|
|
19017
|
+
finalDict.push(String.fromCharCode(this.dictIndex));
|
|
19018
|
+
}
|
|
19019
|
+
});
|
|
19020
|
+
}
|
|
19021
|
+
if (shuffle) {
|
|
19022
|
+
const PROBABILITY = 0.5;
|
|
19023
|
+
finalDict = finalDict.sort(() => Math.random() - PROBABILITY);
|
|
19024
|
+
}
|
|
19025
|
+
this.dict = finalDict;
|
|
19026
|
+
this.dictLength = this.dict.length;
|
|
19027
|
+
this.setCounter(0);
|
|
19028
|
+
});
|
|
19029
|
+
__publicField(this, "seq", () => {
|
|
19030
|
+
return this.sequentialUUID();
|
|
19031
|
+
});
|
|
19032
|
+
/**
|
|
19033
|
+
* Generates UUID based on internal counter that's incremented after each ID generation.
|
|
19034
|
+
* @alias `const uid = new ShortUniqueId(); uid.seq();`
|
|
19035
|
+
*/
|
|
19036
|
+
__publicField(this, "sequentialUUID", () => {
|
|
19037
|
+
let counterDiv;
|
|
19038
|
+
let counterRem;
|
|
19039
|
+
let id = "";
|
|
19040
|
+
counterDiv = this.counter;
|
|
19041
|
+
do {
|
|
19042
|
+
counterRem = counterDiv % this.dictLength;
|
|
19043
|
+
counterDiv = Math.trunc(counterDiv / this.dictLength);
|
|
19044
|
+
id += this.dict[counterRem];
|
|
19045
|
+
} while (counterDiv !== 0);
|
|
19046
|
+
this.counter += 1;
|
|
19047
|
+
return id;
|
|
19048
|
+
});
|
|
19049
|
+
__publicField(this, "rnd", (uuidLength = this.uuidLength || DEFAULT_UUID_LENGTH) => {
|
|
19050
|
+
return this.randomUUID(uuidLength);
|
|
19051
|
+
});
|
|
19052
|
+
/**
|
|
19053
|
+
* Generates UUID by creating each part randomly.
|
|
19054
|
+
* @alias `const uid = new ShortUniqueId(); uid.rnd(uuidLength: number);`
|
|
19055
|
+
*/
|
|
19056
|
+
__publicField(this, "randomUUID", (uuidLength = this.uuidLength || DEFAULT_UUID_LENGTH) => {
|
|
19057
|
+
let id;
|
|
19058
|
+
let randomPartIdx;
|
|
19059
|
+
let j;
|
|
19060
|
+
if (uuidLength === null || typeof uuidLength === "undefined" || uuidLength < 1) {
|
|
19061
|
+
throw new Error("Invalid UUID Length Provided");
|
|
19062
|
+
}
|
|
19063
|
+
const isPositive = uuidLength >= 0;
|
|
19064
|
+
id = "";
|
|
19065
|
+
for (j = 0; j < uuidLength; j += 1) {
|
|
19066
|
+
randomPartIdx = parseInt(
|
|
19067
|
+
(Math.random() * this.dictLength).toFixed(0),
|
|
19068
|
+
10
|
|
19069
|
+
) % this.dictLength;
|
|
19070
|
+
id += this.dict[randomPartIdx];
|
|
19071
|
+
}
|
|
19072
|
+
return id;
|
|
19073
|
+
});
|
|
19074
|
+
__publicField(this, "fmt", (format, date) => {
|
|
19075
|
+
return this.formattedUUID(format, date);
|
|
19076
|
+
});
|
|
19077
|
+
/**
|
|
19078
|
+
* Generates custom UUID with the provided format string.
|
|
19079
|
+
* @alias `const uid = new ShortUniqueId(); uid.fmt(format: string);`
|
|
19080
|
+
*/
|
|
19081
|
+
__publicField(this, "formattedUUID", (format, date) => {
|
|
19082
|
+
const fnMap = {
|
|
19083
|
+
"$r": this.randomUUID,
|
|
19084
|
+
"$s": this.sequentialUUID,
|
|
19085
|
+
"$t": this.stamp
|
|
19086
|
+
};
|
|
19087
|
+
const result = format.replace(
|
|
19088
|
+
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
19089
|
+
(m) => {
|
|
19090
|
+
const fn = m.slice(0, 2);
|
|
19091
|
+
const len = parseInt(m.slice(2), 10);
|
|
19092
|
+
if (fn === "$s") {
|
|
19093
|
+
return fnMap[fn]().padStart(len, "0");
|
|
19094
|
+
}
|
|
19095
|
+
if (fn === "$t" && date) {
|
|
19096
|
+
return fnMap[fn](len, date);
|
|
19097
|
+
}
|
|
19098
|
+
return fnMap[fn](len);
|
|
19099
|
+
}
|
|
19100
|
+
);
|
|
19101
|
+
return result;
|
|
19102
|
+
});
|
|
19103
|
+
/**
|
|
19104
|
+
* Calculates total number of possible UUIDs.
|
|
19105
|
+
*
|
|
19106
|
+
* Given that:
|
|
19107
|
+
*
|
|
19108
|
+
* - `H` is the total number of possible UUIDs
|
|
19109
|
+
* - `n` is the number of unique characters in the dictionary
|
|
19110
|
+
* - `l` is the UUID length
|
|
19111
|
+
*
|
|
19112
|
+
* Then `H` is defined as `n` to the power of `l`:
|
|
19113
|
+
*
|
|
19114
|
+
* <div style="background: white; padding: 5px; border-radius: 5px; overflow: hidden;">
|
|
19115
|
+
* <img src="https://render.githubusercontent.com/render/math?math=%5CHuge%20H=n%5El"/>
|
|
19116
|
+
* </div>
|
|
19117
|
+
*
|
|
19118
|
+
* This function returns `H`.
|
|
19119
|
+
*/
|
|
19120
|
+
__publicField(this, "availableUUIDs", (uuidLength = this.uuidLength) => {
|
|
19121
|
+
return parseFloat(
|
|
19122
|
+
Math.pow([...new Set(this.dict)].length, uuidLength).toFixed(0)
|
|
19123
|
+
);
|
|
19124
|
+
});
|
|
19125
|
+
/**
|
|
19126
|
+
* Calculates approximate number of hashes before first collision.
|
|
19127
|
+
*
|
|
19128
|
+
* Given that:
|
|
19129
|
+
*
|
|
19130
|
+
* - `H` is the total number of possible UUIDs, or in terms of this library,
|
|
19131
|
+
* the result of running `availableUUIDs()`
|
|
19132
|
+
* - the expected number of values we have to choose before finding the
|
|
19133
|
+
* first collision can be expressed as the quantity `Q(H)`
|
|
19134
|
+
*
|
|
19135
|
+
* Then `Q(H)` can be approximated as the square root of the product of half
|
|
19136
|
+
* of pi times `H`:
|
|
19137
|
+
*
|
|
19138
|
+
* <div style="background: white; padding: 5px; border-radius: 5px; overflow: hidden;">
|
|
19139
|
+
* <img src="https://render.githubusercontent.com/render/math?math=%5CHuge%20Q(H)%5Capprox%5Csqrt%7B%5Cfrac%7B%5Cpi%7D%7B2%7DH%7D"/>
|
|
19140
|
+
* </div>
|
|
19141
|
+
*
|
|
19142
|
+
* This function returns `Q(H)`.
|
|
19143
|
+
*
|
|
19144
|
+
* (see [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution))
|
|
19145
|
+
*/
|
|
19146
|
+
__publicField(this, "approxMaxBeforeCollision", (rounds = this.availableUUIDs(this.uuidLength)) => {
|
|
19147
|
+
return parseFloat(
|
|
19148
|
+
Math.sqrt(Math.PI / 2 * rounds).toFixed(20)
|
|
19149
|
+
);
|
|
19150
|
+
});
|
|
19151
|
+
/**
|
|
19152
|
+
* Calculates probability of generating duplicate UUIDs (a collision) in a
|
|
19153
|
+
* given number of UUID generation rounds.
|
|
19154
|
+
*
|
|
19155
|
+
* Given that:
|
|
19156
|
+
*
|
|
19157
|
+
* - `r` is the maximum number of times that `randomUUID()` will be called,
|
|
19158
|
+
* or better said the number of _rounds_
|
|
19159
|
+
* - `H` is the total number of possible UUIDs, or in terms of this library,
|
|
19160
|
+
* the result of running `availableUUIDs()`
|
|
19161
|
+
*
|
|
19162
|
+
* Then the probability of collision `p(r; H)` can be approximated as the result
|
|
19163
|
+
* of dividing the square root of the product of half of pi times `r` by `H`:
|
|
19164
|
+
*
|
|
19165
|
+
* <div style="background: white; padding: 5px; border-radius: 5px; overflow: hidden;">
|
|
19166
|
+
* <img src="https://render.githubusercontent.com/render/math?math=%5CHuge%20p(r%3B%20H)%5Capprox%5Cfrac%7B%5Csqrt%7B%5Cfrac%7B%5Cpi%7D%7B2%7Dr%7D%7D%7BH%7D"/>
|
|
19167
|
+
* </div>
|
|
19168
|
+
*
|
|
19169
|
+
* This function returns `p(r; H)`.
|
|
19170
|
+
*
|
|
19171
|
+
* (see [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution))
|
|
19172
|
+
*
|
|
19173
|
+
* (Useful if you are wondering _"If I use this lib and expect to perform at most
|
|
19174
|
+
* `r` rounds of UUID generations, what is the probability that I will hit a duplicate UUID?"_.)
|
|
19175
|
+
*/
|
|
19176
|
+
__publicField(this, "collisionProbability", (rounds = this.availableUUIDs(this.uuidLength), uuidLength = this.uuidLength) => {
|
|
19177
|
+
return parseFloat(
|
|
19178
|
+
(this.approxMaxBeforeCollision(rounds) / this.availableUUIDs(uuidLength)).toFixed(20)
|
|
19179
|
+
);
|
|
19180
|
+
});
|
|
19181
|
+
/**
|
|
19182
|
+
* Calculate a "uniqueness" score (from 0 to 1) of UUIDs based on size of
|
|
19183
|
+
* dictionary and chosen UUID length.
|
|
19184
|
+
*
|
|
19185
|
+
* Given that:
|
|
19186
|
+
*
|
|
19187
|
+
* - `H` is the total number of possible UUIDs, or in terms of this library,
|
|
19188
|
+
* the result of running `availableUUIDs()`
|
|
19189
|
+
* - `Q(H)` is the approximate number of hashes before first collision,
|
|
19190
|
+
* or in terms of this library, the result of running `approxMaxBeforeCollision()`
|
|
19191
|
+
*
|
|
19192
|
+
* Then `uniqueness` can be expressed as the additive inverse of the probability of
|
|
19193
|
+
* generating a "word" I had previously generated (a duplicate) at any given iteration
|
|
19194
|
+
* up to the the total number of possible UUIDs expressed as the quotiend of `Q(H)` and `H`:
|
|
19195
|
+
*
|
|
19196
|
+
* <div style="background: white; padding: 5px; border-radius: 5px; overflow: hidden;">
|
|
19197
|
+
* <img src="https://render.githubusercontent.com/render/math?math=%5CHuge%201-%5Cfrac%7BQ(H)%7D%7BH%7D"/>
|
|
19198
|
+
* </div>
|
|
19199
|
+
*
|
|
19200
|
+
* (Useful if you need a value to rate the "quality" of the combination of given dictionary
|
|
19201
|
+
* and UUID length. The closer to 1, higher the uniqueness and thus better the quality.)
|
|
19202
|
+
*/
|
|
19203
|
+
__publicField(this, "uniqueness", (rounds = this.availableUUIDs(this.uuidLength)) => {
|
|
19204
|
+
const score = parseFloat(
|
|
19205
|
+
(1 - this.approxMaxBeforeCollision(rounds) / rounds).toFixed(20)
|
|
19206
|
+
);
|
|
19207
|
+
return score > 1 ? 1 : score < 0 ? 0 : score;
|
|
19208
|
+
});
|
|
19209
|
+
/**
|
|
19210
|
+
* Return the version of this module.
|
|
19211
|
+
*/
|
|
19212
|
+
__publicField(this, "getVersion", () => {
|
|
19213
|
+
return this.version;
|
|
19214
|
+
});
|
|
19215
|
+
/**
|
|
19216
|
+
* Generates a UUID with a timestamp that can be extracted using `uid.parseStamp(stampString);`.
|
|
19217
|
+
*
|
|
19218
|
+
* ```js
|
|
19219
|
+
* const uidWithTimestamp = uid.stamp(32);
|
|
19220
|
+
* console.log(uidWithTimestamp);
|
|
19221
|
+
* // GDa608f973aRCHLXQYPTbKDbjDeVsSb3
|
|
19222
|
+
*
|
|
19223
|
+
* console.log(uid.parseStamp(uidWithTimestamp));
|
|
19224
|
+
* // 2021-05-03T06:24:58.000Z
|
|
19225
|
+
* ```
|
|
19226
|
+
*/
|
|
19227
|
+
__publicField(this, "stamp", (finalLength, date) => {
|
|
19228
|
+
const hexStamp = Math.floor(+(date || /* @__PURE__ */ new Date()) / 1e3).toString(16);
|
|
19229
|
+
if (typeof finalLength === "number" && finalLength === 0) {
|
|
19230
|
+
return hexStamp;
|
|
19231
|
+
}
|
|
19232
|
+
if (typeof finalLength !== "number" || finalLength < 10) {
|
|
19233
|
+
throw new Error(
|
|
19234
|
+
[
|
|
19235
|
+
"Param finalLength must be a number greater than or equal to 10,",
|
|
19236
|
+
"or 0 if you want the raw hexadecimal timestamp"
|
|
19237
|
+
].join("\n")
|
|
19238
|
+
);
|
|
19239
|
+
}
|
|
19240
|
+
const idLength = finalLength - 9;
|
|
19241
|
+
const rndIdx = Math.round(Math.random() * (idLength > 15 ? 15 : idLength));
|
|
19242
|
+
const id = this.randomUUID(idLength);
|
|
19243
|
+
return `${id.substring(0, rndIdx)}${hexStamp}${id.substring(rndIdx)}${rndIdx.toString(16)}`;
|
|
19244
|
+
});
|
|
19245
|
+
/**
|
|
19246
|
+
* Extracts the date embeded in a UUID generated using the `uid.stamp(finalLength);` method.
|
|
19247
|
+
*
|
|
19248
|
+
* ```js
|
|
19249
|
+
* const uidWithTimestamp = uid.stamp(32);
|
|
19250
|
+
* console.log(uidWithTimestamp);
|
|
19251
|
+
* // GDa608f973aRCHLXQYPTbKDbjDeVsSb3
|
|
19252
|
+
*
|
|
19253
|
+
* console.log(uid.parseStamp(uidWithTimestamp));
|
|
19254
|
+
* // 2021-05-03T06:24:58.000Z
|
|
19255
|
+
* ```
|
|
19256
|
+
*/
|
|
19257
|
+
__publicField(this, "parseStamp", (suid, format) => {
|
|
19258
|
+
if (format && !/t0|t[1-9]\d{1,}/.test(format)) {
|
|
19259
|
+
throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");
|
|
19260
|
+
}
|
|
19261
|
+
const stamp = format ? format.replace(
|
|
19262
|
+
/\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
|
|
19263
|
+
(m) => {
|
|
19264
|
+
const fnMap = {
|
|
19265
|
+
"$r": (len2) => [...Array(len2)].map(() => "r").join(""),
|
|
19266
|
+
"$s": (len2) => [...Array(len2)].map(() => "s").join(""),
|
|
19267
|
+
"$t": (len2) => [...Array(len2)].map(() => "t").join("")
|
|
19268
|
+
};
|
|
19269
|
+
const fn = m.slice(0, 2);
|
|
19270
|
+
const len = parseInt(m.slice(2), 10);
|
|
19271
|
+
return fnMap[fn](len);
|
|
19272
|
+
}
|
|
19273
|
+
).replace(
|
|
19274
|
+
/^(.*?)(t{8,})(.*)$/g,
|
|
19275
|
+
(_m, p1, p2) => {
|
|
19276
|
+
return suid.substring(p1.length, p1.length + p2.length);
|
|
19277
|
+
}
|
|
19278
|
+
) : suid;
|
|
19279
|
+
if (stamp.length === 8) {
|
|
19280
|
+
return new Date(parseInt(stamp, 16) * 1e3);
|
|
19281
|
+
}
|
|
19282
|
+
if (stamp.length < 10) {
|
|
19283
|
+
throw new Error("Stamp length invalid");
|
|
19284
|
+
}
|
|
19285
|
+
const rndIdx = parseInt(stamp.substring(stamp.length - 1), 16);
|
|
19286
|
+
return new Date(parseInt(stamp.substring(rndIdx, rndIdx + 8), 16) * 1e3);
|
|
19287
|
+
});
|
|
19288
|
+
/**
|
|
19289
|
+
* Set the counter to a specific value.
|
|
19290
|
+
*/
|
|
19291
|
+
__publicField(this, "setCounter", (counter) => {
|
|
19292
|
+
this.counter = counter;
|
|
19293
|
+
});
|
|
19294
|
+
const options = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), argOptions);
|
|
19295
|
+
this.counter = 0;
|
|
19296
|
+
this.debug = false;
|
|
19297
|
+
this.dict = [];
|
|
19298
|
+
this.version = version;
|
|
19299
|
+
const {
|
|
19300
|
+
dictionary,
|
|
19301
|
+
shuffle,
|
|
19302
|
+
length,
|
|
19303
|
+
counter
|
|
19304
|
+
} = options;
|
|
19305
|
+
this.uuidLength = length;
|
|
19306
|
+
this.setDictionary(dictionary, shuffle);
|
|
19307
|
+
this.setCounter(counter);
|
|
19308
|
+
this.debug = options.debug;
|
|
19309
|
+
this.log(this.dict);
|
|
19310
|
+
this.log(
|
|
19311
|
+
`Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
|
|
19312
|
+
);
|
|
19313
|
+
this.log = this.log.bind(this);
|
|
19314
|
+
this.setDictionary = this.setDictionary.bind(this);
|
|
19315
|
+
this.setCounter = this.setCounter.bind(this);
|
|
19316
|
+
this.seq = this.seq.bind(this);
|
|
19317
|
+
this.sequentialUUID = this.sequentialUUID.bind(this);
|
|
19318
|
+
this.rnd = this.rnd.bind(this);
|
|
19319
|
+
this.randomUUID = this.randomUUID.bind(this);
|
|
19320
|
+
this.fmt = this.fmt.bind(this);
|
|
19321
|
+
this.formattedUUID = this.formattedUUID.bind(this);
|
|
19322
|
+
this.availableUUIDs = this.availableUUIDs.bind(this);
|
|
19323
|
+
this.approxMaxBeforeCollision = this.approxMaxBeforeCollision.bind(this);
|
|
19324
|
+
this.collisionProbability = this.collisionProbability.bind(this);
|
|
19325
|
+
this.uniqueness = this.uniqueness.bind(this);
|
|
19326
|
+
this.getVersion = this.getVersion.bind(this);
|
|
19327
|
+
this.stamp = this.stamp.bind(this);
|
|
19328
|
+
this.parseStamp = this.parseStamp.bind(this);
|
|
19329
|
+
return this;
|
|
19330
|
+
}
|
|
19331
|
+
};
|
|
19332
|
+
/** @hidden */
|
|
19333
|
+
__publicField(_ShortUniqueId, "default", _ShortUniqueId);
|
|
19334
|
+
var ShortUniqueId = _ShortUniqueId;
|
|
19335
|
+
return __toCommonJS(src_exports);
|
|
19336
|
+
})();
|
|
19337
|
+
//# sourceMappingURL=short-unique-id.js.map
|
|
19338
|
+
true&&(module.exports=ShortUniqueId.default),'undefined'!=typeof window&&(ShortUniqueId=ShortUniqueId.default);
|
|
19339
|
+
|
|
19340
|
+
/***/ }),
|
|
19341
|
+
|
|
18830
19342
|
/***/ 37478:
|
|
18831
19343
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
18832
19344
|
|
|
@@ -19825,7 +20337,7 @@ class CloneError extends _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__[
|
|
|
19825
20337
|
constructor(message, structuredOptions) {
|
|
19826
20338
|
super(message, structuredOptions);
|
|
19827
20339
|
if (typeof structuredOptions !== 'undefined') {
|
|
19828
|
-
this.value = structuredOptions.
|
|
20340
|
+
this.value = structuredOptions.value;
|
|
19829
20341
|
}
|
|
19830
20342
|
}
|
|
19831
20343
|
}
|
|
@@ -20260,6 +20772,103 @@ class SourceMap extends minim__WEBPACK_IMPORTED_MODULE_0__.ArrayElement {
|
|
|
20260
20772
|
|
|
20261
20773
|
/***/ }),
|
|
20262
20774
|
|
|
20775
|
+
/***/ 66398:
|
|
20776
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
20777
|
+
|
|
20778
|
+
"use strict";
|
|
20779
|
+
__webpack_require__.r(__webpack_exports__);
|
|
20780
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
20781
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
20782
|
+
/* harmony export */ });
|
|
20783
|
+
/* harmony import */ var _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29096);
|
|
20784
|
+
|
|
20785
|
+
class ElementIdentityError extends _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
20786
|
+
constructor(message, structuredOptions) {
|
|
20787
|
+
super(message, structuredOptions);
|
|
20788
|
+
if (typeof structuredOptions !== 'undefined') {
|
|
20789
|
+
this.value = structuredOptions.value;
|
|
20790
|
+
}
|
|
20791
|
+
}
|
|
20792
|
+
}
|
|
20793
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ElementIdentityError);
|
|
20794
|
+
|
|
20795
|
+
/***/ }),
|
|
20796
|
+
|
|
20797
|
+
/***/ 47644:
|
|
20798
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
20799
|
+
|
|
20800
|
+
"use strict";
|
|
20801
|
+
__webpack_require__.r(__webpack_exports__);
|
|
20802
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
20803
|
+
/* harmony export */ IdentityManager: () => (/* binding */ IdentityManager),
|
|
20804
|
+
/* harmony export */ defaultIdentityManager: () => (/* binding */ defaultIdentityManager)
|
|
20805
|
+
/* harmony export */ });
|
|
20806
|
+
/* harmony import */ var minim__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43500);
|
|
20807
|
+
/* harmony import */ var stampit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(43992);
|
|
20808
|
+
/* harmony import */ var short_unique_id__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(77913);
|
|
20809
|
+
/* harmony import */ var _errors_ElementIdentityError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(66398);
|
|
20810
|
+
/* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(28552);
|
|
20811
|
+
|
|
20812
|
+
|
|
20813
|
+
|
|
20814
|
+
|
|
20815
|
+
|
|
20816
|
+
const IdentityManager = stampit__WEBPACK_IMPORTED_MODULE_1__({
|
|
20817
|
+
props: {
|
|
20818
|
+
uuid: null,
|
|
20819
|
+
length: null,
|
|
20820
|
+
identityMap: null
|
|
20821
|
+
},
|
|
20822
|
+
init({
|
|
20823
|
+
length = 6
|
|
20824
|
+
} = {}) {
|
|
20825
|
+
this.length = 6;
|
|
20826
|
+
this.uuid = new short_unique_id__WEBPACK_IMPORTED_MODULE_2__({
|
|
20827
|
+
length
|
|
20828
|
+
});
|
|
20829
|
+
this.identityMap = new WeakMap();
|
|
20830
|
+
},
|
|
20831
|
+
methods: {
|
|
20832
|
+
identify(element) {
|
|
20833
|
+
if (!(0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.isElement)(element)) {
|
|
20834
|
+
throw new _errors_ElementIdentityError_mjs__WEBPACK_IMPORTED_MODULE_4__["default"]('Cannot not identify the element. `element` is neither structurally compatible nor a subclass of an Element class.', {
|
|
20835
|
+
value: element
|
|
20836
|
+
});
|
|
20837
|
+
}
|
|
20838
|
+
|
|
20839
|
+
// use already assigned identity
|
|
20840
|
+
if (element.meta.hasKey('id') && (0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(element.meta.id) && !element.meta.id.equals('')) {
|
|
20841
|
+
return element.id;
|
|
20842
|
+
}
|
|
20843
|
+
|
|
20844
|
+
// assign identity in immutable way
|
|
20845
|
+
if (this.identityMap.has(element)) {
|
|
20846
|
+
return this.identityMap.get(element);
|
|
20847
|
+
}
|
|
20848
|
+
|
|
20849
|
+
// return element identity
|
|
20850
|
+
const id = new minim__WEBPACK_IMPORTED_MODULE_0__.StringElement(this.generateId());
|
|
20851
|
+
this.identityMap.set(element, id);
|
|
20852
|
+
return id;
|
|
20853
|
+
},
|
|
20854
|
+
forget(element) {
|
|
20855
|
+
if (this.identityMap.has(element)) {
|
|
20856
|
+
this.identityMap.delete(element);
|
|
20857
|
+
return true;
|
|
20858
|
+
}
|
|
20859
|
+
return false;
|
|
20860
|
+
},
|
|
20861
|
+
generateId() {
|
|
20862
|
+
return this.uuid.randomUUID();
|
|
20863
|
+
}
|
|
20864
|
+
}
|
|
20865
|
+
});
|
|
20866
|
+
const defaultIdentityManager = IdentityManager({
|
|
20867
|
+
length: 6
|
|
20868
|
+
});
|
|
20869
|
+
|
|
20870
|
+
/***/ }),
|
|
20871
|
+
|
|
20263
20872
|
/***/ 63244:
|
|
20264
20873
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
20265
20874
|
|
|
@@ -38665,30 +39274,31 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
38665
39274
|
/* harmony export */ });
|
|
38666
39275
|
/* harmony import */ var stampit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43992);
|
|
38667
39276
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(25546);
|
|
38668
|
-
/* harmony import */ var
|
|
39277
|
+
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(4926);
|
|
38669
39278
|
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(87395);
|
|
38670
|
-
/* harmony import */ var
|
|
38671
|
-
/* harmony import */ var
|
|
38672
|
-
/* harmony import */ var
|
|
38673
|
-
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(
|
|
38674
|
-
/* harmony import */ var
|
|
38675
|
-
/* harmony import */ var
|
|
38676
|
-
/* harmony import */ var _swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
38677
|
-
/* harmony import */ var
|
|
38678
|
-
/* harmony import */ var
|
|
38679
|
-
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(
|
|
38680
|
-
/* harmony import */ var
|
|
38681
|
-
/* harmony import */ var
|
|
38682
|
-
/* harmony import */ var
|
|
38683
|
-
/* harmony import */ var
|
|
38684
|
-
/* harmony import */ var
|
|
38685
|
-
/* harmony import */ var
|
|
38686
|
-
/* harmony import */ var
|
|
38687
|
-
/* harmony import */ var
|
|
38688
|
-
/* harmony import */ var
|
|
38689
|
-
/* harmony import */ var
|
|
38690
|
-
/* harmony import */ var
|
|
38691
|
-
/* harmony import */ var
|
|
39279
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(47644);
|
|
39280
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(50334);
|
|
39281
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(28552);
|
|
39282
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(50308);
|
|
39283
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(44344);
|
|
39284
|
+
/* harmony import */ var _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(42455);
|
|
39285
|
+
/* harmony import */ var _swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3608);
|
|
39286
|
+
/* harmony import */ var _swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(8647);
|
|
39287
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(66316);
|
|
39288
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(74144);
|
|
39289
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(94481);
|
|
39290
|
+
/* harmony import */ var _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(84714);
|
|
39291
|
+
/* harmony import */ var _selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(90609);
|
|
39292
|
+
/* harmony import */ var _selectors_uri_mjs__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(14726);
|
|
39293
|
+
/* harmony import */ var _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(67625);
|
|
39294
|
+
/* harmony import */ var _errors_MaximumResolverDepthError_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(58496);
|
|
39295
|
+
/* harmony import */ var _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(69239);
|
|
39296
|
+
/* harmony import */ var _parse_index_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(42215);
|
|
39297
|
+
/* harmony import */ var _Reference_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(68488);
|
|
39298
|
+
/* harmony import */ var _util_File_mjs__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(35059);
|
|
39299
|
+
/* harmony import */ var _resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(77079);
|
|
39300
|
+
/* harmony import */ var _util_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(90719);
|
|
39301
|
+
/* harmony import */ var _errors_EvaluationJsonSchemaUriError_mjs__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(552);
|
|
38692
39302
|
|
|
38693
39303
|
|
|
38694
39304
|
|
|
@@ -38709,6 +39319,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
38709
39319
|
// @ts-ignore
|
|
38710
39320
|
const visitAsync = _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_2__.visit[Symbol.for('nodejs.util.promisify.custom')];
|
|
38711
39321
|
|
|
39322
|
+
// initialize element identity manager
|
|
39323
|
+
const identityManager = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_3__.IdentityManager)();
|
|
39324
|
+
|
|
39325
|
+
/**
|
|
39326
|
+
* Predicate for detecting if element was created by merging referencing
|
|
39327
|
+
* element with particular element identity with a referenced element.
|
|
39328
|
+
*/
|
|
39329
|
+
const wasReferencedBy = referencingElement => element => element.meta.hasKey('ref-referencing-element-id') && element.meta.get('ref-referencing-element-id').equals((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(identityManager.identify(referencingElement)));
|
|
39330
|
+
|
|
38712
39331
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
38713
39332
|
const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
38714
39333
|
props: {
|
|
@@ -38723,22 +39342,22 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38723
39342
|
reference,
|
|
38724
39343
|
namespace,
|
|
38725
39344
|
options,
|
|
38726
|
-
ancestors = new
|
|
39345
|
+
ancestors = new _util_mjs__WEBPACK_IMPORTED_MODULE_5__.AncestorLineage()
|
|
38727
39346
|
}) {
|
|
38728
39347
|
this.indirections = indirections;
|
|
38729
39348
|
this.namespace = namespace;
|
|
38730
39349
|
this.reference = reference;
|
|
38731
39350
|
this.options = options;
|
|
38732
|
-
this.ancestors = new
|
|
39351
|
+
this.ancestors = new _util_mjs__WEBPACK_IMPORTED_MODULE_5__.AncestorLineage(...ancestors);
|
|
38733
39352
|
},
|
|
38734
39353
|
methods: {
|
|
38735
39354
|
toBaseURI(uri) {
|
|
38736
|
-
return
|
|
39355
|
+
return _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.resolve(this.reference.uri, _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.sanitize(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.stripHash(uri)));
|
|
38737
39356
|
},
|
|
38738
39357
|
async toReference(uri) {
|
|
38739
39358
|
// detect maximum depth of resolution
|
|
38740
39359
|
if (this.reference.depth >= this.options.resolve.maxDepth) {
|
|
38741
|
-
throw new
|
|
39360
|
+
throw new _errors_MaximumResolverDepthError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"](`Maximum resolution depth of ${this.options.resolve.maxDepth} has been exceeded by file "${this.reference.uri}"`);
|
|
38742
39361
|
}
|
|
38743
39362
|
const baseURI = this.toBaseURI(uri);
|
|
38744
39363
|
const {
|
|
@@ -38749,7 +39368,7 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38749
39368
|
if (refSet.has(baseURI)) {
|
|
38750
39369
|
return refSet.find((0,ramda__WEBPACK_IMPORTED_MODULE_1__.propEq)(baseURI, 'uri'));
|
|
38751
39370
|
}
|
|
38752
|
-
const parseResult = await (0,
|
|
39371
|
+
const parseResult = await (0,_parse_index_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize(baseURI), {
|
|
38753
39372
|
...this.options,
|
|
38754
39373
|
parse: {
|
|
38755
39374
|
...this.options.parse,
|
|
@@ -38758,7 +39377,7 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38758
39377
|
});
|
|
38759
39378
|
|
|
38760
39379
|
// register new Reference with ReferenceSet
|
|
38761
|
-
const reference = (0,
|
|
39380
|
+
const reference = (0,_Reference_mjs__WEBPACK_IMPORTED_MODULE_9__["default"])({
|
|
38762
39381
|
uri: baseURI,
|
|
38763
39382
|
value: parseResult,
|
|
38764
39383
|
depth: this.reference.depth + 1
|
|
@@ -38771,8 +39390,8 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38771
39390
|
* Compute full ancestors lineage.
|
|
38772
39391
|
* Ancestors are flatten to unwrap all Element instances.
|
|
38773
39392
|
*/
|
|
38774
|
-
const directAncestors = new
|
|
38775
|
-
const ancestorsLineage = new
|
|
39393
|
+
const directAncestors = new Set(ancestors.filter(_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isElement));
|
|
39394
|
+
const ancestorsLineage = new _util_mjs__WEBPACK_IMPORTED_MODULE_5__.AncestorLineage(...this.ancestors, directAncestors);
|
|
38776
39395
|
return [ancestorsLineage, directAncestors];
|
|
38777
39396
|
},
|
|
38778
39397
|
async ReferenceElement(referencingElement, key, parent, path, ancestors) {
|
|
@@ -38784,26 +39403,26 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38784
39403
|
}
|
|
38785
39404
|
|
|
38786
39405
|
// ignore resolving external Reference Objects
|
|
38787
|
-
if (!this.options.resolve.external && (0,
|
|
39406
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isReferenceElementExternal)(referencingElement)) {
|
|
38788
39407
|
return false;
|
|
38789
39408
|
}
|
|
38790
|
-
const reference = await this.toReference((0,
|
|
39409
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
38791
39410
|
const {
|
|
38792
39411
|
uri: retrievalURI
|
|
38793
39412
|
} = reference;
|
|
38794
|
-
const $refBaseURI =
|
|
39413
|
+
const $refBaseURI = _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
38795
39414
|
this.indirections.push(referencingElement);
|
|
38796
|
-
const jsonPointer = (0,
|
|
39415
|
+
const jsonPointer = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.uriToPointer)($refBaseURI);
|
|
38797
39416
|
|
|
38798
39417
|
// possibly non-semantic fragment
|
|
38799
|
-
let referencedElement = (0,
|
|
39418
|
+
let referencedElement = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__["default"])(jsonPointer, reference.value.result);
|
|
38800
39419
|
|
|
38801
39420
|
// applying semantics to a fragment
|
|
38802
|
-
if ((0,
|
|
38803
|
-
const referencedElementType = (0,
|
|
38804
|
-
if ((0,
|
|
39421
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isPrimitiveElement)(referencedElement)) {
|
|
39422
|
+
const referencedElementType = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.meta.get('referenced-element'));
|
|
39423
|
+
if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isReferenceLikeElement)(referencedElement)) {
|
|
38805
39424
|
// handling indirect references
|
|
38806
|
-
referencedElement =
|
|
39425
|
+
referencedElement = _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.ReferenceElement.refract(referencedElement);
|
|
38807
39426
|
referencedElement.setMetaProperty('referenced-element', referencedElementType);
|
|
38808
39427
|
} else {
|
|
38809
39428
|
// handling direct references
|
|
@@ -38814,12 +39433,12 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38814
39433
|
|
|
38815
39434
|
// detect direct or indirect reference
|
|
38816
39435
|
if (this.indirections.includes(referencedElement)) {
|
|
38817
|
-
throw new
|
|
39436
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"]('Recursive Reference Object detected');
|
|
38818
39437
|
}
|
|
38819
39438
|
|
|
38820
39439
|
// detect maximum depth of dereferencing
|
|
38821
39440
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
38822
|
-
throw new
|
|
39441
|
+
throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_17__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
38823
39442
|
}
|
|
38824
39443
|
|
|
38825
39444
|
// append referencing reference to ancestors lineage
|
|
@@ -38834,29 +39453,31 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38834
39453
|
ancestors: ancestorsLineage
|
|
38835
39454
|
});
|
|
38836
39455
|
referencedElement = await visitAsync(referencedElement, visitor, {
|
|
38837
|
-
keyMap:
|
|
38838
|
-
nodeTypeGetter:
|
|
39456
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.keyMap,
|
|
39457
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.getNodeType
|
|
38839
39458
|
});
|
|
38840
39459
|
|
|
38841
39460
|
// remove referencing reference from ancestors lineage
|
|
38842
39461
|
directAncestors.delete(referencingElement);
|
|
38843
39462
|
this.indirections.pop();
|
|
38844
39463
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
38845
|
-
const copy = (0,
|
|
39464
|
+
const copy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(refedElement);
|
|
38846
39465
|
|
|
38847
39466
|
// annotate fragment with info about original Reference element
|
|
38848
39467
|
copy.setMetaProperty('ref-fields', {
|
|
38849
|
-
$ref: (0,
|
|
39468
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref),
|
|
38850
39469
|
// @ts-ignore
|
|
38851
|
-
description: (0,
|
|
39470
|
+
description: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.description),
|
|
38852
39471
|
// @ts-ignore
|
|
38853
|
-
summary: (0,
|
|
39472
|
+
summary: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.summary)
|
|
38854
39473
|
});
|
|
38855
39474
|
// annotate fragment with info about origin
|
|
38856
39475
|
copy.setMetaProperty('ref-origin', reference.uri);
|
|
39476
|
+
// annotate fragment with info about referencing element
|
|
39477
|
+
copy.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
38857
39478
|
|
|
38858
39479
|
// override description and summary (outer has higher priority then inner)
|
|
38859
|
-
if ((0,
|
|
39480
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isObjectElement)(refedElement)) {
|
|
38860
39481
|
if (referencingElement.hasKey('description') && 'description' in refedElement) {
|
|
38861
39482
|
// @ts-ignore
|
|
38862
39483
|
copy.remove('description');
|
|
@@ -38874,11 +39495,13 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38874
39495
|
};
|
|
38875
39496
|
|
|
38876
39497
|
// attempting to create cycle
|
|
38877
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
38878
|
-
|
|
38879
|
-
|
|
39498
|
+
if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
|
|
39499
|
+
var _ancestorsLineage$fin;
|
|
39500
|
+
const replaceWith = (_ancestorsLineage$fin = ancestorsLineage.findItem(wasReferencedBy(referencingElement))) !== null && _ancestorsLineage$fin !== void 0 ? _ancestorsLineage$fin : mergeAndAnnotateReferencedElement(referencedElement);
|
|
39501
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isMemberElement)(parent)) {
|
|
39502
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
38880
39503
|
} else if (Array.isArray(parent)) {
|
|
38881
|
-
parent[key] =
|
|
39504
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
38882
39505
|
}
|
|
38883
39506
|
|
|
38884
39507
|
return false;
|
|
@@ -38891,7 +39514,7 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38891
39514
|
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
|
|
38892
39515
|
|
|
38893
39516
|
// ignore PathItemElement without $ref field
|
|
38894
|
-
if (!(0,
|
|
39517
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(referencingElement.$ref)) {
|
|
38895
39518
|
return undefined;
|
|
38896
39519
|
}
|
|
38897
39520
|
|
|
@@ -38901,33 +39524,33 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38901
39524
|
}
|
|
38902
39525
|
|
|
38903
39526
|
// ignore resolving external Path Item Elements
|
|
38904
|
-
if (!this.options.resolve.external && (0,
|
|
39527
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isPathItemElementExternal)(referencingElement)) {
|
|
38905
39528
|
return undefined;
|
|
38906
39529
|
}
|
|
38907
|
-
const reference = await this.toReference((0,
|
|
39530
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
38908
39531
|
const {
|
|
38909
39532
|
uri: retrievalURI
|
|
38910
39533
|
} = reference;
|
|
38911
|
-
const $refBaseURI =
|
|
39534
|
+
const $refBaseURI = _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.resolve(retrievalURI, (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref));
|
|
38912
39535
|
this.indirections.push(referencingElement);
|
|
38913
|
-
const jsonPointer = (0,
|
|
39536
|
+
const jsonPointer = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.uriToPointer)($refBaseURI);
|
|
38914
39537
|
|
|
38915
39538
|
// possibly non-semantic referenced element
|
|
38916
|
-
let referencedElement = (0,
|
|
39539
|
+
let referencedElement = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__["default"])(jsonPointer, reference.value.result);
|
|
38917
39540
|
|
|
38918
39541
|
// applying semantics to a referenced element
|
|
38919
|
-
if ((0,
|
|
38920
|
-
referencedElement =
|
|
39542
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isPrimitiveElement)(referencedElement)) {
|
|
39543
|
+
referencedElement = _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.PathItemElement.refract(referencedElement);
|
|
38921
39544
|
}
|
|
38922
39545
|
|
|
38923
39546
|
// detect direct or indirect reference
|
|
38924
39547
|
if (this.indirections.includes(referencedElement)) {
|
|
38925
|
-
throw new
|
|
39548
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"]('Recursive Path Item Object reference detected');
|
|
38926
39549
|
}
|
|
38927
39550
|
|
|
38928
39551
|
// detect maximum depth of dereferencing
|
|
38929
39552
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
38930
|
-
throw new
|
|
39553
|
+
throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_17__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
38931
39554
|
}
|
|
38932
39555
|
|
|
38933
39556
|
// append referencing path item to ancestors lineage
|
|
@@ -38942,8 +39565,8 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38942
39565
|
ancestors: ancestorsLineage
|
|
38943
39566
|
});
|
|
38944
39567
|
referencedElement = await visitAsync(referencedElement, visitor, {
|
|
38945
|
-
keyMap:
|
|
38946
|
-
nodeTypeGetter:
|
|
39568
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.keyMap,
|
|
39569
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.getNodeType
|
|
38947
39570
|
});
|
|
38948
39571
|
|
|
38949
39572
|
// remove referencing path item from ancestors lineage
|
|
@@ -38951,29 +39574,33 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38951
39574
|
this.indirections.pop();
|
|
38952
39575
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
38953
39576
|
// merge fields from referenced Path Item with referencing one
|
|
38954
|
-
const mergedElement = new
|
|
39577
|
+
const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.PathItemElement([...refedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(refedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(refedElement.attributes));
|
|
38955
39578
|
// existing keywords from referencing PathItemElement overrides ones from referenced element
|
|
38956
39579
|
referencingElement.forEach((value, keyElement, item) => {
|
|
38957
|
-
mergedElement.remove((0,
|
|
39580
|
+
mergedElement.remove((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(keyElement));
|
|
38958
39581
|
mergedElement.content.push(item);
|
|
38959
39582
|
});
|
|
38960
39583
|
mergedElement.remove('$ref');
|
|
38961
39584
|
|
|
38962
39585
|
// annotate referenced element with info about original referencing element
|
|
38963
39586
|
mergedElement.setMetaProperty('ref-fields', {
|
|
38964
|
-
$ref: (0,
|
|
39587
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)
|
|
38965
39588
|
});
|
|
38966
39589
|
// annotate referenced element with info about origin
|
|
38967
39590
|
mergedElement.setMetaProperty('ref-origin', reference.uri);
|
|
39591
|
+
// annotate fragment with info about referencing element
|
|
39592
|
+
mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
38968
39593
|
return mergedElement;
|
|
38969
39594
|
};
|
|
38970
39595
|
|
|
38971
39596
|
// attempting to create cycle
|
|
38972
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
38973
|
-
|
|
38974
|
-
|
|
39597
|
+
if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
|
|
39598
|
+
var _ancestorsLineage$fin2;
|
|
39599
|
+
const replaceWith = (_ancestorsLineage$fin2 = ancestorsLineage.findItem(wasReferencedBy(referencingElement))) !== null && _ancestorsLineage$fin2 !== void 0 ? _ancestorsLineage$fin2 : mergeAndAnnotateReferencedElement(referencedElement);
|
|
39600
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isMemberElement)(parent)) {
|
|
39601
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
38975
39602
|
} else if (Array.isArray(parent)) {
|
|
38976
|
-
parent[key] =
|
|
39603
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
38977
39604
|
}
|
|
38978
39605
|
|
|
38979
39606
|
return false;
|
|
@@ -38984,48 +39611,48 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
38984
39611
|
},
|
|
38985
39612
|
async LinkElement(linkElement) {
|
|
38986
39613
|
// ignore LinkElement without operationRef or operationId field
|
|
38987
|
-
if (!(0,
|
|
39614
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationRef) && !(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationId)) {
|
|
38988
39615
|
return undefined;
|
|
38989
39616
|
}
|
|
38990
39617
|
|
|
38991
39618
|
// ignore resolving external Path Item Elements
|
|
38992
|
-
if (!this.options.resolve.external && (0,
|
|
39619
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isLinkElementExternal)(linkElement)) {
|
|
38993
39620
|
return undefined;
|
|
38994
39621
|
}
|
|
38995
39622
|
|
|
38996
39623
|
// operationRef and operationId fields are mutually exclusive
|
|
38997
|
-
if ((0,
|
|
38998
|
-
throw new
|
|
39624
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationRef) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationId)) {
|
|
39625
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"]('LinkElement operationRef and operationId fields are mutually exclusive.');
|
|
38999
39626
|
}
|
|
39000
39627
|
let operationElement;
|
|
39001
|
-
if ((0,
|
|
39628
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationRef)) {
|
|
39002
39629
|
var _linkElementCopy$oper;
|
|
39003
39630
|
// possibly non-semantic referenced element
|
|
39004
|
-
const jsonPointer = (0,
|
|
39005
|
-
const reference = await this.toReference((0,
|
|
39006
|
-
operationElement = (0,
|
|
39631
|
+
const jsonPointer = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.uriToPointer)((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(linkElement.operationRef));
|
|
39632
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(linkElement.operationRef));
|
|
39633
|
+
operationElement = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__["default"])(jsonPointer, reference.value.result);
|
|
39007
39634
|
// applying semantics to a referenced element
|
|
39008
|
-
if ((0,
|
|
39009
|
-
operationElement =
|
|
39635
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isPrimitiveElement)(operationElement)) {
|
|
39636
|
+
operationElement = _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.OperationElement.refract(operationElement);
|
|
39010
39637
|
}
|
|
39011
39638
|
// create shallow clone to be able to annotate with metadata
|
|
39012
|
-
operationElement = (0,
|
|
39639
|
+
operationElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(operationElement);
|
|
39013
39640
|
// annotate operation element with info about origin
|
|
39014
39641
|
operationElement.setMetaProperty('ref-origin', reference.uri);
|
|
39015
|
-
const linkElementCopy = (0,
|
|
39642
|
+
const linkElementCopy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(linkElement);
|
|
39016
39643
|
(_linkElementCopy$oper = linkElementCopy.operationRef) === null || _linkElementCopy$oper === void 0 || _linkElementCopy$oper.meta.set('operation', operationElement);
|
|
39017
39644
|
return linkElementCopy;
|
|
39018
39645
|
}
|
|
39019
|
-
if ((0,
|
|
39646
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(linkElement.operationId)) {
|
|
39020
39647
|
var _linkElementCopy$oper2;
|
|
39021
|
-
const operationId = (0,
|
|
39022
|
-
const reference = await this.toReference(
|
|
39023
|
-
operationElement = (0,
|
|
39648
|
+
const operationId = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(linkElement.operationId);
|
|
39649
|
+
const reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize(this.reference.uri));
|
|
39650
|
+
operationElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_20__["default"])(e => (0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isOperationElement)(e) && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isElement)(e.operationId) && e.operationId.equals(operationId), reference.value.result);
|
|
39024
39651
|
// OperationElement not found by its operationId
|
|
39025
|
-
if ((0,
|
|
39026
|
-
throw new
|
|
39652
|
+
if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_21__["default"])(operationElement)) {
|
|
39653
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"](`OperationElement(operationId=${operationId}) not found.`);
|
|
39027
39654
|
}
|
|
39028
|
-
const linkElementCopy = (0,
|
|
39655
|
+
const linkElementCopy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(linkElement);
|
|
39029
39656
|
(_linkElementCopy$oper2 = linkElementCopy.operationId) === null || _linkElementCopy$oper2 === void 0 || _linkElementCopy$oper2.meta.set('operation', operationElement);
|
|
39030
39657
|
return linkElementCopy;
|
|
39031
39658
|
}
|
|
@@ -39035,7 +39662,7 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39035
39662
|
const [ancestorsLineage] = this.toAncestorLineage([...ancestors, parent]);
|
|
39036
39663
|
|
|
39037
39664
|
// ignore ExampleElement without externalValue field
|
|
39038
|
-
if (!(0,
|
|
39665
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(exampleElement.externalValue)) {
|
|
39039
39666
|
return undefined;
|
|
39040
39667
|
}
|
|
39041
39668
|
|
|
@@ -39045,21 +39672,21 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39045
39672
|
}
|
|
39046
39673
|
|
|
39047
39674
|
// ignore resolving ExampleElement externalValue
|
|
39048
|
-
if (!this.options.resolve.external && (0,
|
|
39675
|
+
if (!this.options.resolve.external && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(exampleElement.externalValue)) {
|
|
39049
39676
|
return undefined;
|
|
39050
39677
|
}
|
|
39051
39678
|
|
|
39052
39679
|
// value and externalValue fields are mutually exclusive
|
|
39053
|
-
if (exampleElement.hasKey('value') && (0,
|
|
39054
|
-
throw new
|
|
39680
|
+
if (exampleElement.hasKey('value') && (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(exampleElement.externalValue)) {
|
|
39681
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"]('ExampleElement value and externalValue fields are mutually exclusive.');
|
|
39055
39682
|
}
|
|
39056
|
-
const reference = await this.toReference((0,
|
|
39683
|
+
const reference = await this.toReference((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(exampleElement.externalValue));
|
|
39057
39684
|
|
|
39058
39685
|
// shallow clone of the referenced element
|
|
39059
|
-
const valueElement = (0,
|
|
39686
|
+
const valueElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(reference.value.result);
|
|
39060
39687
|
// annotate operation element with info about origin
|
|
39061
39688
|
valueElement.setMetaProperty('ref-origin', reference.uri);
|
|
39062
|
-
const exampleElementCopy = (0,
|
|
39689
|
+
const exampleElementCopy = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneShallow)(exampleElement);
|
|
39063
39690
|
exampleElementCopy.value = valueElement;
|
|
39064
39691
|
return exampleElementCopy;
|
|
39065
39692
|
},
|
|
@@ -39067,7 +39694,7 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39067
39694
|
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
|
|
39068
39695
|
|
|
39069
39696
|
// skip current referencing schema as $ref keyword was not defined
|
|
39070
|
-
if (!(0,
|
|
39697
|
+
if (!(0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isStringElement)(referencingElement.$ref)) {
|
|
39071
39698
|
// skip traversing this schema but traverse all it's child schemas
|
|
39072
39699
|
return undefined;
|
|
39073
39700
|
}
|
|
@@ -39078,13 +39705,13 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39078
39705
|
}
|
|
39079
39706
|
|
|
39080
39707
|
// compute baseURI using rules around $id and $ref keywords
|
|
39081
|
-
let reference = await this.toReference(
|
|
39708
|
+
let reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize(this.reference.uri));
|
|
39082
39709
|
let {
|
|
39083
39710
|
uri: retrievalURI
|
|
39084
39711
|
} = reference;
|
|
39085
|
-
const $refBaseURI = (0,
|
|
39086
|
-
const $refBaseURIStrippedHash =
|
|
39087
|
-
const file = (0,
|
|
39712
|
+
const $refBaseURI = (0,_resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__.resolveSchema$refField)(retrievalURI, referencingElement);
|
|
39713
|
+
const $refBaseURIStrippedHash = _util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.stripHash($refBaseURI);
|
|
39714
|
+
const file = (0,_util_File_mjs__WEBPACK_IMPORTED_MODULE_23__["default"])({
|
|
39088
39715
|
uri: $refBaseURIStrippedHash
|
|
39089
39716
|
});
|
|
39090
39717
|
const isUnknownURI = (0,ramda__WEBPACK_IMPORTED_MODULE_1__.none)(r => r.canRead(file), this.options.resolve.resolvers);
|
|
@@ -39104,39 +39731,39 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39104
39731
|
if (isUnknownURI || isURL) {
|
|
39105
39732
|
// we're dealing with canonical URI or URL with possible fragment
|
|
39106
39733
|
const selector = $refBaseURI;
|
|
39107
|
-
referencedElement = (0,
|
|
39734
|
+
referencedElement = (0,_selectors_uri_mjs__WEBPACK_IMPORTED_MODULE_24__.evaluate)(selector,
|
|
39108
39735
|
// @ts-ignore
|
|
39109
|
-
(0,
|
|
39736
|
+
(0,_resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__.maybeRefractToSchemaElement)(reference.value.result));
|
|
39110
39737
|
} else {
|
|
39111
39738
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
39112
|
-
reference = await this.toReference(
|
|
39113
|
-
const selector = (0,
|
|
39114
|
-
referencedElement = (0,
|
|
39739
|
+
reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize($refBaseURI));
|
|
39740
|
+
const selector = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.uriToPointer)($refBaseURI);
|
|
39741
|
+
referencedElement = (0,_resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__.maybeRefractToSchemaElement)(
|
|
39115
39742
|
// @ts-ignore
|
|
39116
|
-
(0,
|
|
39743
|
+
(0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__["default"])(selector, reference.value.result));
|
|
39117
39744
|
}
|
|
39118
39745
|
} catch (error) {
|
|
39119
39746
|
/**
|
|
39120
39747
|
* No SchemaElement($id=URL) was not found, so we're going to try to resolve
|
|
39121
39748
|
* the URL and assume the returned response is a JSON Schema.
|
|
39122
39749
|
*/
|
|
39123
|
-
if (isURL && error instanceof
|
|
39124
|
-
if ((0,_selectors_$
|
|
39750
|
+
if (isURL && error instanceof _errors_EvaluationJsonSchemaUriError_mjs__WEBPACK_IMPORTED_MODULE_25__["default"]) {
|
|
39751
|
+
if ((0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_26__.isAnchor)((0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_26__.uriToAnchor)($refBaseURI))) {
|
|
39125
39752
|
// we're dealing with JSON Schema $anchor here
|
|
39126
|
-
reference = await this.toReference(
|
|
39753
|
+
reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize($refBaseURI));
|
|
39127
39754
|
retrievalURI = reference.uri;
|
|
39128
|
-
const selector = (0,_selectors_$
|
|
39129
|
-
referencedElement = (0,_selectors_$
|
|
39755
|
+
const selector = (0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_26__.uriToAnchor)($refBaseURI);
|
|
39756
|
+
referencedElement = (0,_selectors_$anchor_mjs__WEBPACK_IMPORTED_MODULE_26__.evaluate)(selector,
|
|
39130
39757
|
// @ts-ignore
|
|
39131
|
-
(0,
|
|
39758
|
+
(0,_resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__.maybeRefractToSchemaElement)(reference.value.result));
|
|
39132
39759
|
} else {
|
|
39133
39760
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
39134
|
-
reference = await this.toReference(
|
|
39761
|
+
reference = await this.toReference(_util_url_mjs__WEBPACK_IMPORTED_MODULE_6__.unsanitize($refBaseURI));
|
|
39135
39762
|
retrievalURI = reference.uri;
|
|
39136
|
-
const selector = (0,
|
|
39137
|
-
referencedElement = (0,
|
|
39763
|
+
const selector = (0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.uriToPointer)($refBaseURI);
|
|
39764
|
+
referencedElement = (0,_resolve_strategies_openapi_3_1_util_mjs__WEBPACK_IMPORTED_MODULE_22__.maybeRefractToSchemaElement)(
|
|
39138
39765
|
// @ts-ignore
|
|
39139
|
-
(0,
|
|
39766
|
+
(0,_swagger_api_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__["default"])(selector, reference.value.result));
|
|
39140
39767
|
}
|
|
39141
39768
|
} else {
|
|
39142
39769
|
throw error;
|
|
@@ -39145,12 +39772,12 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39145
39772
|
|
|
39146
39773
|
// detect direct or indirect reference
|
|
39147
39774
|
if (this.indirections.includes(referencedElement)) {
|
|
39148
|
-
throw new
|
|
39775
|
+
throw new _swagger_api_apidom_error__WEBPACK_IMPORTED_MODULE_16__["default"]('Recursive Schema Object reference detected');
|
|
39149
39776
|
}
|
|
39150
39777
|
|
|
39151
39778
|
// detect maximum depth of dereferencing
|
|
39152
39779
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
39153
|
-
throw new
|
|
39780
|
+
throw new _errors_MaximumDereferenceDepthError_mjs__WEBPACK_IMPORTED_MODULE_17__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`);
|
|
39154
39781
|
}
|
|
39155
39782
|
|
|
39156
39783
|
// append referencing schema to ancestors lineage
|
|
@@ -39165,8 +39792,8 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39165
39792
|
ancestors: ancestorsLineage
|
|
39166
39793
|
});
|
|
39167
39794
|
referencedElement = await visitAsync(referencedElement, visitor, {
|
|
39168
|
-
keyMap:
|
|
39169
|
-
nodeTypeGetter:
|
|
39795
|
+
keyMap: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.keyMap,
|
|
39796
|
+
nodeTypeGetter: _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__.getNodeType
|
|
39170
39797
|
});
|
|
39171
39798
|
|
|
39172
39799
|
// remove referencing schema from ancestors lineage
|
|
@@ -39174,46 +39801,50 @@ const OpenApi3_1DereferenceVisitor = stampit__WEBPACK_IMPORTED_MODULE_0__({
|
|
|
39174
39801
|
this.indirections.pop();
|
|
39175
39802
|
|
|
39176
39803
|
// Boolean JSON Schemas
|
|
39177
|
-
if ((0,
|
|
39178
|
-
const booleanJsonSchemaElement = (0,
|
|
39804
|
+
if ((0,_swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_11__.isBooleanJsonSchemaElement)(referencedElement)) {
|
|
39805
|
+
const booleanJsonSchemaElement = (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(referencedElement);
|
|
39179
39806
|
// annotate referenced element with info about original referencing element
|
|
39180
39807
|
booleanJsonSchemaElement.setMetaProperty('ref-fields', {
|
|
39181
|
-
$ref: (0,
|
|
39808
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)
|
|
39182
39809
|
});
|
|
39183
39810
|
// annotate referenced element with info about origin
|
|
39184
39811
|
booleanJsonSchemaElement.setMetaProperty('ref-origin', reference.uri);
|
|
39812
|
+
// annotate fragment with info about referencing element
|
|
39813
|
+
booleanJsonSchemaElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
39185
39814
|
return booleanJsonSchemaElement;
|
|
39186
39815
|
}
|
|
39187
39816
|
const mergeAndAnnotateReferencedElement = refedElement => {
|
|
39188
39817
|
// Schema Object - merge keywords from referenced schema with referencing schema
|
|
39189
|
-
const mergedElement = new
|
|
39818
|
+
const mergedElement = new _swagger_api_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.SchemaElement([...refedElement.content], (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(refedElement.meta), (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(refedElement.attributes));
|
|
39190
39819
|
// existing keywords from referencing schema overrides ones from referenced schema
|
|
39191
39820
|
referencingElement.forEach((value, keyElement, item) => {
|
|
39192
|
-
mergedElement.remove((0,
|
|
39821
|
+
mergedElement.remove((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(keyElement));
|
|
39193
39822
|
mergedElement.content.push(item);
|
|
39194
39823
|
});
|
|
39195
39824
|
mergedElement.remove('$ref');
|
|
39196
39825
|
// annotate referenced element with info about original referencing element
|
|
39197
39826
|
mergedElement.setMetaProperty('ref-fields', {
|
|
39198
|
-
$ref: (0,
|
|
39827
|
+
$ref: (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_4__["default"])(referencingElement.$ref)
|
|
39199
39828
|
});
|
|
39200
39829
|
// annotate fragment with info about origin
|
|
39201
39830
|
mergedElement.setMetaProperty('ref-origin', reference.uri);
|
|
39831
|
+
// annotate fragment with info about referencing element
|
|
39832
|
+
mergedElement.setMetaProperty('ref-referencing-element-id', (0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_19__.cloneDeep)(identityManager.identify(referencingElement)));
|
|
39202
39833
|
return mergedElement;
|
|
39203
39834
|
};
|
|
39204
39835
|
|
|
39205
39836
|
// attempting to create cycle
|
|
39206
|
-
if (ancestorsLineage.includes(referencedElement)) {
|
|
39207
|
-
|
|
39208
|
-
|
|
39837
|
+
if (ancestorsLineage.includes(referencingElement) || ancestorsLineage.includes(referencedElement)) {
|
|
39838
|
+
var _ancestorsLineage$fin3;
|
|
39839
|
+
const replaceWith = (_ancestorsLineage$fin3 = ancestorsLineage.findItem(wasReferencedBy(referencingElement))) !== null && _ancestorsLineage$fin3 !== void 0 ? _ancestorsLineage$fin3 : mergeAndAnnotateReferencedElement(referencedElement);
|
|
39840
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_10__.isMemberElement)(parent)) {
|
|
39841
|
+
parent.value = replaceWith; // eslint-disable-line no-param-reassign
|
|
39209
39842
|
} else if (Array.isArray(parent)) {
|
|
39210
|
-
parent[key] =
|
|
39843
|
+
parent[key] = replaceWith; // eslint-disable-line no-param-reassign
|
|
39211
39844
|
}
|
|
39212
39845
|
|
|
39213
39846
|
return false;
|
|
39214
39847
|
}
|
|
39215
|
-
|
|
39216
|
-
// transclude referencing element with merged referenced element
|
|
39217
39848
|
return mergeAndAnnotateReferencedElement(referencedElement);
|
|
39218
39849
|
}
|
|
39219
39850
|
}
|
|
@@ -39230,17 +39861,30 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
39230
39861
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
39231
39862
|
/* harmony export */ AncestorLineage: () => (/* binding */ AncestorLineage)
|
|
39232
39863
|
/* harmony export */ });
|
|
39864
|
+
/* harmony import */ var _swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28552);
|
|
39865
|
+
|
|
39866
|
+
|
|
39233
39867
|
// eslint-disable-next-line import/prefer-default-export
|
|
39234
39868
|
class AncestorLineage extends Array {
|
|
39235
39869
|
includesCycle(element) {
|
|
39236
39870
|
return this.filter(ancestors => ancestors.has(element)).length > 1;
|
|
39237
39871
|
}
|
|
39238
39872
|
includes(searchElement, fromIndex) {
|
|
39239
|
-
if (searchElement instanceof
|
|
39873
|
+
if (searchElement instanceof Set) {
|
|
39240
39874
|
return super.includes(searchElement, fromIndex);
|
|
39241
39875
|
}
|
|
39242
39876
|
return this.some(ancestors => ancestors.has(searchElement));
|
|
39243
39877
|
}
|
|
39878
|
+
findItem(predicate) {
|
|
39879
|
+
for (const set of this) {
|
|
39880
|
+
for (const item of set) {
|
|
39881
|
+
if ((0,_swagger_api_apidom_core__WEBPACK_IMPORTED_MODULE_0__.isElement)(item) && predicate(item)) {
|
|
39882
|
+
return item;
|
|
39883
|
+
}
|
|
39884
|
+
}
|
|
39885
|
+
}
|
|
39886
|
+
return undefined;
|
|
39887
|
+
}
|
|
39244
39888
|
}
|
|
39245
39889
|
|
|
39246
39890
|
/***/ }),
|