@speclynx/apidom-reference 5.2.4 → 5.2.6
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/CHANGELOG.md +19 -0
- package/README.md +37 -14
- package/dist/apidom-reference.browser.js +1234 -596
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +29 -29
- package/src/bundle/strategies/arazzo-1/visitor.cjs +105 -22
- package/src/bundle/strategies/arazzo-1/visitor.mjs +107 -24
- package/src/bundle/strategies/openapi-3-1/visitor.cjs +197 -47
- package/src/bundle/strategies/openapi-3-1/visitor.mjs +200 -50
- package/src/bundle/util.cjs +57 -2
- package/src/bundle/util.mjs +52 -0
- package/src/dereference/strategies/arazzo-1/index.cjs +20 -17
- package/src/dereference/strategies/arazzo-1/index.mjs +14 -11
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.cjs +6 -0
- package/src/dereference/strategies/arazzo-1/selectors/$anchor.mjs +1 -1
- package/src/dereference/strategies/arazzo-1/selectors/uri.cjs +6 -0
- package/src/dereference/strategies/arazzo-1/selectors/uri.mjs +1 -1
- package/src/dereference/strategies/arazzo-1/source-descriptions.cjs +65 -42
- package/src/dereference/strategies/arazzo-1/source-descriptions.mjs +64 -42
- package/src/dereference/strategies/arazzo-1/util.cjs +6 -0
- package/src/dereference/strategies/arazzo-1/util.mjs +1 -1
- package/src/dereference/strategies/arazzo-1/visitor.cjs +97 -35
- package/src/dereference/strategies/arazzo-1/visitor.mjs +101 -39
- package/src/dereference/strategies/openapi-3-1/index.cjs +2 -1
- package/src/dereference/strategies/openapi-3-1/index.mjs +3 -1
- package/src/dereference/strategies/openapi-3-1/selectors/$anchor.cjs +16 -4
- package/src/dereference/strategies/openapi-3-1/selectors/$anchor.mjs +14 -3
- package/src/dereference/strategies/openapi-3-1/selectors/json-pointer.cjs +29 -0
- package/src/dereference/strategies/openapi-3-1/selectors/json-pointer.mjs +22 -0
- package/src/dereference/strategies/openapi-3-1/selectors/uri.cjs +54 -27
- package/src/dereference/strategies/openapi-3-1/selectors/uri.mjs +51 -27
- package/src/dereference/strategies/openapi-3-1/util.cjs +75 -14
- package/src/dereference/strategies/openapi-3-1/util.mjs +68 -14
- package/src/dereference/strategies/openapi-3-1/visitor.cjs +85 -9
- package/src/dereference/strategies/openapi-3-1/visitor.mjs +89 -13
- package/src/util/url.cjs +35 -2
- package/src/util/url.mjs +32 -0
- package/types/apidom-reference.d.ts +12 -0
- package/types/bundle/strategies/arazzo-1/index.d.ts +1 -1
- package/types/bundle/strategies/arazzo-1/visitor.d.ts +51 -6
- package/types/bundle/strategies/openapi-3-1/index.d.ts +1 -1
- package/types/bundle/strategies/openapi-3-1/visitor.d.ts +59 -3
- package/types/bundle/util.d.ts +39 -0
- package/types/dereference/strategies/arazzo-1/selectors/$anchor.d.ts +1 -1
- package/types/dereference/strategies/arazzo-1/selectors/uri.d.ts +1 -1
- package/types/dereference/strategies/arazzo-1/util.d.ts +1 -1
- package/types/dereference/strategies/arazzo-1/visitor.d.ts +17 -1
- package/types/dereference/strategies/openapi-3-1/selectors/$anchor.d.ts +8 -0
- package/types/dereference/strategies/openapi-3-1/selectors/json-pointer.d.ts +9 -0
- package/types/dereference/strategies/openapi-3-1/selectors/uri.d.ts +37 -4
- package/types/dereference/strategies/openapi-3-1/util.d.ts +53 -2
- package/types/dereference/strategies/openapi-3-1/visitor.d.ts +17 -1
- package/types/util/url.d.ts +10 -0
|
@@ -456,6 +456,12 @@ const cf = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_4__.fixedFields)(_s
|
|
|
456
456
|
indexed: true
|
|
457
457
|
});
|
|
458
458
|
|
|
459
|
+
/**
|
|
460
|
+
* A bundled JSON Schema resource awaiting placement into the entry document's
|
|
461
|
+
* `components.inputs`.
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
|
|
459
465
|
/**
|
|
460
466
|
* @public
|
|
461
467
|
*/
|
|
@@ -503,17 +509,47 @@ class Arazzo1BundleVisitor {
|
|
|
503
509
|
* components that are still being bundled.
|
|
504
510
|
*/
|
|
505
511
|
reservedNames;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Embedded resources waiting to be placed into the entry document's
|
|
515
|
+
* `components.inputs`, shared across the entry document and every external
|
|
516
|
+
* document visitor. Placement is deferred until the entry document traversal
|
|
517
|
+
* completes: the traversal walks live content, so placing a resource mid-way
|
|
518
|
+
* would make it descend into the resource and re-bundle its `$ref`s against
|
|
519
|
+
* the entry document's base URI instead of the resource's own.
|
|
520
|
+
*/
|
|
521
|
+
placements;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Index of `$id`-bearing schemas per document, shared across the entry document
|
|
525
|
+
* and every external document visitor of a single bundle run so it never
|
|
526
|
+
* outlives mutations of the documents (e.g. the final placement of inputs).
|
|
527
|
+
*/
|
|
528
|
+
schema$idIndex;
|
|
506
529
|
constructor({
|
|
507
530
|
reference,
|
|
508
531
|
options,
|
|
509
532
|
assignments = new Map(),
|
|
510
|
-
reservedNames = new Map()
|
|
533
|
+
reservedNames = new Map(),
|
|
534
|
+
placements = [],
|
|
535
|
+
schema$idIndex = new WeakMap()
|
|
511
536
|
}) {
|
|
512
537
|
this.reference = reference;
|
|
513
538
|
this.baseURI = (0,_dereference_strategies_arazzo_1_util_ts__WEBPACK_IMPORTED_MODULE_23__.resolveArazzo$selfField)(reference.uri, reference.value?.result);
|
|
514
539
|
this.options = options;
|
|
515
540
|
this.assignments = assignments;
|
|
516
541
|
this.reservedNames = reservedNames;
|
|
542
|
+
this.placements = placements;
|
|
543
|
+
this.schema$idIndex = schema$idIndex;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Base URI of the entry document — its `$self` when present, otherwise its
|
|
548
|
+
* retrieval URI. It is the base against which a relative `$id` written into
|
|
549
|
+
* `components.inputs` resolves.
|
|
550
|
+
*/
|
|
551
|
+
get entryBaseURI() {
|
|
552
|
+
return (0,_dereference_strategies_arazzo_1_util_ts__WEBPACK_IMPORTED_MODULE_23__.resolveArazzo$selfField)(_util_url_ts__WEBPACK_IMPORTED_MODULE_17__.stripHash(this.reference.refSet.rootRef.uri), this.entryResult);
|
|
517
553
|
}
|
|
518
554
|
toBaseURI(uri) {
|
|
519
555
|
return _util_url_ts__WEBPACK_IMPORTED_MODULE_17__.resolve(this.baseURI, _util_url_ts__WEBPACK_IMPORTED_MODULE_17__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_17__.stripHash(uri)));
|
|
@@ -665,14 +701,17 @@ class Arazzo1BundleVisitor {
|
|
|
665
701
|
|
|
666
702
|
/**
|
|
667
703
|
* Computes a collision-free component name within `components.inputs`. A name
|
|
668
|
-
* is taken if it's already
|
|
669
|
-
* still being bundled (reserved before recursion).
|
|
704
|
+
* is taken if it's already present in the entry document's inputs or reserved
|
|
705
|
+
* by a component that is still being bundled (reserved before recursion).
|
|
670
706
|
*/
|
|
671
707
|
uniqueName(candidate) {
|
|
672
708
|
const field = cf.inputs.name;
|
|
673
|
-
const
|
|
709
|
+
const {
|
|
710
|
+
components
|
|
711
|
+
} = this.entryResult;
|
|
712
|
+
const inputs = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isObjectElement)(components) ? components.get(field) : undefined;
|
|
674
713
|
const reserved = this.reservedNames.get(field) ?? new Set();
|
|
675
|
-
return (0,_util_ts__WEBPACK_IMPORTED_MODULE_25__.uniqueName)(candidate, name => inputs.hasKey(name) || reserved.has(name));
|
|
714
|
+
return (0,_util_ts__WEBPACK_IMPORTED_MODULE_25__.uniqueName)(candidate, name => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isObjectElement)(inputs) && inputs.hasKey(name) || reserved.has(name));
|
|
676
715
|
}
|
|
677
716
|
|
|
678
717
|
/**
|
|
@@ -697,14 +736,36 @@ class Arazzo1BundleVisitor {
|
|
|
697
736
|
this.entryParseResult.content.push(annotation);
|
|
698
737
|
}
|
|
699
738
|
|
|
739
|
+
/**
|
|
740
|
+
* The entry document traversal is rooted at its Parse Result (nested
|
|
741
|
+
* traversals are rooted at schema resources), so leaving it marks the moment
|
|
742
|
+
* the whole entry document has been visited and the collected resources can
|
|
743
|
+
* be placed into `components.inputs` without the traversal descending into them.
|
|
744
|
+
* Guarded on the node so that a traversal rooted at any other Parse Result
|
|
745
|
+
* never flushes the shared placements early.
|
|
746
|
+
*/
|
|
747
|
+
ParseResultElement = {
|
|
748
|
+
leave: path => {
|
|
749
|
+
if (path.node !== this.entryParseResult) return;
|
|
750
|
+
for (const {
|
|
751
|
+
name,
|
|
752
|
+
element
|
|
753
|
+
} of this.placements) {
|
|
754
|
+
this.ensureInputsField().set(name, element);
|
|
755
|
+
}
|
|
756
|
+
this.placements.length = 0;
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
|
|
700
760
|
/**
|
|
701
761
|
* JSON Schema Objects in Arazzo (used by Input Objects and inline schemas) are
|
|
702
762
|
* a JSON Schema 2020-12 dialect — the only external reference type Arazzo
|
|
703
763
|
* defines. They are bundled per the JSON Schema Compound Document rules: the
|
|
704
764
|
* external schema RESOURCE is embedded verbatim into `components.inputs`
|
|
705
|
-
* (carrying its `$id`), and the referencing `$ref` is
|
|
706
|
-
*
|
|
707
|
-
*
|
|
765
|
+
* (carrying its `$id`), and the referencing `$ref` is rebased onto that `$id`
|
|
766
|
+
* when it resolves to a different URI (a location-based `$ref` to a
|
|
767
|
+
* self-identifying resource); otherwise it is left unchanged. This mirrors
|
|
768
|
+
* the openapi-3-1 strategy's Schema Object handling.
|
|
708
769
|
*/
|
|
709
770
|
async JSONSchemaElement(path) {
|
|
710
771
|
const referencingElement = path.node;
|
|
@@ -719,7 +780,8 @@ class Arazzo1BundleVisitor {
|
|
|
719
780
|
// current document's base URI is derived directly (not via toReference)
|
|
720
781
|
// so an internal $ref needs no resolution and never trips the
|
|
721
782
|
// resolve.maxDepth guard.
|
|
722
|
-
const
|
|
783
|
+
const schemaBaseURI = (0,_dereference_strategies_arazzo_1_util_ts__WEBPACK_IMPORTED_MODULE_24__.resolveSchemaBaseURI)(this.baseURI, path);
|
|
784
|
+
const $refBaseURI = (0,_dereference_strategies_arazzo_1_util_ts__WEBPACK_IMPORTED_MODULE_24__.resolveSchema$refField)(schemaBaseURI, referencingElement);
|
|
723
785
|
const $refBaseURIStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_17__.stripHash($refBaseURI);
|
|
724
786
|
const file = new _File_ts__WEBPACK_IMPORTED_MODULE_20__["default"]({
|
|
725
787
|
uri: $refBaseURIStrippedHash
|
|
@@ -757,7 +819,10 @@ class Arazzo1BundleVisitor {
|
|
|
757
819
|
let schemaReference = this.reference;
|
|
758
820
|
try {
|
|
759
821
|
const referenceAsSchema = (0,_dereference_strategies_arazzo_1_util_ts__WEBPACK_IMPORTED_MODULE_23__.maybeRefractToJSONSchemaElement)(schemaReference.value.result);
|
|
760
|
-
(0,_dereference_strategies_arazzo_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_22__.evaluate)($refBaseURI, referenceAsSchema
|
|
822
|
+
(0,_dereference_strategies_arazzo_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_22__.evaluate)($refBaseURI, referenceAsSchema, {
|
|
823
|
+
baseURI: this.baseURI,
|
|
824
|
+
index: this.schema$idIndex
|
|
825
|
+
});
|
|
761
826
|
} catch (error) {
|
|
762
827
|
if (isURL && error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_16__["default"]) {
|
|
763
828
|
if ((0,_dereference_strategies_arazzo_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_21__.isAnchor)((0,_dereference_strategies_arazzo_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_21__.uriToAnchor)($refBaseURI))) {
|
|
@@ -796,20 +861,23 @@ class Arazzo1BundleVisitor {
|
|
|
796
861
|
const field = cf.inputs.name;
|
|
797
862
|
const canonicalKey = `${field}\t${resourceBaseURI}`;
|
|
798
863
|
|
|
799
|
-
//
|
|
800
|
-
// $
|
|
864
|
+
// a location-based $ref to a self-identifying resource is rebased onto the
|
|
865
|
+
// resource's $id (keeping its fragment) — once embedded, the resource is
|
|
866
|
+
// reachable only by its $id. A $ref already resolving to that $id is left
|
|
867
|
+
// as written. See rebaseSchema$ref for the spec trade-off.
|
|
868
|
+
const rebased$ref = (0,_util_ts__WEBPACK_IMPORTED_MODULE_25__.rebaseSchema$ref)($refBaseURI, resourceBaseURI);
|
|
869
|
+
|
|
870
|
+
// resource already embedded (or being embedded) — point the referencing
|
|
871
|
+
// $ref at it and stop. This also terminates circular external schema
|
|
801
872
|
// references, since the assignment is reserved BEFORE recursion.
|
|
802
873
|
if (this.assignments.has(canonicalKey)) {
|
|
874
|
+
if (rebased$ref !== undefined) referencingElement.set('$ref', rebased$ref);
|
|
803
875
|
path.skip();
|
|
804
876
|
return;
|
|
805
877
|
}
|
|
806
878
|
|
|
807
|
-
// own a copy of the resource
|
|
808
|
-
// $ref still resolves against it once embedded
|
|
879
|
+
// own a copy of the resource
|
|
809
880
|
const embeddedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.cloneDeep)(resourceRoot);
|
|
810
|
-
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isStringElement)(embeddedElement.$id)) {
|
|
811
|
-
embeddedElement.set('$id', resourceBaseURI);
|
|
812
|
-
}
|
|
813
881
|
|
|
814
882
|
// the embedded thing is the WHOLE resource (keyed by its $id), so its name
|
|
815
883
|
// is derived from the resource URI
|
|
@@ -829,22 +897,37 @@ class Arazzo1BundleVisitor {
|
|
|
829
897
|
reference: schemaReference,
|
|
830
898
|
options: this.options,
|
|
831
899
|
assignments: this.assignments,
|
|
832
|
-
reservedNames: this.reservedNames
|
|
900
|
+
reservedNames: this.reservedNames,
|
|
901
|
+
placements: this.placements,
|
|
902
|
+
schema$idIndex: this.schema$idIndex
|
|
833
903
|
});
|
|
834
904
|
const bundledElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_7__.traverseAsync)(embeddedElement, visitor, {
|
|
835
905
|
mutable: true
|
|
836
906
|
});
|
|
837
907
|
|
|
908
|
+
// a resource without its own $id is identified by its retrieval URI; write
|
|
909
|
+
// it relative to the entry document (the base of components.inputs) so the
|
|
910
|
+
// bundle carries no absolute filesystem path and stays relocatable. Assigned
|
|
911
|
+
// after the nested traversal so a reader deriving a schema's base from live
|
|
912
|
+
// $ids (see #540) never resolves the resource's own $refs against the entry
|
|
913
|
+
// document.
|
|
914
|
+
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isStringElement)(bundledElement.$id)) {
|
|
915
|
+
bundledElement.set('$id', _util_url_ts__WEBPACK_IMPORTED_MODULE_17__.relative(this.entryBaseURI, resourceBaseURI));
|
|
916
|
+
}
|
|
917
|
+
|
|
838
918
|
// annotate the embedded resource with info about its origin
|
|
839
919
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isElement)(bundledElement)) {
|
|
840
920
|
bundledElement.meta.set('ref-origin', schemaReference.uri);
|
|
841
921
|
}
|
|
842
922
|
|
|
843
|
-
//
|
|
844
|
-
this.
|
|
923
|
+
// queue the embedded resource for placement into the entry document's components.inputs
|
|
924
|
+
this.placements.push({
|
|
925
|
+
name: componentName,
|
|
926
|
+
element: bundledElement
|
|
927
|
+
});
|
|
845
928
|
|
|
846
|
-
// the referencing $ref
|
|
847
|
-
|
|
929
|
+
// point the referencing $ref at the embedded resource's $id
|
|
930
|
+
if (rebased$ref !== undefined) referencingElement.set('$ref', rebased$ref);
|
|
848
931
|
path.skip();
|
|
849
932
|
} catch (error) {
|
|
850
933
|
this.handleError(`Error while bundling JSON Schema Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
@@ -3164,43 +3247,44 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3164
3247
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(87009);
|
|
3165
3248
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6352);
|
|
3166
3249
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(25162);
|
|
3167
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
3168
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
3169
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
3170
|
-
/* harmony import */ var
|
|
3171
|
-
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
|
|
3172
|
-
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
3173
|
-
/* harmony import */ var
|
|
3174
|
-
/* harmony import */ var
|
|
3175
|
-
/* harmony import */ var
|
|
3176
|
-
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
3177
|
-
/* harmony import */ var
|
|
3178
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(
|
|
3179
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(
|
|
3180
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(
|
|
3181
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(
|
|
3182
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(
|
|
3183
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(
|
|
3184
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(
|
|
3185
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(
|
|
3186
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(
|
|
3187
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(
|
|
3188
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(
|
|
3189
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(
|
|
3190
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(
|
|
3191
|
-
/* harmony import */ var
|
|
3192
|
-
/* harmony import */ var
|
|
3193
|
-
/* harmony import */ var
|
|
3194
|
-
/* harmony import */ var
|
|
3195
|
-
/* harmony import */ var
|
|
3196
|
-
/* harmony import */ var
|
|
3197
|
-
/* harmony import */ var
|
|
3198
|
-
/* harmony import */ var
|
|
3199
|
-
/* harmony import */ var
|
|
3200
|
-
/* harmony import */ var
|
|
3201
|
-
/* harmony import */ var
|
|
3202
|
-
/* harmony import */ var
|
|
3203
|
-
/* harmony import */ var
|
|
3250
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(96911);
|
|
3251
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12111);
|
|
3252
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(97071);
|
|
3253
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(84660);
|
|
3254
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(37205);
|
|
3255
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(44673);
|
|
3256
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(16280);
|
|
3257
|
+
/* harmony import */ var _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(44641);
|
|
3258
|
+
/* harmony import */ var _speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(80796);
|
|
3259
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(12020);
|
|
3260
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(61198);
|
|
3261
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(21314);
|
|
3262
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(24329);
|
|
3263
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(29881);
|
|
3264
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(76332);
|
|
3265
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(23806);
|
|
3266
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(52645);
|
|
3267
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(23031);
|
|
3268
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(63842);
|
|
3269
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(87455);
|
|
3270
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(16363);
|
|
3271
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(55122);
|
|
3272
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(71117);
|
|
3273
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(72257);
|
|
3274
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(69511);
|
|
3275
|
+
/* harmony import */ var _errors_BundleError_ts__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(81002);
|
|
3276
|
+
/* harmony import */ var _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(8853);
|
|
3277
|
+
/* harmony import */ var _errors_MaximumBundleDepthError_ts__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(16843);
|
|
3278
|
+
/* harmony import */ var _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(51325);
|
|
3279
|
+
/* harmony import */ var _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(44477);
|
|
3280
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(30658);
|
|
3281
|
+
/* harmony import */ var _parse_index_ts__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(35014);
|
|
3282
|
+
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(98979);
|
|
3283
|
+
/* harmony import */ var _File_ts__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(10682);
|
|
3284
|
+
/* harmony import */ var _dereference_strategies_openapi_3_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(32054);
|
|
3285
|
+
/* harmony import */ var _dereference_strategies_openapi_3_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(56481);
|
|
3286
|
+
/* harmony import */ var _dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(60888);
|
|
3287
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(25939);
|
|
3204
3288
|
|
|
3205
3289
|
|
|
3206
3290
|
|
|
@@ -3227,7 +3311,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3227
3311
|
* Field names are sourced from the Components Object fixed fields so they
|
|
3228
3312
|
* cannot drift from the namespace definition.
|
|
3229
3313
|
*/
|
|
3230
|
-
const cf = (0,
|
|
3314
|
+
const cf = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__.fixedFields)(_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.ComponentsElement, {
|
|
3231
3315
|
indexed: true
|
|
3232
3316
|
});
|
|
3233
3317
|
const componentFieldByReferencedElement = {
|
|
@@ -3250,18 +3334,24 @@ const componentFieldByReferencedElement = {
|
|
|
3250
3334
|
* object.
|
|
3251
3335
|
*/
|
|
3252
3336
|
const componentFieldElementByField = {
|
|
3253
|
-
[cf.schemas.name]:
|
|
3254
|
-
[cf.responses.name]:
|
|
3255
|
-
[cf.parameters.name]:
|
|
3256
|
-
[cf.examples.name]:
|
|
3257
|
-
[cf.requestBodies.name]:
|
|
3258
|
-
[cf.headers.name]:
|
|
3259
|
-
[cf.securitySchemes.name]:
|
|
3260
|
-
[cf.links.name]:
|
|
3261
|
-
[cf.callbacks.name]:
|
|
3262
|
-
[cf.pathItems.name]:
|
|
3337
|
+
[cf.schemas.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_26__["default"],
|
|
3338
|
+
[cf.responses.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_25__["default"],
|
|
3339
|
+
[cf.parameters.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_22__["default"],
|
|
3340
|
+
[cf.examples.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_18__["default"],
|
|
3341
|
+
[cf.requestBodies.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_24__["default"],
|
|
3342
|
+
[cf.headers.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_20__["default"],
|
|
3343
|
+
[cf.securitySchemes.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_27__["default"],
|
|
3344
|
+
[cf.links.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_21__["default"],
|
|
3345
|
+
[cf.callbacks.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__["default"],
|
|
3346
|
+
[cf.pathItems.name]: _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_23__["default"]
|
|
3263
3347
|
};
|
|
3264
3348
|
|
|
3349
|
+
/**
|
|
3350
|
+
* A bundled element awaiting placement into the entry document's Components
|
|
3351
|
+
* Object field.
|
|
3352
|
+
* @public
|
|
3353
|
+
*/
|
|
3354
|
+
|
|
3265
3355
|
/**
|
|
3266
3356
|
* @public
|
|
3267
3357
|
*/
|
|
@@ -3279,7 +3369,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3279
3369
|
* Derived from the shared refSet's root reference.
|
|
3280
3370
|
*/
|
|
3281
3371
|
get entryURI() {
|
|
3282
|
-
return
|
|
3372
|
+
return _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(this.reference.refSet?.rootRef?.uri ?? '');
|
|
3283
3373
|
}
|
|
3284
3374
|
|
|
3285
3375
|
/**
|
|
@@ -3319,18 +3409,50 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3319
3409
|
* generic object referenced once as a Parameter and once as a Response).
|
|
3320
3410
|
*/
|
|
3321
3411
|
refractCache;
|
|
3412
|
+
|
|
3413
|
+
/**
|
|
3414
|
+
* Index of `$id`-bearing schemas per document, shared across the entry document
|
|
3415
|
+
* and every external document visitor of a single bundle run so it never
|
|
3416
|
+
* outlives mutations of the documents (e.g. the final placement of components).
|
|
3417
|
+
*/
|
|
3418
|
+
schema$idIndex;
|
|
3419
|
+
|
|
3420
|
+
/**
|
|
3421
|
+
* Bundled fragments waiting to be placed into the entry document's
|
|
3422
|
+
* Components Object, shared across the entry document and every external
|
|
3423
|
+
* document visitor. Placement is deferred until the entry document traversal
|
|
3424
|
+
* completes: the traversal walks live content, so placing a fragment mid-way
|
|
3425
|
+
* would make it descend into the fragment and re-bundle its `$ref`s against
|
|
3426
|
+
* the entry document's base URI instead of the fragment's own.
|
|
3427
|
+
*/
|
|
3428
|
+
placements;
|
|
3429
|
+
|
|
3430
|
+
/**
|
|
3431
|
+
* The base URI the traversed content will have once placed into the entry
|
|
3432
|
+
* document, when placement changes it: content hoisted out of a non-schema
|
|
3433
|
+
* document (a Response, Parameter, Path Item, ...) trades that document's
|
|
3434
|
+
* base URI for the entry document's. Unset for the entry document itself and
|
|
3435
|
+
* for embedded schema resources, whose `$id` carries their base along.
|
|
3436
|
+
*/
|
|
3437
|
+
relocationBaseURI;
|
|
3322
3438
|
constructor({
|
|
3323
3439
|
reference,
|
|
3324
3440
|
options,
|
|
3325
3441
|
assignments = new Map(),
|
|
3326
3442
|
reservedNames = new Map(),
|
|
3327
|
-
refractCache = new WeakMap()
|
|
3443
|
+
refractCache = new WeakMap(),
|
|
3444
|
+
schema$idIndex = new WeakMap(),
|
|
3445
|
+
placements = [],
|
|
3446
|
+
relocationBaseURI
|
|
3328
3447
|
}) {
|
|
3329
3448
|
this.reference = reference;
|
|
3330
3449
|
this.options = options;
|
|
3331
3450
|
this.assignments = assignments;
|
|
3332
3451
|
this.reservedNames = reservedNames;
|
|
3333
3452
|
this.refractCache = refractCache;
|
|
3453
|
+
this.schema$idIndex = schema$idIndex;
|
|
3454
|
+
this.placements = placements;
|
|
3455
|
+
this.relocationBaseURI = relocationBaseURI;
|
|
3334
3456
|
}
|
|
3335
3457
|
getRefracted(source, type) {
|
|
3336
3458
|
return this.refractCache.get(source)?.get(type);
|
|
@@ -3344,12 +3466,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3344
3466
|
byType.set(type, refracted);
|
|
3345
3467
|
}
|
|
3346
3468
|
toBaseURI(uri) {
|
|
3347
|
-
return
|
|
3469
|
+
return _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.resolve(this.reference.uri, _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(uri)));
|
|
3348
3470
|
}
|
|
3349
3471
|
async toReference(uri) {
|
|
3350
3472
|
// detect maximum depth of resolution
|
|
3351
3473
|
if (this.reference.depth >= this.options.resolve.maxDepth) {
|
|
3352
|
-
throw new
|
|
3474
|
+
throw new _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_31__["default"](`Maximum resolution depth of ${this.options.resolve.maxDepth} has been exceeded by file "${this.reference.uri}"`, {
|
|
3353
3475
|
maxDepth: this.options.resolve.maxDepth,
|
|
3354
3476
|
uri: this.reference.uri
|
|
3355
3477
|
});
|
|
@@ -3363,14 +3485,14 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3363
3485
|
if (refSet.has(baseURI)) {
|
|
3364
3486
|
return refSet.find((0,ramda__WEBPACK_IMPORTED_MODULE_1__["default"])(baseURI, 'uri'));
|
|
3365
3487
|
}
|
|
3366
|
-
const parseResult = await (0,
|
|
3488
|
+
const parseResult = await (0,_parse_index_ts__WEBPACK_IMPORTED_MODULE_34__["default"])(_util_url_ts__WEBPACK_IMPORTED_MODULE_33__.unsanitize(baseURI), {
|
|
3367
3489
|
...this.options,
|
|
3368
3490
|
parse: {
|
|
3369
3491
|
...this.options.parse,
|
|
3370
3492
|
mediaType: 'text/plain'
|
|
3371
3493
|
}
|
|
3372
3494
|
});
|
|
3373
|
-
const reference = new
|
|
3495
|
+
const reference = new _Reference_ts__WEBPACK_IMPORTED_MODULE_35__["default"]({
|
|
3374
3496
|
uri: baseURI,
|
|
3375
3497
|
value: parseResult,
|
|
3376
3498
|
depth: this.reference.depth + 1
|
|
@@ -3385,7 +3507,23 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3385
3507
|
* transferable. Bare fragments are returned unchanged.
|
|
3386
3508
|
*/
|
|
3387
3509
|
normalizeSelfReference(ref) {
|
|
3388
|
-
return ref.startsWith('#') ? ref :
|
|
3510
|
+
return ref.startsWith('#') ? ref : _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.getHash(ref);
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
/**
|
|
3514
|
+
* The base URI the given Schema Object's `$ref` will be resolved against once
|
|
3515
|
+
* the content is placed into the entry document, or `undefined` when the
|
|
3516
|
+
* `$ref` as written resolves to `$refBaseURI` from there as well: the content
|
|
3517
|
+
* isn't relocated, an absolute `$id` on the schema's ancestor chain pins its
|
|
3518
|
+
* base, or the hoisted document sits next to the entry document.
|
|
3519
|
+
*/
|
|
3520
|
+
relocatedSchemaBaseURI(path, $refBaseURI) {
|
|
3521
|
+
if (this.relocationBaseURI === undefined) return undefined;
|
|
3522
|
+
const relocatedBaseURI = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.resolveSchemaBaseURI)(this.relocationBaseURI, path);
|
|
3523
|
+
if ((0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.resolveSchema$refField)(relocatedBaseURI, path.node) === $refBaseURI) {
|
|
3524
|
+
return undefined;
|
|
3525
|
+
}
|
|
3526
|
+
return relocatedBaseURI;
|
|
3389
3527
|
}
|
|
3390
3528
|
|
|
3391
3529
|
/**
|
|
@@ -3404,16 +3542,16 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3404
3542
|
// breach (MaximumBundleDepthError, which also extends BundleError) is a
|
|
3405
3543
|
// resolution failure and flows through below — wrapped and subject to
|
|
3406
3544
|
// continueOnError, like dereferencing.
|
|
3407
|
-
if (error instanceof
|
|
3545
|
+
if (error instanceof _errors_BundleError_ts__WEBPACK_IMPORTED_MODULE_28__["default"] && !(error instanceof _errors_MaximumBundleDepthError_ts__WEBPACK_IMPORTED_MODULE_30__["default"])) {
|
|
3408
3546
|
throw error;
|
|
3409
3547
|
}
|
|
3410
3548
|
const {
|
|
3411
3549
|
continueOnError
|
|
3412
3550
|
} = this.options.bundle;
|
|
3413
|
-
const isEntryDocument =
|
|
3551
|
+
const isEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(this.reference.refSet?.rootRef?.uri ?? '') === this.reference.uri;
|
|
3414
3552
|
const uri = this.reference.uri;
|
|
3415
3553
|
const type = referencingElement.element;
|
|
3416
|
-
const codeFrame = (0,
|
|
3554
|
+
const codeFrame = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement);
|
|
3417
3555
|
const location = visitorPath.formatPath();
|
|
3418
3556
|
const hop = {
|
|
3419
3557
|
uri,
|
|
@@ -3424,12 +3562,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3424
3562
|
codeFrame
|
|
3425
3563
|
};
|
|
3426
3564
|
let unresolvedError;
|
|
3427
|
-
if (error instanceof
|
|
3565
|
+
if (error instanceof _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_29__["default"]) {
|
|
3428
3566
|
// @ts-ignore
|
|
3429
3567
|
error.trace = [hop, ...error.trace];
|
|
3430
3568
|
unresolvedError = error;
|
|
3431
3569
|
} else {
|
|
3432
|
-
unresolvedError = new
|
|
3570
|
+
unresolvedError = new _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_29__["default"](message, {
|
|
3433
3571
|
cause: error,
|
|
3434
3572
|
type,
|
|
3435
3573
|
uri,
|
|
@@ -3452,12 +3590,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3452
3590
|
const entryResult = this.entryResult;
|
|
3453
3591
|
let components = entryResult.components;
|
|
3454
3592
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(components)) {
|
|
3455
|
-
components = new
|
|
3593
|
+
components = new _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_19__.ComponentsElement();
|
|
3456
3594
|
entryResult.components = components;
|
|
3457
3595
|
}
|
|
3458
3596
|
let fieldElement = components.get(field);
|
|
3459
3597
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(fieldElement)) {
|
|
3460
|
-
const FieldElement = componentFieldElementByField[field] ??
|
|
3598
|
+
const FieldElement = componentFieldElementByField[field] ?? _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__["default"];
|
|
3461
3599
|
fieldElement = new FieldElement();
|
|
3462
3600
|
components.set(field, fieldElement);
|
|
3463
3601
|
}
|
|
@@ -3469,9 +3607,9 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3469
3607
|
* falling back to the referenced file's basename.
|
|
3470
3608
|
*/
|
|
3471
3609
|
basenameOf(jsonPointer, baseURI) {
|
|
3472
|
-
const tokens = (0,
|
|
3610
|
+
const tokens = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.parse)(jsonPointer).tree;
|
|
3473
3611
|
const lastToken = tokens.length > 0 ? tokens[tokens.length - 1] : '';
|
|
3474
|
-
return lastToken ||
|
|
3612
|
+
return lastToken || _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.getBasename(baseURI) || 'Schema';
|
|
3475
3613
|
}
|
|
3476
3614
|
|
|
3477
3615
|
/**
|
|
@@ -3494,9 +3632,9 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3494
3632
|
return this.basenameOf(jsonPointer, baseURI);
|
|
3495
3633
|
}
|
|
3496
3634
|
if (componentNamesStrategy === 'title') {
|
|
3497
|
-
const title = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(element) ? (0,
|
|
3635
|
+
const title = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(element) ? (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(element.get('title')) : undefined;
|
|
3498
3636
|
if (typeof title === 'string' && title.trim() !== '') {
|
|
3499
|
-
const name = (0,
|
|
3637
|
+
const name = (0,_util_ts__WEBPACK_IMPORTED_MODULE_40__.sanitizeComponentName)((0,_util_ts__WEBPACK_IMPORTED_MODULE_40__.toPascalCase)(title));
|
|
3500
3638
|
if (name !== '') return name;
|
|
3501
3639
|
}
|
|
3502
3640
|
// fall back to basename when no usable title is present
|
|
@@ -3506,13 +3644,16 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3506
3644
|
|
|
3507
3645
|
/**
|
|
3508
3646
|
* Computes a collision-free component name within the target field. A name is
|
|
3509
|
-
* taken if it's already
|
|
3510
|
-
* is still being bundled (reserved before recursion).
|
|
3647
|
+
* taken if it's already present in the entry document's components or reserved
|
|
3648
|
+
* by a component that is still being bundled (reserved before recursion).
|
|
3511
3649
|
*/
|
|
3512
3650
|
uniqueName(candidate, field) {
|
|
3513
|
-
const
|
|
3651
|
+
const {
|
|
3652
|
+
components
|
|
3653
|
+
} = this.entryResult;
|
|
3654
|
+
const fieldElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(components) ? components.get(field) : undefined;
|
|
3514
3655
|
const reserved = this.reservedNames.get(field) ?? new Set();
|
|
3515
|
-
return (0,
|
|
3656
|
+
return (0,_util_ts__WEBPACK_IMPORTED_MODULE_40__.uniqueName)(candidate, name => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isObjectElement)(fieldElement) && fieldElement.hasKey(name) || reserved.has(name));
|
|
3516
3657
|
}
|
|
3517
3658
|
|
|
3518
3659
|
/**
|
|
@@ -3528,17 +3669,39 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3528
3669
|
}
|
|
3529
3670
|
const message = `Component "${preferredName}" in components/${field} is referenced with the same name but different content. Renamed to "${componentName}".`;
|
|
3530
3671
|
if (onComponentNameCollision === 'error') {
|
|
3531
|
-
throw new
|
|
3672
|
+
throw new _errors_BundleError_ts__WEBPACK_IMPORTED_MODULE_28__["default"](message);
|
|
3532
3673
|
}
|
|
3533
|
-
const annotation = new
|
|
3674
|
+
const annotation = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__["default"](message);
|
|
3534
3675
|
annotation.classes.push('warning');
|
|
3535
3676
|
annotation.code = 'bundle-component-name-collision';
|
|
3536
3677
|
// append (never prepend) so the result element stays ahead of annotations
|
|
3537
3678
|
this.entryParseResult.content.push(annotation);
|
|
3538
3679
|
}
|
|
3680
|
+
|
|
3681
|
+
/**
|
|
3682
|
+
* The entry document traversal is rooted at its Parse Result (nested
|
|
3683
|
+
* traversals are rooted at fragments), so leaving it marks the moment the
|
|
3684
|
+
* whole entry document has been visited and the collected fragments can be
|
|
3685
|
+
* placed into its Components Object without the traversal descending into them.
|
|
3686
|
+
* Guarded on the node so that a traversal rooted at any other Parse Result
|
|
3687
|
+
* never flushes the shared placements early.
|
|
3688
|
+
*/
|
|
3689
|
+
ParseResultElement = {
|
|
3690
|
+
leave: path => {
|
|
3691
|
+
if (path.node !== this.entryParseResult) return;
|
|
3692
|
+
for (const {
|
|
3693
|
+
field,
|
|
3694
|
+
name,
|
|
3695
|
+
element
|
|
3696
|
+
} of this.placements) {
|
|
3697
|
+
this.ensureComponentsField(field).set(name, element);
|
|
3698
|
+
}
|
|
3699
|
+
this.placements.length = 0;
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3539
3702
|
async ReferenceElement(path) {
|
|
3540
3703
|
const referencingElement = path.node;
|
|
3541
|
-
const $ref = (0,
|
|
3704
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref);
|
|
3542
3705
|
const retrievalURI = this.toBaseURI($ref);
|
|
3543
3706
|
const isInternalReference = this.entryURI === retrievalURI;
|
|
3544
3707
|
const isExternalReference = !isInternalReference;
|
|
@@ -3555,8 +3718,8 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3555
3718
|
path.skip();
|
|
3556
3719
|
return;
|
|
3557
3720
|
}
|
|
3558
|
-
const $refBaseURI =
|
|
3559
|
-
const jsonPointer =
|
|
3721
|
+
const $refBaseURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.resolve(retrievalURI, $ref);
|
|
3722
|
+
const jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
3560
3723
|
|
|
3561
3724
|
// the target bucket depends on the referencing context, so it's part of the
|
|
3562
3725
|
// identity: the same external target referenced as e.g. both a parameter and
|
|
@@ -3584,7 +3747,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3584
3747
|
try {
|
|
3585
3748
|
// detect maximum depth of bundling
|
|
3586
3749
|
if (this.reference.depth >= this.options.bundle.maxDepth) {
|
|
3587
|
-
throw new
|
|
3750
|
+
throw new _errors_MaximumBundleDepthError_ts__WEBPACK_IMPORTED_MODULE_30__["default"](`Maximum bundle depth of "${this.options.bundle.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
3588
3751
|
maxDepth: this.options.bundle.maxDepth,
|
|
3589
3752
|
uri: this.reference.uri
|
|
3590
3753
|
});
|
|
@@ -3592,21 +3755,21 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3592
3755
|
const reference = await this.toReference($ref);
|
|
3593
3756
|
|
|
3594
3757
|
// possibly non-semantic fragment
|
|
3595
|
-
let referencedElement = (0,
|
|
3758
|
+
let referencedElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
|
|
3596
3759
|
|
|
3597
3760
|
// apply semantics to the fragment so nested references become Reference Objects
|
|
3598
|
-
if (referencedElement.element !== referencedElementType && !(0,
|
|
3761
|
+
if (referencedElement.element !== referencedElementType && !(0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isReferenceElement)(referencedElement)) {
|
|
3599
3762
|
const cached = this.getRefracted(referencedElement, referencedElementType);
|
|
3600
3763
|
if (cached !== undefined) {
|
|
3601
3764
|
referencedElement = cached;
|
|
3602
|
-
} else if ((0,
|
|
3765
|
+
} else if ((0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isReferenceLikeElement)(referencedElement)) {
|
|
3603
3766
|
const sourceElement = referencedElement;
|
|
3604
|
-
referencedElement = (0,
|
|
3767
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.refractReference)(referencedElement);
|
|
3605
3768
|
referencedElement.meta.set('referenced-element', referencedElementType);
|
|
3606
3769
|
this.setRefracted(sourceElement, referencedElementType, referencedElement);
|
|
3607
3770
|
} else {
|
|
3608
3771
|
const sourceElement = referencedElement;
|
|
3609
|
-
referencedElement = (0,
|
|
3772
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__["default"])(referencedElement, {
|
|
3610
3773
|
element: referencedElementType
|
|
3611
3774
|
});
|
|
3612
3775
|
this.setRefracted(sourceElement, referencedElementType, referencedElement);
|
|
@@ -3614,7 +3777,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3614
3777
|
}
|
|
3615
3778
|
const preferredName = this.baseName(referencedElement, field, jsonPointer, retrievalURI);
|
|
3616
3779
|
const componentName = this.uniqueName(preferredName, field);
|
|
3617
|
-
const internalPointer = `#/components/${field}/${(0,
|
|
3780
|
+
const internalPointer = `#/components/${field}/${(0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.escape)(componentName)}`;
|
|
3618
3781
|
this.reportNameCollision(preferredName, componentName, field);
|
|
3619
3782
|
|
|
3620
3783
|
// reserve the assignment and component name before recursing so cyclic
|
|
@@ -3623,16 +3786,21 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3623
3786
|
if (!this.reservedNames.has(field)) this.reservedNames.set(field, new Set());
|
|
3624
3787
|
this.reservedNames.get(field).add(componentName);
|
|
3625
3788
|
|
|
3626
|
-
// own a copy of the fragment and bundle its own external references
|
|
3627
|
-
|
|
3789
|
+
// own a copy of the fragment and bundle its own external references; the
|
|
3790
|
+
// fragment ends up in the entry document, so that is where its content
|
|
3791
|
+
// resolves relative references from
|
|
3792
|
+
const hoistedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(referencedElement);
|
|
3628
3793
|
const visitor = new OpenAPI3_1BundleVisitor({
|
|
3629
3794
|
reference,
|
|
3630
3795
|
options: this.options,
|
|
3631
3796
|
assignments: this.assignments,
|
|
3632
3797
|
reservedNames: this.reservedNames,
|
|
3633
|
-
refractCache: this.refractCache
|
|
3798
|
+
refractCache: this.refractCache,
|
|
3799
|
+
schema$idIndex: this.schema$idIndex,
|
|
3800
|
+
placements: this.placements,
|
|
3801
|
+
relocationBaseURI: this.entryURI
|
|
3634
3802
|
});
|
|
3635
|
-
const bundledElement = await (0,
|
|
3803
|
+
const bundledElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(hoistedElement, visitor, {
|
|
3636
3804
|
mutable: true
|
|
3637
3805
|
});
|
|
3638
3806
|
|
|
@@ -3641,8 +3809,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3641
3809
|
bundledElement.meta.set('ref-origin', reference.uri);
|
|
3642
3810
|
}
|
|
3643
3811
|
|
|
3644
|
-
//
|
|
3645
|
-
this.
|
|
3812
|
+
// queue the bundled fragment for placement into the entry document's components
|
|
3813
|
+
this.placements.push({
|
|
3814
|
+
field,
|
|
3815
|
+
name: componentName,
|
|
3816
|
+
element: bundledElement
|
|
3817
|
+
});
|
|
3646
3818
|
|
|
3647
3819
|
// rewrite the referencing element to point at the hoisted fragment
|
|
3648
3820
|
referencingElement.set('$ref', internalPointer);
|
|
@@ -3668,7 +3840,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3668
3840
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(pathItemElement.$ref)) {
|
|
3669
3841
|
return;
|
|
3670
3842
|
}
|
|
3671
|
-
const $ref = (0,
|
|
3843
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(pathItemElement.$ref);
|
|
3672
3844
|
const retrievalURI = this.toBaseURI($ref);
|
|
3673
3845
|
const isInternalReference = this.entryURI === retrievalURI;
|
|
3674
3846
|
const isExternalReference = !isInternalReference;
|
|
@@ -3685,8 +3857,8 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3685
3857
|
path.skip();
|
|
3686
3858
|
return;
|
|
3687
3859
|
}
|
|
3688
|
-
const $refBaseURI =
|
|
3689
|
-
const jsonPointer =
|
|
3860
|
+
const $refBaseURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.resolve(retrievalURI, $ref);
|
|
3861
|
+
const jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
3690
3862
|
const field = cf.pathItems.name;
|
|
3691
3863
|
const canonicalKey = `${field}\t${retrievalURI}#${jsonPointer}`;
|
|
3692
3864
|
|
|
@@ -3701,28 +3873,28 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3701
3873
|
try {
|
|
3702
3874
|
// detect maximum depth of bundling
|
|
3703
3875
|
if (this.reference.depth >= this.options.bundle.maxDepth) {
|
|
3704
|
-
throw new
|
|
3876
|
+
throw new _errors_MaximumBundleDepthError_ts__WEBPACK_IMPORTED_MODULE_30__["default"](`Maximum bundle depth of "${this.options.bundle.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
3705
3877
|
maxDepth: this.options.bundle.maxDepth,
|
|
3706
3878
|
uri: this.reference.uri
|
|
3707
3879
|
});
|
|
3708
3880
|
}
|
|
3709
3881
|
const reference = await this.toReference($ref);
|
|
3710
|
-
let referencedElement = (0,
|
|
3882
|
+
let referencedElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
|
|
3711
3883
|
|
|
3712
3884
|
// apply Path Item semantics to the referenced fragment
|
|
3713
|
-
if (!(0,
|
|
3885
|
+
if (!(0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isPathItemElement)(referencedElement)) {
|
|
3714
3886
|
const cached = this.getRefracted(referencedElement, 'pathItem');
|
|
3715
3887
|
if (cached !== undefined) {
|
|
3716
3888
|
referencedElement = cached;
|
|
3717
3889
|
} else {
|
|
3718
3890
|
const sourceElement = referencedElement;
|
|
3719
|
-
referencedElement = (0,
|
|
3891
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.refractPathItem)(referencedElement);
|
|
3720
3892
|
this.setRefracted(sourceElement, 'pathItem', referencedElement);
|
|
3721
3893
|
}
|
|
3722
3894
|
}
|
|
3723
3895
|
const preferredName = this.baseName(referencedElement, field, jsonPointer, retrievalURI);
|
|
3724
3896
|
const componentName = this.uniqueName(preferredName, field);
|
|
3725
|
-
const internalPointer = `#/components/${field}/${(0,
|
|
3897
|
+
const internalPointer = `#/components/${field}/${(0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.escape)(componentName)}`;
|
|
3726
3898
|
this.reportNameCollision(preferredName, componentName, field);
|
|
3727
3899
|
|
|
3728
3900
|
// reserve the assignment and component name before recursing so cyclic
|
|
@@ -3731,16 +3903,21 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3731
3903
|
if (!this.reservedNames.has(field)) this.reservedNames.set(field, new Set());
|
|
3732
3904
|
this.reservedNames.get(field).add(componentName);
|
|
3733
3905
|
|
|
3734
|
-
// own a copy of the fragment and bundle its own external references
|
|
3735
|
-
|
|
3906
|
+
// own a copy of the fragment and bundle its own external references; the
|
|
3907
|
+
// Path Item ends up in the entry document, so that is where its content
|
|
3908
|
+
// resolves relative references from
|
|
3909
|
+
const hoistedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(referencedElement);
|
|
3736
3910
|
const visitor = new OpenAPI3_1BundleVisitor({
|
|
3737
3911
|
reference,
|
|
3738
3912
|
options: this.options,
|
|
3739
3913
|
assignments: this.assignments,
|
|
3740
3914
|
reservedNames: this.reservedNames,
|
|
3741
|
-
refractCache: this.refractCache
|
|
3915
|
+
refractCache: this.refractCache,
|
|
3916
|
+
schema$idIndex: this.schema$idIndex,
|
|
3917
|
+
placements: this.placements,
|
|
3918
|
+
relocationBaseURI: this.entryURI
|
|
3742
3919
|
});
|
|
3743
|
-
const bundledElement = await (0,
|
|
3920
|
+
const bundledElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(hoistedElement, visitor, {
|
|
3744
3921
|
mutable: true
|
|
3745
3922
|
});
|
|
3746
3923
|
|
|
@@ -3749,8 +3926,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3749
3926
|
// internal `#/components/pathItems/...` pointer by the child traversal
|
|
3750
3927
|
bundledElement.meta.set('ref-origin', reference.uri);
|
|
3751
3928
|
|
|
3752
|
-
//
|
|
3753
|
-
this.
|
|
3929
|
+
// queue the bundled Path Item for placement into the entry document's components
|
|
3930
|
+
this.placements.push({
|
|
3931
|
+
field,
|
|
3932
|
+
name: componentName,
|
|
3933
|
+
element: bundledElement
|
|
3934
|
+
});
|
|
3754
3935
|
|
|
3755
3936
|
// rewrite the referencing Path Item to point at the hoisted one, keeping
|
|
3756
3937
|
// any sibling fields (e.g. summary, description) next to the $ref
|
|
@@ -3778,21 +3959,22 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3778
3959
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(referencingElement.$ref)) {
|
|
3779
3960
|
return;
|
|
3780
3961
|
}
|
|
3781
|
-
const $ref = (0,
|
|
3962
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref);
|
|
3782
3963
|
try {
|
|
3783
3964
|
// compute baseURI using rules around $id and $ref keywords. The current
|
|
3784
3965
|
// document's URI is the retrieval URI — derive it directly (not via
|
|
3785
3966
|
// toReference) so an internal $ref needs no resolution and never trips the
|
|
3786
3967
|
// resolve.maxDepth guard, matching how ReferenceElement returns early.
|
|
3787
3968
|
const retrievalURI = this.reference.uri;
|
|
3788
|
-
const
|
|
3789
|
-
const $
|
|
3790
|
-
const
|
|
3969
|
+
const schemaBaseURI = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.resolveSchemaBaseURI)(retrievalURI, path);
|
|
3970
|
+
const $refBaseURI = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.resolveSchema$refField)(schemaBaseURI, referencingElement);
|
|
3971
|
+
const $refBaseURIStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash($refBaseURI);
|
|
3972
|
+
const file = new _File_ts__WEBPACK_IMPORTED_MODULE_36__["default"]({
|
|
3791
3973
|
uri: $refBaseURIStrippedHash
|
|
3792
3974
|
});
|
|
3793
3975
|
const isUnknownURI = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(r => r.canRead(file), this.options.resolve.resolvers);
|
|
3794
3976
|
const isURL = !isUnknownURI;
|
|
3795
|
-
const isInternalReference =
|
|
3977
|
+
const isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(this.reference.uri) === $refBaseURIStrippedHash;
|
|
3796
3978
|
const isExternalReference = !isInternalReference;
|
|
3797
3979
|
|
|
3798
3980
|
// internal Schema Object $refs resolve against the in-document $id graph;
|
|
@@ -3810,7 +3992,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3810
3992
|
// detect maximum depth of bundling before fetching the external resource,
|
|
3811
3993
|
// matching ReferenceElement/PathItemElement (which check before toReference)
|
|
3812
3994
|
if (this.reference.depth >= this.options.bundle.maxDepth) {
|
|
3813
|
-
throw new
|
|
3995
|
+
throw new _errors_MaximumBundleDepthError_ts__WEBPACK_IMPORTED_MODULE_30__["default"](`Maximum bundle depth of "${this.options.bundle.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
3814
3996
|
maxDepth: this.options.bundle.maxDepth,
|
|
3815
3997
|
uri: this.reference.uri
|
|
3816
3998
|
});
|
|
@@ -3821,59 +4003,95 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3821
4003
|
// as a canonical URI / URL against the current document's $id graph; if
|
|
3822
4004
|
// that fails, fall back to fetching the external document and resolving
|
|
3823
4005
|
// the fragment there as a $anchor or JSON Pointer.
|
|
4006
|
+
//
|
|
4007
|
+
// the fragment being traversed is searched before the whole document:
|
|
4008
|
+
// content hoisted out of an external document (a Response, Parameter, Path
|
|
4009
|
+
// Item, ...) is refracted with its own semantics, so the Schema Objects it
|
|
4010
|
+
// contains are indexed, whereas the external document as a whole is parsed
|
|
4011
|
+
// generically and refracted as a bare JSON Schema, which leaves those Schema
|
|
4012
|
+
// Objects (under `content`, `schema`, ...) unrecognized and their `$id`s out
|
|
4013
|
+
// of the index
|
|
4014
|
+
const documentElement = this.reference.value.result;
|
|
4015
|
+
const rootNode = path.getAncestorNodes().at(-1) ?? path.node;
|
|
4016
|
+
const fragmentElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isParseResultElement)(rootNode) ? rootNode.result : rootNode;
|
|
4017
|
+
const uriEvaluateOptions = {
|
|
4018
|
+
baseURI: retrievalURI,
|
|
4019
|
+
index: this.schema$idIndex
|
|
4020
|
+
};
|
|
3824
4021
|
let schemaReference = this.reference;
|
|
4022
|
+
let resourceRoot;
|
|
4023
|
+
let resourceBaseURI;
|
|
3825
4024
|
try {
|
|
3826
|
-
|
|
3827
|
-
|
|
4025
|
+
try {
|
|
4026
|
+
(0,_dereference_strategies_openapi_3_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_38__.evaluate)($refBaseURI, (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.maybeRefractToSchemaElement)(fragmentElement), uriEvaluateOptions);
|
|
4027
|
+
// a $ref that resolves (by $id/$anchor/pointer) within the traversed
|
|
4028
|
+
// content is internal even when its URI form (e.g. a URN or absolute
|
|
4029
|
+
// $id) is not a bare fragment: the $id resource travels with the content
|
|
4030
|
+
// wherever it is placed. Leave it untouched — it resolves against the
|
|
4031
|
+
// in-content $id graph, and embedding the content into itself would be
|
|
4032
|
+
// wrong.
|
|
4033
|
+
return;
|
|
4034
|
+
} catch (error) {
|
|
4035
|
+
if (!(error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_32__["default"]) || fragmentElement === documentElement) {
|
|
4036
|
+
throw error;
|
|
4037
|
+
}
|
|
4038
|
+
const documentAsSchema = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.maybeRefractToSchemaElement)(documentElement);
|
|
4039
|
+
(0,_dereference_strategies_openapi_3_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_38__.evaluate)($refBaseURI, documentAsSchema, uriEvaluateOptions);
|
|
4040
|
+
// the $id resource sits in the current document but outside the
|
|
4041
|
+
// traversed fragment, so it stays behind once the fragment is placed
|
|
4042
|
+
// into the entry document. The resource to embed is that $id-bearing
|
|
4043
|
+
// schema, addressed by its canonical URI (the $ref without fragment).
|
|
4044
|
+
resourceRoot = (0,_dereference_strategies_openapi_3_1_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_38__.evaluate)($refBaseURIStrippedHash, documentAsSchema, uriEvaluateOptions);
|
|
4045
|
+
resourceBaseURI = $refBaseURIStrippedHash;
|
|
4046
|
+
}
|
|
3828
4047
|
} catch (error) {
|
|
3829
|
-
if (isURL && error instanceof
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
const
|
|
3834
|
-
(0,_dereference_strategies_openapi_3_1_selectors_$
|
|
4048
|
+
if (isURL && error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_32__["default"]) {
|
|
4049
|
+
schemaReference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_33__.unsanitize($refBaseURI));
|
|
4050
|
+
const referenceAsSchema = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.maybeRefractToSchemaElement)(schemaReference.value.result);
|
|
4051
|
+
if ((0,_dereference_strategies_openapi_3_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_37__.isAnchor)((0,_dereference_strategies_openapi_3_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_37__.uriToAnchor)($refBaseURI))) {
|
|
4052
|
+
const selector = (0,_dereference_strategies_openapi_3_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_37__.uriToAnchor)($refBaseURI);
|
|
4053
|
+
(0,_dereference_strategies_openapi_3_1_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_37__.evaluate)(selector, referenceAsSchema);
|
|
3835
4054
|
} else {
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
const referenceAsSchema = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_38__.maybeRefractToSchemaElement)(schemaReference.value.result);
|
|
3839
|
-
(0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__.evaluate)(referenceAsSchema, selector);
|
|
4055
|
+
const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
4056
|
+
(0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(referenceAsSchema, selector);
|
|
3840
4057
|
}
|
|
4058
|
+
|
|
4059
|
+
// the resource to embed is the WHOLE external document (its root
|
|
4060
|
+
// schema), identified by its $id. A $ref into a fragment of the
|
|
4061
|
+
// document embeds the entire document resource once; the fragment
|
|
4062
|
+
// keeps resolving against the embedded $id.
|
|
4063
|
+
resourceRoot = referenceAsSchema;
|
|
4064
|
+
resourceBaseURI = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_39__.resolveSchema$idField)(_util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(schemaReference.uri), resourceRoot) ?? _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.stripHash(schemaReference.uri);
|
|
3841
4065
|
} else {
|
|
3842
4066
|
throw error;
|
|
3843
4067
|
}
|
|
3844
4068
|
}
|
|
3845
|
-
|
|
3846
|
-
// a $ref that resolves (by $id/$anchor/pointer) within the current document
|
|
3847
|
-
// is internal even when its URI form (e.g. a URN or absolute $id) is not a
|
|
3848
|
-
// bare fragment. Leave it untouched — it resolves against the in-document
|
|
3849
|
-
// $id graph, and embedding the current document into itself would be wrong.
|
|
3850
|
-
if (_util_url_ts__WEBPACK_IMPORTED_MODULE_32__.stripHash(schemaReference.uri) === _util_url_ts__WEBPACK_IMPORTED_MODULE_32__.stripHash(this.reference.uri)) {
|
|
3851
|
-
return;
|
|
3852
|
-
}
|
|
3853
|
-
|
|
3854
|
-
// the resource to embed is the WHOLE external document (its root schema),
|
|
3855
|
-
// identified by its $id. A $ref into a fragment of the document embeds the
|
|
3856
|
-
// entire document resource once; the fragment keeps resolving against the
|
|
3857
|
-
// embedded $id.
|
|
3858
|
-
const resourceRoot = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_38__.maybeRefractToSchemaElement)(schemaReference.value.result);
|
|
3859
|
-
const resourceBaseURI = (0,_dereference_strategies_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_38__.resolveSchema$idField)(_util_url_ts__WEBPACK_IMPORTED_MODULE_32__.stripHash(schemaReference.uri), resourceRoot) ?? _util_url_ts__WEBPACK_IMPORTED_MODULE_32__.stripHash(schemaReference.uri);
|
|
3860
4069
|
const field = cf.schemas.name;
|
|
3861
4070
|
const canonicalKey = `${field}\t${resourceBaseURI}`;
|
|
3862
4071
|
|
|
3863
|
-
//
|
|
3864
|
-
// $
|
|
4072
|
+
// a location-based $ref to a self-identifying resource is rebased onto the
|
|
4073
|
+
// resource's $id (keeping its fragment) — once embedded, the resource is
|
|
4074
|
+
// reachable only by its $id. A $ref already resolving to that $id is left
|
|
4075
|
+
// as written. See rebaseSchema$ref for the spec trade-off.
|
|
4076
|
+
//
|
|
4077
|
+
// a $ref whose base URI changes on relocation into the entry document
|
|
4078
|
+
// (inside a hoisted Response, Parameter, Path Item, ...) is instead
|
|
4079
|
+
// rewritten to address the embedded resource from the base it will have
|
|
4080
|
+
// there, otherwise it dangles once placed. See relocateSchema$ref.
|
|
4081
|
+
const relocatedBaseURI = this.relocatedSchemaBaseURI(path, $refBaseURI);
|
|
4082
|
+
const rebased$ref = relocatedBaseURI === undefined ? (0,_util_ts__WEBPACK_IMPORTED_MODULE_40__.rebaseSchema$ref)($refBaseURI, resourceBaseURI) : (0,_util_ts__WEBPACK_IMPORTED_MODULE_40__.relocateSchema$ref)($refBaseURI, resourceBaseURI, relocatedBaseURI, (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(resourceRoot.$id));
|
|
4083
|
+
|
|
4084
|
+
// resource already embedded (or being embedded) — point the referencing
|
|
4085
|
+
// $ref at it and stop. This also terminates circular external schema
|
|
3865
4086
|
// references, since the assignment is reserved BEFORE recursion.
|
|
3866
4087
|
if (this.assignments.has(canonicalKey)) {
|
|
4088
|
+
if (rebased$ref !== undefined) referencingElement.set('$ref', rebased$ref);
|
|
3867
4089
|
path.skip();
|
|
3868
4090
|
return;
|
|
3869
4091
|
}
|
|
3870
4092
|
|
|
3871
|
-
// own a copy of the resource
|
|
3872
|
-
|
|
3873
|
-
const embeddedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.cloneDeep)(resourceRoot);
|
|
3874
|
-
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(embeddedElement.$id)) {
|
|
3875
|
-
embeddedElement.set('$id', resourceBaseURI);
|
|
3876
|
-
}
|
|
4093
|
+
// own a copy of the resource
|
|
4094
|
+
const embeddedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(resourceRoot);
|
|
3877
4095
|
|
|
3878
4096
|
// the embedded thing is the WHOLE resource (keyed by its $id), so its name
|
|
3879
4097
|
// is derived from the resource URI, not the $ref fragment — passing a root
|
|
@@ -3884,7 +4102,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3884
4102
|
|
|
3885
4103
|
// reserve the assignment and component name before recursing so circular
|
|
3886
4104
|
// external schema references terminate
|
|
3887
|
-
this.assignments.set(canonicalKey, `#/components/${field}/${(0,
|
|
4105
|
+
this.assignments.set(canonicalKey, `#/components/${field}/${(0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.escape)(componentName)}`);
|
|
3888
4106
|
if (!this.reservedNames.has(field)) this.reservedNames.set(field, new Set());
|
|
3889
4107
|
this.reservedNames.get(field).add(componentName);
|
|
3890
4108
|
|
|
@@ -3895,20 +4113,36 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3895
4113
|
options: this.options,
|
|
3896
4114
|
assignments: this.assignments,
|
|
3897
4115
|
reservedNames: this.reservedNames,
|
|
3898
|
-
refractCache: this.refractCache
|
|
4116
|
+
refractCache: this.refractCache,
|
|
4117
|
+
schema$idIndex: this.schema$idIndex,
|
|
4118
|
+
placements: this.placements
|
|
3899
4119
|
});
|
|
3900
|
-
const bundledElement = await (0,
|
|
4120
|
+
const bundledElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(embeddedElement, visitor, {
|
|
3901
4121
|
mutable: true
|
|
3902
4122
|
});
|
|
3903
4123
|
|
|
4124
|
+
// a resource without its own $id is identified by its retrieval URI; write
|
|
4125
|
+
// it relative to the entry document (the base of components.schemas) so the
|
|
4126
|
+
// bundle carries no absolute filesystem path and stays relocatable. Assigned
|
|
4127
|
+
// after the nested traversal so a reader deriving a schema's base from live
|
|
4128
|
+
// $ids (see #540) never resolves the resource's own $refs against the entry
|
|
4129
|
+
// document.
|
|
4130
|
+
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(bundledElement.$id)) {
|
|
4131
|
+
bundledElement.set('$id', _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.relative(this.entryURI, resourceBaseURI));
|
|
4132
|
+
}
|
|
4133
|
+
|
|
3904
4134
|
// annotate the embedded resource with info about its origin
|
|
3905
4135
|
bundledElement.meta.set('ref-origin', schemaReference.uri);
|
|
3906
4136
|
|
|
3907
|
-
//
|
|
3908
|
-
this.
|
|
4137
|
+
// queue the embedded resource for placement into the entry document's components
|
|
4138
|
+
this.placements.push({
|
|
4139
|
+
field,
|
|
4140
|
+
name: componentName,
|
|
4141
|
+
element: bundledElement
|
|
4142
|
+
});
|
|
3909
4143
|
|
|
3910
|
-
// the referencing $ref
|
|
3911
|
-
|
|
4144
|
+
// point the referencing $ref at the embedded resource's $id
|
|
4145
|
+
if (rebased$ref !== undefined) referencingElement.set('$ref', rebased$ref);
|
|
3912
4146
|
path.skip();
|
|
3913
4147
|
} catch (error) {
|
|
3914
4148
|
this.handleError(`Error while bundling Schema Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
@@ -3931,12 +4165,12 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3931
4165
|
|
|
3932
4166
|
// value and externalValue fields are mutually exclusive
|
|
3933
4167
|
if (exampleElement.hasKey('value') && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(exampleElement.externalValue)) {
|
|
3934
|
-
throw new
|
|
3935
|
-
value: (0,
|
|
3936
|
-
externalValue: (0,
|
|
4168
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('ExampleElement value and externalValue fields are mutually exclusive', {
|
|
4169
|
+
value: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.value),
|
|
4170
|
+
externalValue: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue)
|
|
3937
4171
|
});
|
|
3938
4172
|
}
|
|
3939
|
-
const externalValue = (0,
|
|
4173
|
+
const externalValue = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue);
|
|
3940
4174
|
const retrievalURI = this.toBaseURI(externalValue);
|
|
3941
4175
|
const isInternalReference = this.entryURI === retrievalURI;
|
|
3942
4176
|
const isExternalReference = !isInternalReference;
|
|
@@ -3947,9 +4181,9 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3947
4181
|
}
|
|
3948
4182
|
try {
|
|
3949
4183
|
const reference = await this.toReference(externalValue);
|
|
3950
|
-
const valueElement = (0,
|
|
4184
|
+
const valueElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(reference.value.result);
|
|
3951
4185
|
valueElement.meta.set('ref-origin', reference.uri);
|
|
3952
|
-
const exampleElementCopy = (0,
|
|
4186
|
+
const exampleElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(exampleElement);
|
|
3953
4187
|
exampleElementCopy.value = valueElement;
|
|
3954
4188
|
exampleElementCopy.remove('externalValue');
|
|
3955
4189
|
path.replaceWith(exampleElementCopy);
|
|
@@ -3970,9 +4204,9 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3970
4204
|
|
|
3971
4205
|
// operationRef and operationId fields are mutually exclusive
|
|
3972
4206
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(linkElement.operationRef) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(linkElement.operationId)) {
|
|
3973
|
-
throw new
|
|
3974
|
-
operationRef: (0,
|
|
3975
|
-
operationId: (0,
|
|
4207
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('LinkElement operationRef and operationId fields are mutually exclusive', {
|
|
4208
|
+
operationRef: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef),
|
|
4209
|
+
operationId: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationId)
|
|
3976
4210
|
});
|
|
3977
4211
|
}
|
|
3978
4212
|
|
|
@@ -3980,7 +4214,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3980
4214
|
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(linkElement.operationRef)) {
|
|
3981
4215
|
return;
|
|
3982
4216
|
}
|
|
3983
|
-
const operationRef = (0,
|
|
4217
|
+
const operationRef = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef);
|
|
3984
4218
|
const retrievalURI = this.toBaseURI(operationRef);
|
|
3985
4219
|
const isInternalReference = this.entryURI === retrievalURI;
|
|
3986
4220
|
if (isInternalReference) {
|
|
@@ -3997,7 +4231,7 @@ class OpenAPI3_1BundleVisitor {
|
|
|
3997
4231
|
|
|
3998
4232
|
// rewrite to an absolute URI so the link keeps resolving once the document
|
|
3999
4233
|
// is treated as self-contained
|
|
4000
|
-
const absoluteURI =
|
|
4234
|
+
const absoluteURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_33__.resolve(this.reference.uri, operationRef);
|
|
4001
4235
|
if (absoluteURI !== operationRef) {
|
|
4002
4236
|
linkElement.set('operationRef', absoluteURI);
|
|
4003
4237
|
}
|
|
@@ -4016,6 +4250,9 @@ class OpenAPI3_1BundleVisitor {
|
|
|
4016
4250
|
|
|
4017
4251
|
"use strict";
|
|
4018
4252
|
__webpack_require__.r(__webpack_exports__);
|
|
4253
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30658);
|
|
4254
|
+
|
|
4255
|
+
|
|
4019
4256
|
/**
|
|
4020
4257
|
* Upper-cases the first letter of each whitespace-separated word and joins
|
|
4021
4258
|
* them, e.g. `pet model` -> `PetModel`.
|
|
@@ -4049,7 +4286,60 @@ const uniqueName = (candidate, isTaken) => {
|
|
|
4049
4286
|
}
|
|
4050
4287
|
return `${candidate}-${counter}`;
|
|
4051
4288
|
};
|
|
4289
|
+
|
|
4290
|
+
/**
|
|
4291
|
+
* Computes the `$ref` value addressing an embedded JSON Schema resource by its
|
|
4292
|
+
* canonical `$id`. `$refURI` is the `$ref` resolved against the referencing
|
|
4293
|
+
* document's base URI; `resourceURI` is the embedded resource's canonical URI
|
|
4294
|
+
* (its `$id`, or the retrieval URI when it has none).
|
|
4295
|
+
*
|
|
4296
|
+
* When the two differ — a location-based `$ref` (e.g. `./ex.json#/$defs/Pet`)
|
|
4297
|
+
* to a resource that identifies itself differently (`$id: https://example.com/pets`)
|
|
4298
|
+
* — the `$ref` is rebased onto the resource URI, keeping its `$anchor` or JSON
|
|
4299
|
+
* Pointer fragment. Once embedded, the resource is reachable only by its `$id`,
|
|
4300
|
+
* so an unchanged `$ref` would dangle. When they already agree, `undefined` is
|
|
4301
|
+
* returned and the `$ref` is to be left as written.
|
|
4302
|
+
*
|
|
4303
|
+
* This knowingly departs from the letter of JSON Schema 2020-12 §9.3.1
|
|
4304
|
+
* ("references ... MUST NOT be changed"), which presumes `$ref`s are written
|
|
4305
|
+
* against `$id`s. The target schema — and thus evaluation output — is unchanged;
|
|
4306
|
+
* only the alias the loader knew the resource by is normalized to its canonical URI.
|
|
4307
|
+
*
|
|
4308
|
+
* @public
|
|
4309
|
+
*/
|
|
4310
|
+
const rebaseSchema$ref = ($refURI, resourceURI) => {
|
|
4311
|
+
if (_util_url_ts__WEBPACK_IMPORTED_MODULE_0__.stripHash($refURI) === resourceURI) {
|
|
4312
|
+
return undefined;
|
|
4313
|
+
}
|
|
4314
|
+
const fragment = _util_url_ts__WEBPACK_IMPORTED_MODULE_0__.getHash($refURI);
|
|
4315
|
+
return fragment === '#' ? resourceURI : `${resourceURI}${fragment}`;
|
|
4316
|
+
};
|
|
4317
|
+
|
|
4318
|
+
/**
|
|
4319
|
+
* Computes the `$ref` value addressing an embedded JSON Schema resource from a
|
|
4320
|
+
* Schema Object whose base URI changes when it is relocated into the entry
|
|
4321
|
+
* document — one carried inside a hoisted Response, Parameter, Path Item, etc.
|
|
4322
|
+
* `$refURI` and `resourceURI` are as in `rebaseSchema$ref`; `baseURI` is the
|
|
4323
|
+
* base the `$ref` resolves against after relocation.
|
|
4324
|
+
*
|
|
4325
|
+
* A resource that identifies itself (`isResourceIdentified`, i.e. it declares a
|
|
4326
|
+
* `$id`) is addressed by that `$id`, exactly as `rebaseSchema$ref` does. A
|
|
4327
|
+
* resource identified only by its retrieval URI is addressed by a URI reference
|
|
4328
|
+
* relative to `baseURI`: it then resolves to the `$id` assigned from that
|
|
4329
|
+
* retrieval URI wherever the bundle is placed, and no absolute retrieval
|
|
4330
|
+
* location leaks into the `$ref`. The `$anchor` or JSON Pointer fragment is
|
|
4331
|
+
* kept in both cases.
|
|
4332
|
+
*
|
|
4333
|
+
* @public
|
|
4334
|
+
*/
|
|
4335
|
+
const relocateSchema$ref = ($refURI, resourceURI, baseURI, isResourceIdentified) => {
|
|
4336
|
+
const target = isResourceIdentified ? resourceURI : _util_url_ts__WEBPACK_IMPORTED_MODULE_0__.relative(baseURI, resourceURI);
|
|
4337
|
+
const fragment = _util_url_ts__WEBPACK_IMPORTED_MODULE_0__.getHash($refURI);
|
|
4338
|
+
return fragment === '#' ? target : `${target}${fragment}`;
|
|
4339
|
+
};
|
|
4052
4340
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
4341
|
+
/* harmony export */ "rebaseSchema$ref", 0, /* binding */ rebaseSchema$ref,
|
|
4342
|
+
/* harmony export */ "relocateSchema$ref", 0, /* binding */ relocateSchema$ref,
|
|
4053
4343
|
/* harmony export */ "sanitizeComponentName", 0, /* binding */ sanitizeComponentName,
|
|
4054
4344
|
/* harmony export */ "toPascalCase", 0, /* binding */ toPascalCase,
|
|
4055
4345
|
/* harmony export */ "uniqueName", 0, /* binding */ uniqueName
|
|
@@ -4670,7 +4960,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4670
4960
|
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(98979);
|
|
4671
4961
|
/* harmony import */ var _ReferenceSet_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(24131);
|
|
4672
4962
|
/* harmony import */ var _visitor_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(31843);
|
|
4673
|
-
/* harmony import */ var
|
|
4963
|
+
/* harmony import */ var _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(60888);
|
|
4964
|
+
/* harmony import */ var _source_descriptions_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(12586);
|
|
4965
|
+
|
|
4674
4966
|
|
|
4675
4967
|
|
|
4676
4968
|
|
|
@@ -4734,7 +5026,8 @@ class Arazzo1DereferenceStrategy extends _DereferenceStrategy_ts__WEBPACK_IMPORT
|
|
|
4734
5026
|
const shouldDetectCircular = ['error', 'replace'].includes(options.dereference.circular);
|
|
4735
5027
|
const visitor = new _visitor_ts__WEBPACK_IMPORTED_MODULE_9__["default"]({
|
|
4736
5028
|
reference,
|
|
4737
|
-
options
|
|
5029
|
+
options,
|
|
5030
|
+
ancestorSchema$ids: (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_11__.detachedRootSchema$ids)(refSet.rootRef.value.result)
|
|
4738
5031
|
});
|
|
4739
5032
|
const dereferencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_3__.traverseAsync)(refSet.rootRef.value, visitor, {
|
|
4740
5033
|
mutable: true,
|
|
@@ -4743,6 +5036,17 @@ class Arazzo1DereferenceStrategy extends _DereferenceStrategy_ts__WEBPACK_IMPORT
|
|
|
4743
5036
|
})
|
|
4744
5037
|
});
|
|
4745
5038
|
|
|
5039
|
+
/**
|
|
5040
|
+
* If immutable option is set, replay refs from the refSet.
|
|
5041
|
+
* Replayed before source descriptions are dereferenced, so they can reuse the refs.
|
|
5042
|
+
*/
|
|
5043
|
+
if (options.dereference.immutable) {
|
|
5044
|
+
mutableRefSet.refs.filter(ref => ref.uri.startsWith('immutable://')).map(ref => new _Reference_ts__WEBPACK_IMPORTED_MODULE_7__["default"]({
|
|
5045
|
+
...ref,
|
|
5046
|
+
uri: ref.uri.replace(/^immutable:\/\//, '')
|
|
5047
|
+
})).forEach(ref => immutableRefSet.add(ref));
|
|
5048
|
+
}
|
|
5049
|
+
|
|
4746
5050
|
/**
|
|
4747
5051
|
* Dereference source descriptions if option is enabled.
|
|
4748
5052
|
*/
|
|
@@ -4753,20 +5057,10 @@ class Arazzo1DereferenceStrategy extends _DereferenceStrategy_ts__WEBPACK_IMPORT
|
|
|
4753
5057
|
// drop any existing parse-phase source description results before pushing
|
|
4754
5058
|
const cleaned = parseResult.reject(item => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.isParseResultElement)(item) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.includesClasses)(item, ['source-description']));
|
|
4755
5059
|
parseResult.content = cleaned.content;
|
|
4756
|
-
const sourceDescriptions = await (0,
|
|
5060
|
+
const sourceDescriptions = await (0,_source_descriptions_ts__WEBPACK_IMPORTED_MODULE_12__.dereferenceSourceDescriptions)(parseResult, reference.uri, options, this.name);
|
|
4757
5061
|
parseResult.push(...sourceDescriptions);
|
|
4758
5062
|
}
|
|
4759
5063
|
|
|
4760
|
-
/**
|
|
4761
|
-
* If immutable option is set, replay refs from the refSet.
|
|
4762
|
-
*/
|
|
4763
|
-
if (options.dereference.immutable) {
|
|
4764
|
-
mutableRefSet.refs.filter(ref => ref.uri.startsWith('immutable://')).map(ref => new _Reference_ts__WEBPACK_IMPORTED_MODULE_7__["default"]({
|
|
4765
|
-
...ref,
|
|
4766
|
-
uri: ref.uri.replace(/^immutable:\/\//, '')
|
|
4767
|
-
})).forEach(ref => immutableRefSet.add(ref));
|
|
4768
|
-
}
|
|
4769
|
-
|
|
4770
5064
|
/**
|
|
4771
5065
|
* Release all memory if this refSet was not provided as a configuration option.
|
|
4772
5066
|
* If provided as configuration option, then provider is responsible for cleanup.
|
|
@@ -4803,10 +5097,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4803
5097
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4823);
|
|
4804
5098
|
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28839);
|
|
4805
5099
|
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(44673);
|
|
4806
|
-
/* harmony import */ var
|
|
4807
|
-
/* harmony import */ var
|
|
4808
|
-
/* harmony import */ var
|
|
4809
|
-
/* harmony import */ var
|
|
5100
|
+
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(164);
|
|
5101
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(30658);
|
|
5102
|
+
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(98979);
|
|
5103
|
+
/* harmony import */ var _ReferenceSet_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(24131);
|
|
5104
|
+
/* harmony import */ var _options_util_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(86547);
|
|
5105
|
+
/* harmony import */ var _parse_index_ts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(35014);
|
|
5106
|
+
/* harmony import */ var _index_ts__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(42037);
|
|
5107
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(91005);
|
|
5108
|
+
|
|
5109
|
+
|
|
5110
|
+
|
|
5111
|
+
|
|
4810
5112
|
|
|
4811
5113
|
|
|
4812
5114
|
|
|
@@ -4840,7 +5142,7 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
4840
5142
|
}
|
|
4841
5143
|
|
|
4842
5144
|
// normalize URI for consistent cycle detection and refSet cache key matching
|
|
4843
|
-
const retrievalURI =
|
|
5145
|
+
const retrievalURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_7__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_7__.stripHash(_util_url_ts__WEBPACK_IMPORTED_MODULE_7__.resolve(ctx.baseURI, sourceDescriptionURI)));
|
|
4844
5146
|
parseResult.setMetaProperty('retrievalURI', retrievalURI);
|
|
4845
5147
|
|
|
4846
5148
|
// skip if the document is still being dereferenced higher up the chain (cycle detection)
|
|
@@ -4859,58 +5161,69 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
4859
5161
|
annotation.classes.push('info');
|
|
4860
5162
|
parseResult.push(annotation);
|
|
4861
5163
|
parseResult.meta.set('parseResult', sharedDereferenceResult);
|
|
4862
|
-
(0,
|
|
5164
|
+
(0,_util_ts__WEBPACK_IMPORTED_MODULE_13__.validateSourceDescriptionAPI)(parseResult, sourceDescription, sharedDereferenceResult.api, retrievalURI);
|
|
4863
5165
|
return parseResult;
|
|
4864
5166
|
}
|
|
4865
5167
|
|
|
4866
5168
|
// check if source description was already parsed (e.g., during parse phase with sourceDescriptions: true)
|
|
4867
5169
|
const existingParseResult = sourceDescription.meta.get('parseResult');
|
|
5170
|
+
const parentRefSet = ctx.options.dereference.refSet;
|
|
5171
|
+
let refSet = null;
|
|
4868
5172
|
try {
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
},
|
|
4879
|
-
dereference: {
|
|
4880
|
-
strategyOpts: {
|
|
4881
|
-
// nested documents should dereference all their source descriptions
|
|
4882
|
-
// (parent's name filter doesn't apply to nested documents)
|
|
4883
|
-
// set at strategy-specific level to override any inherited filters
|
|
4884
|
-
[ctx.strategyName]: {
|
|
4885
|
-
sourceDescriptions: true,
|
|
4886
|
-
sourceDescriptionsDepth: ctx.currentDepth + 1,
|
|
4887
|
-
sourceDescriptionsAncestors: ctx.ancestors,
|
|
4888
|
-
sourceDescriptionsDereferenced: ctx.dereferenced
|
|
4889
|
-
}
|
|
4890
|
-
}
|
|
4891
|
-
}
|
|
4892
|
-
}));
|
|
5173
|
+
// source description document comes from, in order of preference:
|
|
5174
|
+
// caller-supplied refSet, parse phase, or is fetched and parsed now
|
|
5175
|
+
const cachedReference = parentRefSet?.find(ref => ref.uri === retrievalURI);
|
|
5176
|
+
let sourceDescriptionParseResult;
|
|
5177
|
+
let isFreshlyParsed = false;
|
|
5178
|
+
if (cachedReference !== undefined) {
|
|
5179
|
+
sourceDescriptionParseResult = cachedReference.value;
|
|
5180
|
+
} else if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.isParseResultElement)(existingParseResult)) {
|
|
5181
|
+
sourceDescriptionParseResult = existingParseResult;
|
|
4893
5182
|
} else {
|
|
4894
|
-
|
|
4895
|
-
sourceDescriptionDereferenced = await (0,_index_ts__WEBPACK_IMPORTED_MODULE_8__["default"])(retrievalURI, (0,_options_util_ts__WEBPACK_IMPORTED_MODULE_7__.merge)(ctx.options, {
|
|
5183
|
+
sourceDescriptionParseResult = await (0,_parse_index_ts__WEBPACK_IMPORTED_MODULE_11__["default"])(retrievalURI, (0,_options_util_ts__WEBPACK_IMPORTED_MODULE_10__.merge)(ctx.options, {
|
|
4896
5184
|
parse: {
|
|
4897
|
-
mediaType: 'text/plain'
|
|
4898
|
-
}
|
|
4899
|
-
dereference: {
|
|
4900
|
-
strategyOpts: {
|
|
4901
|
-
// nested documents should dereference all their source descriptions
|
|
4902
|
-
// (parent's name filter doesn't apply to nested documents)
|
|
4903
|
-
// set at strategy-specific level to override any inherited filters
|
|
4904
|
-
[ctx.strategyName]: {
|
|
4905
|
-
sourceDescriptions: true,
|
|
4906
|
-
sourceDescriptionsDepth: ctx.currentDepth + 1,
|
|
4907
|
-
sourceDescriptionsAncestors: ctx.ancestors,
|
|
4908
|
-
sourceDescriptionsDereferenced: ctx.dereferenced
|
|
4909
|
-
}
|
|
4910
|
-
}
|
|
4911
|
-
}
|
|
5185
|
+
mediaType: 'text/plain'
|
|
5186
|
+
} // allow parser plugin detection
|
|
4912
5187
|
}));
|
|
5188
|
+
isFreshlyParsed = true;
|
|
5189
|
+
}
|
|
5190
|
+
|
|
5191
|
+
// caller-supplied refSet is rooted at the entry document, but strategies dereference
|
|
5192
|
+
// the root of the refSet; re-root its references at the source description
|
|
5193
|
+
if (parentRefSet !== null) {
|
|
5194
|
+
refSet = new _ReferenceSet_ts__WEBPACK_IMPORTED_MODULE_9__["default"]({
|
|
5195
|
+
refs: [new _Reference_ts__WEBPACK_IMPORTED_MODULE_8__["default"]({
|
|
5196
|
+
uri: retrievalURI,
|
|
5197
|
+
value: sourceDescriptionParseResult
|
|
5198
|
+
}), ...parentRefSet.refs.map(ref => new _Reference_ts__WEBPACK_IMPORTED_MODULE_8__["default"]({
|
|
5199
|
+
...ref,
|
|
5200
|
+
refSet: undefined
|
|
5201
|
+
}))]
|
|
5202
|
+
});
|
|
4913
5203
|
}
|
|
5204
|
+
const sourceDescriptionDereferenced = await (0,_index_ts__WEBPACK_IMPORTED_MODULE_12__.dereferenceApiDOM)(sourceDescriptionParseResult, (0,_options_util_ts__WEBPACK_IMPORTED_MODULE_10__.merge)((0,ramda__WEBPACK_IMPORTED_MODULE_6__["default"])(['dereference', 'refSet'], refSet, ctx.options), {
|
|
5205
|
+
parse: {
|
|
5206
|
+
mediaType: 'text/plain' // allow dereference strategy detection via ApiDOM inspection
|
|
5207
|
+
},
|
|
5208
|
+
resolve: {
|
|
5209
|
+
baseURI: retrievalURI
|
|
5210
|
+
},
|
|
5211
|
+
dereference: {
|
|
5212
|
+
// freshly parsed document not reported to any refSet can be dereferenced in mutable mode
|
|
5213
|
+
immutable: ctx.options.dereference.immutable && !(isFreshlyParsed && parentRefSet === null),
|
|
5214
|
+
strategyOpts: {
|
|
5215
|
+
// nested documents should dereference all their source descriptions
|
|
5216
|
+
// (parent's name filter doesn't apply to nested documents)
|
|
5217
|
+
// set at strategy-specific level to override any inherited filters
|
|
5218
|
+
[ctx.strategyName]: {
|
|
5219
|
+
sourceDescriptions: true,
|
|
5220
|
+
sourceDescriptionsDepth: ctx.currentDepth + 1,
|
|
5221
|
+
sourceDescriptionsAncestors: ctx.ancestors,
|
|
5222
|
+
sourceDescriptionsDereferenced: ctx.dereferenced
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
}));
|
|
4914
5227
|
|
|
4915
5228
|
// merge dereferenced result into our parse result
|
|
4916
5229
|
for (const item of sourceDescriptionDereferenced) {
|
|
@@ -4923,16 +5236,23 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
4923
5236
|
annotation.classes.push('error');
|
|
4924
5237
|
parseResult.push(annotation);
|
|
4925
5238
|
return parseResult;
|
|
5239
|
+
} finally {
|
|
5240
|
+
// report documents reached through the source description to the caller-supplied refSet,
|
|
5241
|
+
// even when dereferencing it failed
|
|
5242
|
+
if (parentRefSet !== null && refSet !== null) {
|
|
5243
|
+
parentRefSet.merge(refSet);
|
|
5244
|
+
parentRefSet.circular ||= refSet.circular;
|
|
5245
|
+
}
|
|
4926
5246
|
}
|
|
4927
5247
|
|
|
4928
5248
|
// register dereferenced document for later references to it
|
|
4929
5249
|
const {
|
|
4930
5250
|
api: sourceDescriptionAPI
|
|
4931
5251
|
} = parseResult;
|
|
4932
|
-
for (const documentURI of (0,
|
|
5252
|
+
for (const documentURI of (0,_util_ts__WEBPACK_IMPORTED_MODULE_13__.arazzoDocumentURIs)(retrievalURI, sourceDescriptionAPI)) {
|
|
4933
5253
|
ctx.dereferenced.set(documentURI, parseResult);
|
|
4934
5254
|
}
|
|
4935
|
-
;(0,
|
|
5255
|
+
;(0,_util_ts__WEBPACK_IMPORTED_MODULE_13__.validateSourceDescriptionAPI)(parseResult, sourceDescription, sourceDescriptionAPI, retrievalURI);
|
|
4936
5256
|
return parseResult;
|
|
4937
5257
|
}
|
|
4938
5258
|
|
|
@@ -4985,7 +5305,7 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
4985
5305
|
* @public
|
|
4986
5306
|
*/
|
|
4987
5307
|
async function dereferenceSourceDescriptions(parseResult, parseResultRetrievalURI, options, strategyName = 'arazzo-1') {
|
|
4988
|
-
const retrievalURI =
|
|
5308
|
+
const retrievalURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_7__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_7__.stripHash(parseResultRetrievalURI));
|
|
4989
5309
|
const results = [];
|
|
4990
5310
|
|
|
4991
5311
|
// get API from dereferenced parse result
|
|
@@ -5016,7 +5336,7 @@ async function dereferenceSourceDescriptions(parseResult, parseResultRetrievalUR
|
|
|
5016
5336
|
const currentDepth = sharedOpts.sourceDescriptionsDepth ?? 0;
|
|
5017
5337
|
const dereferenced = sharedOpts.sourceDescriptionsDereferenced ?? new Map();
|
|
5018
5338
|
// current file is an ancestor of everything dereferenced below
|
|
5019
|
-
const ancestors = [...(sharedOpts.sourceDescriptionsAncestors ?? []), ...(0,
|
|
5339
|
+
const ancestors = [...(sharedOpts.sourceDescriptionsAncestors ?? []), ...(0,_util_ts__WEBPACK_IMPORTED_MODULE_13__.arazzoDocumentURIs)(retrievalURI, api)];
|
|
5020
5340
|
if (currentDepth >= maxDepth) {
|
|
5021
5341
|
const annotation = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__["default"](`Maximum dereference depth of ${maxDepth} has been exceeded by file "${retrievalURI}"`);
|
|
5022
5342
|
annotation.classes.push('error');
|
|
@@ -5026,7 +5346,7 @@ async function dereferenceSourceDescriptions(parseResult, parseResultRetrievalUR
|
|
|
5026
5346
|
}
|
|
5027
5347
|
const ctx = {
|
|
5028
5348
|
// base URI for resolving source description URLs honors Arazzo `$self` field
|
|
5029
|
-
baseURI: (0,
|
|
5349
|
+
baseURI: (0,_util_ts__WEBPACK_IMPORTED_MODULE_13__.resolveArazzo$selfField)(retrievalURI, api),
|
|
5030
5350
|
options,
|
|
5031
5351
|
strategyName,
|
|
5032
5352
|
currentDepth,
|
|
@@ -5062,7 +5382,8 @@ async function dereferenceSourceDescriptions(parseResult, parseResultRetrievalUR
|
|
|
5062
5382
|
__webpack_require__.r(__webpack_exports__);
|
|
5063
5383
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5064
5384
|
/* harmony export */ resolveSchema$idField: () => (/* reexport safe */ _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_9__.resolveSchema$idField),
|
|
5065
|
-
/* harmony export */ resolveSchema$refField: () => (/* reexport safe */ _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_9__.resolveSchema$refField)
|
|
5385
|
+
/* harmony export */ resolveSchema$refField: () => (/* reexport safe */ _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_9__.resolveSchema$refField),
|
|
5386
|
+
/* harmony export */ resolveSchemaBaseURI: () => (/* reexport safe */ _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_9__.resolveSchemaBaseURI)
|
|
5066
5387
|
/* harmony export */ });
|
|
5067
5388
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25162);
|
|
5068
5389
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84660);
|
|
@@ -5203,31 +5524,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5203
5524
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(87009);
|
|
5204
5525
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6352);
|
|
5205
5526
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(25162);
|
|
5206
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
5207
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
5208
|
-
/* harmony import */ var
|
|
5209
|
-
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(
|
|
5210
|
-
/* harmony import */ var
|
|
5211
|
-
/* harmony import */ var
|
|
5212
|
-
/* harmony import */ var
|
|
5213
|
-
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(
|
|
5214
|
-
/* harmony import */ var
|
|
5215
|
-
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
5216
|
-
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(
|
|
5217
|
-
/* harmony import */ var
|
|
5218
|
-
/* harmony import */ var
|
|
5219
|
-
/* harmony import */ var
|
|
5220
|
-
/* harmony import */ var
|
|
5221
|
-
/* harmony import */ var
|
|
5222
|
-
/* harmony import */ var
|
|
5223
|
-
/* harmony import */ var
|
|
5224
|
-
/* harmony import */ var
|
|
5225
|
-
/* harmony import */ var
|
|
5226
|
-
/* harmony import */ var
|
|
5227
|
-
/* harmony import */ var
|
|
5228
|
-
/* harmony import */ var
|
|
5229
|
-
/* harmony import */ var
|
|
5230
|
-
/* harmony import */ var
|
|
5527
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(96911);
|
|
5528
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12111);
|
|
5529
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(78894);
|
|
5530
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(44673);
|
|
5531
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16280);
|
|
5532
|
+
/* harmony import */ var _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(44641);
|
|
5533
|
+
/* harmony import */ var _speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(80796);
|
|
5534
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(12020);
|
|
5535
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(61198);
|
|
5536
|
+
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(7557);
|
|
5537
|
+
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(96681);
|
|
5538
|
+
/* harmony import */ var _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(28839);
|
|
5539
|
+
/* harmony import */ var _swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(26847);
|
|
5540
|
+
/* harmony import */ var _selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(32054);
|
|
5541
|
+
/* harmony import */ var _selectors_uri_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(56481);
|
|
5542
|
+
/* harmony import */ var _openapi_3_1_selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(37517);
|
|
5543
|
+
/* harmony import */ var _openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(60888);
|
|
5544
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(91005);
|
|
5545
|
+
/* harmony import */ var _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(8853);
|
|
5546
|
+
/* harmony import */ var _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(37757);
|
|
5547
|
+
/* harmony import */ var _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(51325);
|
|
5548
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(30658);
|
|
5549
|
+
/* harmony import */ var _parse_index_ts__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(35014);
|
|
5550
|
+
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(98979);
|
|
5551
|
+
/* harmony import */ var _File_ts__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(10682);
|
|
5552
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(53429);
|
|
5553
|
+
/* harmony import */ var _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(44477);
|
|
5554
|
+
|
|
5231
5555
|
|
|
5232
5556
|
|
|
5233
5557
|
|
|
@@ -5268,8 +5592,23 @@ class Arazzo1DereferenceVisitor {
|
|
|
5268
5592
|
*/
|
|
5269
5593
|
baseURI;
|
|
5270
5594
|
options;
|
|
5595
|
+
|
|
5596
|
+
/**
|
|
5597
|
+
* Index of `$id`-bearing schemas per document, shared across nested visitors
|
|
5598
|
+
* of a single dereference run so it never outlives mutations of the documents.
|
|
5599
|
+
*/
|
|
5600
|
+
schema$idIndex;
|
|
5271
5601
|
visited;
|
|
5272
5602
|
|
|
5603
|
+
/**
|
|
5604
|
+
* `$id`s of the JSON Schema elements enclosing the traversal root within its
|
|
5605
|
+
* document (outermost first). Empty when the root is the document itself; a
|
|
5606
|
+
* nested visitor traversing a fragment is seeded with the `$id`s of the
|
|
5607
|
+
* schemas the fragment sits under, so the `$ref`s and `$id`s within resolve
|
|
5608
|
+
* against the same base as they would from the document root.
|
|
5609
|
+
*/
|
|
5610
|
+
ancestorSchema$ids;
|
|
5611
|
+
|
|
5273
5612
|
/**
|
|
5274
5613
|
* Tracks element ancestors across dive-deep traversal boundaries.
|
|
5275
5614
|
* Used for cycle detection: if a referenced element is found in
|
|
@@ -5280,29 +5619,33 @@ class Arazzo1DereferenceVisitor {
|
|
|
5280
5619
|
reference,
|
|
5281
5620
|
options,
|
|
5282
5621
|
indirections = [],
|
|
5283
|
-
|
|
5284
|
-
|
|
5622
|
+
schema$idIndex = new WeakMap(),
|
|
5623
|
+
ancestors = new _util_ts__WEBPACK_IMPORTED_MODULE_28__.AncestorLineage(),
|
|
5624
|
+
visited = new WeakSet(),
|
|
5625
|
+
ancestorSchema$ids = []
|
|
5285
5626
|
}) {
|
|
5286
5627
|
this.indirections = indirections;
|
|
5287
5628
|
this.reference = reference;
|
|
5288
|
-
this.baseURI = (0,
|
|
5629
|
+
this.baseURI = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.resolveArazzo$selfField)(reference.uri, reference.value?.result);
|
|
5289
5630
|
this.options = options;
|
|
5290
|
-
this.
|
|
5631
|
+
this.schema$idIndex = schema$idIndex;
|
|
5632
|
+
this.ancestors = new _util_ts__WEBPACK_IMPORTED_MODULE_28__.AncestorLineage(...ancestors);
|
|
5291
5633
|
this.visited = visited;
|
|
5634
|
+
this.ancestorSchema$ids = ancestorSchema$ids;
|
|
5292
5635
|
}
|
|
5293
5636
|
toAncestorLineage(path) {
|
|
5294
5637
|
const ancestorNodes = path.getAncestorNodes();
|
|
5295
5638
|
const directAncestors = new Set(ancestorNodes.filter(_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isElement));
|
|
5296
|
-
const ancestorsLineage = new
|
|
5639
|
+
const ancestorsLineage = new _util_ts__WEBPACK_IMPORTED_MODULE_28__.AncestorLineage(...this.ancestors, directAncestors);
|
|
5297
5640
|
return [ancestorsLineage, directAncestors];
|
|
5298
5641
|
}
|
|
5299
5642
|
toBaseURI(uri) {
|
|
5300
|
-
return
|
|
5643
|
+
return _util_url_ts__WEBPACK_IMPORTED_MODULE_24__.resolve(this.baseURI, _util_url_ts__WEBPACK_IMPORTED_MODULE_24__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.stripHash(uri)));
|
|
5301
5644
|
}
|
|
5302
5645
|
async toReference(uri) {
|
|
5303
5646
|
// detect maximum depth of resolution
|
|
5304
5647
|
if (this.reference.depth >= this.options.resolve.maxDepth) {
|
|
5305
|
-
throw new
|
|
5648
|
+
throw new _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_23__["default"](`Maximum resolution depth of ${this.options.resolve.maxDepth} has been exceeded by file "${this.reference.uri}"`, {
|
|
5306
5649
|
maxDepth: this.options.resolve.maxDepth,
|
|
5307
5650
|
uri: this.reference.uri
|
|
5308
5651
|
});
|
|
@@ -5318,11 +5661,11 @@ class Arazzo1DereferenceVisitor {
|
|
|
5318
5661
|
}
|
|
5319
5662
|
|
|
5320
5663
|
// identity-based referencing: URI matches `$self` of an already processed Arazzo document
|
|
5321
|
-
const referenceBy$self = refSet.find((0,
|
|
5664
|
+
const referenceBy$self = refSet.find((0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.identifiedBy$self)(baseURI));
|
|
5322
5665
|
if (referenceBy$self !== undefined) {
|
|
5323
5666
|
return referenceBy$self;
|
|
5324
5667
|
}
|
|
5325
|
-
const parseResult = await (0,
|
|
5668
|
+
const parseResult = await (0,_parse_index_ts__WEBPACK_IMPORTED_MODULE_25__["default"])(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.unsanitize(baseURI), {
|
|
5326
5669
|
...this.options,
|
|
5327
5670
|
parse: {
|
|
5328
5671
|
...this.options.parse,
|
|
@@ -5345,15 +5688,15 @@ class Arazzo1DereferenceVisitor {
|
|
|
5345
5688
|
// context always sees raw, unresolved elements and processes them with its own
|
|
5346
5689
|
// ancestors/indirections. The trade-off is that elements referenced by multiple
|
|
5347
5690
|
// documents would be resolved once per context instead of being reused.
|
|
5348
|
-
const mutableReference = new
|
|
5691
|
+
const mutableReference = new _Reference_ts__WEBPACK_IMPORTED_MODULE_26__["default"]({
|
|
5349
5692
|
uri: baseURI,
|
|
5350
|
-
value: this.options.dereference.immutable ? (0,
|
|
5693
|
+
value: this.options.dereference.immutable ? (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(parseResult) : parseResult,
|
|
5351
5694
|
depth: this.reference.depth + 1
|
|
5352
5695
|
});
|
|
5353
5696
|
refSet.add(mutableReference);
|
|
5354
5697
|
if (this.options.dereference.immutable) {
|
|
5355
5698
|
// register new immutable reference with a refSet
|
|
5356
|
-
const immutableReference = new
|
|
5699
|
+
const immutableReference = new _Reference_ts__WEBPACK_IMPORTED_MODULE_26__["default"]({
|
|
5357
5700
|
uri: `immutable://${baseURI}`,
|
|
5358
5701
|
value: parseResult,
|
|
5359
5702
|
depth: this.reference.depth + 1
|
|
@@ -5377,10 +5720,10 @@ class Arazzo1DereferenceVisitor {
|
|
|
5377
5720
|
const {
|
|
5378
5721
|
continueOnError
|
|
5379
5722
|
} = this.options.dereference;
|
|
5380
|
-
const isEntryDocument =
|
|
5723
|
+
const isEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_24__.stripHash(this.reference.refSet?.rootRef?.uri ?? '') === this.reference.uri;
|
|
5381
5724
|
const uri = this.reference.uri;
|
|
5382
5725
|
const type = referencingElement.element;
|
|
5383
|
-
const codeFrame = (0,
|
|
5726
|
+
const codeFrame = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__["default"])(referencingElement);
|
|
5384
5727
|
|
|
5385
5728
|
// find element location by identity in the document tree.
|
|
5386
5729
|
// guarded: this.reference.value may not be a ParseResultElement or may lack a result.
|
|
@@ -5389,7 +5732,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
5389
5732
|
let location;
|
|
5390
5733
|
const root = this.reference.value.result;
|
|
5391
5734
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isElement)(root)) {
|
|
5392
|
-
(0,
|
|
5735
|
+
(0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_9__.traverse)(root, {
|
|
5393
5736
|
enter(p) {
|
|
5394
5737
|
if (p.node === referencingElement) {
|
|
5395
5738
|
location = p.formatPath();
|
|
@@ -5410,10 +5753,10 @@ class Arazzo1DereferenceVisitor {
|
|
|
5410
5753
|
|
|
5411
5754
|
// enrich existing error from nested visitor or create new one
|
|
5412
5755
|
let unresolvedError;
|
|
5413
|
-
if (error instanceof
|
|
5756
|
+
if (error instanceof _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_21__["default"]) {
|
|
5414
5757
|
// prefix relative locations for entries belonging to the referenced document
|
|
5415
5758
|
const refBaseURI = this.toBaseURI(refFieldValue);
|
|
5416
|
-
const fragment =
|
|
5759
|
+
const fragment = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference(refFieldValue);
|
|
5417
5760
|
if (fragment) {
|
|
5418
5761
|
if (refBaseURI === error.uri && error.location) {
|
|
5419
5762
|
error.location = fragment + error.location;
|
|
@@ -5426,7 +5769,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
5426
5769
|
error.trace = [hop, ...error.trace];
|
|
5427
5770
|
unresolvedError = error;
|
|
5428
5771
|
} else {
|
|
5429
|
-
unresolvedError = new
|
|
5772
|
+
unresolvedError = new _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_21__["default"](message, {
|
|
5430
5773
|
cause: error,
|
|
5431
5774
|
type,
|
|
5432
5775
|
uri,
|
|
@@ -5454,52 +5797,56 @@ class Arazzo1DereferenceVisitor {
|
|
|
5454
5797
|
path.skip();
|
|
5455
5798
|
return;
|
|
5456
5799
|
}
|
|
5457
|
-
const runtimeExpression = (0,
|
|
5458
|
-
|
|
5459
|
-
// parse the runtime expression
|
|
5460
|
-
const {
|
|
5461
|
-
result,
|
|
5462
|
-
tree
|
|
5463
|
-
} = (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_14__.parse)(runtimeExpression);
|
|
5464
|
-
if (!result.success) {
|
|
5465
|
-
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_7__["default"](`Invalid Reusable Object reference format: "${runtimeExpression}"`, {
|
|
5466
|
-
runtimeExpression
|
|
5467
|
-
});
|
|
5468
|
-
}
|
|
5469
|
-
|
|
5470
|
-
// ReusableElement can only reference components
|
|
5471
|
-
if (tree.type !== 'ComponentsExpression') {
|
|
5472
|
-
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_7__["default"](`Reusable Object reference "${runtimeExpression}" must be a components expression`, {
|
|
5473
|
-
runtimeExpression
|
|
5474
|
-
});
|
|
5475
|
-
}
|
|
5476
|
-
|
|
5477
|
-
// evaluate runtime expression as JSON Pointer to get the referenced element
|
|
5478
|
-
const jsonPointer = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__.compile)(['components', tree.componentType, tree.componentName]);
|
|
5800
|
+
const runtimeExpression = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.reference);
|
|
5479
5801
|
let referencedElement;
|
|
5480
5802
|
try {
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
});
|
|
5803
|
+
// parse the runtime expression
|
|
5804
|
+
const {
|
|
5805
|
+
result,
|
|
5806
|
+
tree
|
|
5807
|
+
} = (0,_swaggerexpert_arazzo_runtime_expression__WEBPACK_IMPORTED_MODULE_15__.parse)(runtimeExpression);
|
|
5808
|
+
if (!result.success) {
|
|
5809
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__["default"](`Invalid Reusable Object reference format: "${runtimeExpression}"`, {
|
|
5810
|
+
runtimeExpression
|
|
5811
|
+
});
|
|
5812
|
+
}
|
|
5813
|
+
|
|
5814
|
+
// ReusableElement can only reference components
|
|
5815
|
+
if (tree.type !== 'ComponentsExpression') {
|
|
5816
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__["default"](`Reusable Object reference "${runtimeExpression}" must be a components expression`, {
|
|
5817
|
+
runtimeExpression
|
|
5818
|
+
});
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
// evaluate runtime expression as JSON Pointer to get the referenced element
|
|
5822
|
+
const jsonPointer = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__.compile)(['components', tree.componentType, tree.componentName]);
|
|
5823
|
+
try {
|
|
5824
|
+
referencedElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_10__.evaluate)(this.reference.value.result, jsonPointer);
|
|
5825
|
+
} catch {
|
|
5826
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__["default"](`Reusable Object reference "${runtimeExpression}" cannot be resolved`, {
|
|
5827
|
+
runtimeExpression
|
|
5828
|
+
});
|
|
5829
|
+
}
|
|
5830
|
+
} catch (error) {
|
|
5831
|
+
this.handleError(`Error while dereferencing Reusable Object. Cannot resolve reference "${runtimeExpression}": ${error.message}`, error, referencingElement, 'reference', runtimeExpression, path);
|
|
5832
|
+
return;
|
|
5486
5833
|
}
|
|
5487
5834
|
|
|
5488
5835
|
/**
|
|
5489
5836
|
* Create a shallow clone of the referenced element to avoid modifying the original.
|
|
5490
5837
|
*/
|
|
5491
|
-
const mergedElement = (0,
|
|
5838
|
+
const mergedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(referencedElement);
|
|
5492
5839
|
// annotate with info about original referencing element
|
|
5493
5840
|
mergedElement.meta.set('ref-fields', {
|
|
5494
5841
|
reference: runtimeExpression,
|
|
5495
|
-
value: (0,
|
|
5842
|
+
value: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.value)
|
|
5496
5843
|
});
|
|
5497
5844
|
// annotate with info about origin
|
|
5498
5845
|
mergedElement.meta.set('ref-origin', this.reference.uri);
|
|
5499
5846
|
mergedElement.meta.set('ref-type', referencingElement.element);
|
|
5500
5847
|
|
|
5501
5848
|
// override value field if present for Parameter Objects
|
|
5502
|
-
if ((0,
|
|
5849
|
+
if ((0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_14__.isParameterElement)(mergedElement) && referencingElement.hasKey('value')) {
|
|
5503
5850
|
mergedElement.remove('value');
|
|
5504
5851
|
mergedElement.set('value', referencingElement.get('value'));
|
|
5505
5852
|
}
|
|
@@ -5526,13 +5873,17 @@ class Arazzo1DereferenceVisitor {
|
|
|
5526
5873
|
const indirectionsSize = this.indirections.length;
|
|
5527
5874
|
try {
|
|
5528
5875
|
// compute baseURI using rules around $self, $id and $ref keywords
|
|
5529
|
-
let reference = await this.toReference(
|
|
5876
|
+
let reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.unsanitize(this.reference.uri));
|
|
5530
5877
|
let {
|
|
5531
5878
|
uri: retrievalURI
|
|
5532
5879
|
} = reference;
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
const
|
|
5880
|
+
// base URI in effect at the traversal root: the document base refined by
|
|
5881
|
+
// the $ids of the schemas enclosing the root when the root is a fragment
|
|
5882
|
+
const rootBaseURI = (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.resolveSchema$ids)(this.baseURI, this.ancestorSchema$ids);
|
|
5883
|
+
const schemaBaseURI = (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.resolveSchemaBaseURI)(rootBaseURI, path);
|
|
5884
|
+
const $refBaseURI = (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.resolveSchema$refField)(schemaBaseURI, referencingElement);
|
|
5885
|
+
const $refBaseURIStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_24__.stripHash($refBaseURI);
|
|
5886
|
+
const file = new _File_ts__WEBPACK_IMPORTED_MODULE_27__["default"]({
|
|
5536
5887
|
uri: $refBaseURIStrippedHash
|
|
5537
5888
|
});
|
|
5538
5889
|
const isUnknownURI = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(r => r.canRead(file), this.options.resolve.resolvers);
|
|
@@ -5542,14 +5893,33 @@ class Arazzo1DereferenceVisitor {
|
|
|
5542
5893
|
|
|
5543
5894
|
// determining reference, proper evaluation and selection mechanism
|
|
5544
5895
|
let referencedElement;
|
|
5896
|
+
// $ids of the schemas enclosing the referenced element within its document
|
|
5897
|
+
let ancestorSchema$ids;
|
|
5545
5898
|
try {
|
|
5546
5899
|
if (isUnknownURI || isURL) {
|
|
5547
5900
|
// we're dealing with canonical URI or URL with possible fragment
|
|
5548
5901
|
retrievalURI = this.toBaseURI($refBaseURI);
|
|
5549
5902
|
const selector = $refBaseURI;
|
|
5550
|
-
const
|
|
5551
|
-
|
|
5552
|
-
|
|
5903
|
+
const documentElement = reference.value.result;
|
|
5904
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(documentElement);
|
|
5905
|
+
// a document that is itself a fragment detached from its source carries
|
|
5906
|
+
// the $ids enclosing it only as `ancestorSchema$ids`: its $ids are then
|
|
5907
|
+
// indexed against the base that chain leaves in effect, and the chain
|
|
5908
|
+
// prefixes the one of the located schema. A nested visitor rooted at a
|
|
5909
|
+
// fragment of a whole document indexes that document against its own base.
|
|
5910
|
+
const rootNode = path.getAncestorNodes().at(-1) ?? path.node;
|
|
5911
|
+
const isDocumentRoot = ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isParseResultElement)(rootNode) ? rootNode.result : rootNode) === documentElement;
|
|
5912
|
+
({
|
|
5913
|
+
element: referencedElement,
|
|
5914
|
+
ancestorSchema$ids
|
|
5915
|
+
} = (0,_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_17__.locate)(selector, referenceAsSchema, {
|
|
5916
|
+
baseURI: isDocumentRoot ? rootBaseURI : this.baseURI,
|
|
5917
|
+
index: this.schema$idIndex
|
|
5918
|
+
}));
|
|
5919
|
+
if (isDocumentRoot) {
|
|
5920
|
+
ancestorSchema$ids = [...this.ancestorSchema$ids, ...ancestorSchema$ids];
|
|
5921
|
+
}
|
|
5922
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(referencedElement);
|
|
5553
5923
|
|
|
5554
5924
|
// ignore resolving internal Schema Objects
|
|
5555
5925
|
if (!this.options.resolve.internal && isInternalReference) {
|
|
@@ -5577,19 +5947,22 @@ class Arazzo1DereferenceVisitor {
|
|
|
5577
5947
|
// skip traversing this schema element but traverse all its child elements
|
|
5578
5948
|
return;
|
|
5579
5949
|
}
|
|
5580
|
-
reference = await this.toReference(
|
|
5581
|
-
const selector =
|
|
5582
|
-
const referenceAsSchema = (0,
|
|
5583
|
-
|
|
5584
|
-
|
|
5950
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.unsanitize($refBaseURI));
|
|
5951
|
+
const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
5952
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(reference.value.result);
|
|
5953
|
+
({
|
|
5954
|
+
element: referencedElement,
|
|
5955
|
+
ancestorSchema$ids
|
|
5956
|
+
} = (0,_openapi_3_1_selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_18__.locate)(referenceAsSchema, selector));
|
|
5957
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(referencedElement);
|
|
5585
5958
|
}
|
|
5586
5959
|
} catch (error) {
|
|
5587
5960
|
/**
|
|
5588
5961
|
* JSONSchemaElement($id=URL) was not found, so we're going to try to resolve
|
|
5589
5962
|
* the URL and assume the returned response is a JSON Schema.
|
|
5590
5963
|
*/
|
|
5591
|
-
if (isURL && error instanceof
|
|
5592
|
-
if ((0,_selectors_$
|
|
5964
|
+
if (isURL && error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_29__["default"]) {
|
|
5965
|
+
if ((0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_16__.isAnchor)((0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_16__.uriToAnchor)($refBaseURI))) {
|
|
5593
5966
|
// we're dealing with JSON Schema $anchor here
|
|
5594
5967
|
isInternalReference = this.baseURI === retrievalURI;
|
|
5595
5968
|
isExternalReference = !isInternalReference;
|
|
@@ -5604,11 +5977,14 @@ class Arazzo1DereferenceVisitor {
|
|
|
5604
5977
|
// skip traversing this schema element but traverse all its child elements
|
|
5605
5978
|
return;
|
|
5606
5979
|
}
|
|
5607
|
-
reference = await this.toReference(
|
|
5608
|
-
const selector = (0,_selectors_$
|
|
5609
|
-
const referenceAsSchema = (0,
|
|
5610
|
-
|
|
5611
|
-
|
|
5980
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.unsanitize($refBaseURI));
|
|
5981
|
+
const selector = (0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_16__.uriToAnchor)($refBaseURI);
|
|
5982
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(reference.value.result);
|
|
5983
|
+
({
|
|
5984
|
+
element: referencedElement,
|
|
5985
|
+
ancestorSchema$ids
|
|
5986
|
+
} = (0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_16__.locate)(selector, referenceAsSchema));
|
|
5987
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(referencedElement);
|
|
5612
5988
|
} else {
|
|
5613
5989
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
5614
5990
|
retrievalURI = this.toBaseURI($refBaseURI);
|
|
@@ -5625,11 +6001,14 @@ class Arazzo1DereferenceVisitor {
|
|
|
5625
6001
|
// skip traversing this schema element but traverse all its child elements
|
|
5626
6002
|
return;
|
|
5627
6003
|
}
|
|
5628
|
-
reference = await this.toReference(
|
|
5629
|
-
const selector =
|
|
5630
|
-
const referenceAsSchema = (0,
|
|
5631
|
-
|
|
5632
|
-
|
|
6004
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_24__.unsanitize($refBaseURI));
|
|
6005
|
+
const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_11__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
6006
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(reference.value.result);
|
|
6007
|
+
({
|
|
6008
|
+
element: referencedElement,
|
|
6009
|
+
ancestorSchema$ids
|
|
6010
|
+
} = (0,_openapi_3_1_selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_18__.locate)(referenceAsSchema, selector));
|
|
6011
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.maybeRefractToJSONSchemaElement)(referencedElement);
|
|
5633
6012
|
}
|
|
5634
6013
|
} else {
|
|
5635
6014
|
throw error;
|
|
@@ -5639,14 +6018,14 @@ class Arazzo1DereferenceVisitor {
|
|
|
5639
6018
|
|
|
5640
6019
|
// detect direct or indirect reference
|
|
5641
6020
|
if (referencingElement === referencedElement) {
|
|
5642
|
-
throw new
|
|
5643
|
-
$ref: (0,
|
|
6021
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__["default"]('Recursive JSON Schema reference detected', {
|
|
6022
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref)
|
|
5644
6023
|
});
|
|
5645
6024
|
}
|
|
5646
6025
|
|
|
5647
6026
|
// detect maximum depth of dereferencing
|
|
5648
6027
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
5649
|
-
throw new
|
|
6028
|
+
throw new _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_22__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
5650
6029
|
maxDepth: this.options.dereference.maxDepth,
|
|
5651
6030
|
uri: this.reference.uri
|
|
5652
6031
|
});
|
|
@@ -5657,14 +6036,14 @@ class Arazzo1DereferenceVisitor {
|
|
|
5657
6036
|
if (ancestorsLineage.includes(referencedElement)) {
|
|
5658
6037
|
reference.refSet.circular = true;
|
|
5659
6038
|
if (this.options.dereference.circular === 'error') {
|
|
5660
|
-
throw new
|
|
5661
|
-
$ref: (0,
|
|
6039
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_8__["default"]('Circular reference detected', {
|
|
6040
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref)
|
|
5662
6041
|
});
|
|
5663
6042
|
} else if (this.options.dereference.circular === 'replace') {
|
|
5664
|
-
const refElement = new
|
|
6043
|
+
const refElement = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__["default"]($refBaseURI, {
|
|
5665
6044
|
type: referencingElement.element,
|
|
5666
6045
|
uri: reference.uri,
|
|
5667
|
-
$ref: (0,
|
|
6046
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref)
|
|
5668
6047
|
});
|
|
5669
6048
|
const replacer = this.options.dereference.strategyOpts['arazzo-1']?.circularReplacer ?? this.options.dereference.circularReplacer;
|
|
5670
6049
|
const replacement = replacer(refElement);
|
|
@@ -5683,9 +6062,13 @@ class Arazzo1DereferenceVisitor {
|
|
|
5683
6062
|
* 3. Fragment is a JSON Schema with $ref field. We need to follow it to get the eventual value
|
|
5684
6063
|
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
|
|
5685
6064
|
*/
|
|
5686
|
-
const isNonEntryDocument =
|
|
6065
|
+
const isNonEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_24__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
|
|
5687
6066
|
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
|
|
5688
|
-
|
|
6067
|
+
// content transplanted into the referencing site is traversed under that
|
|
6068
|
+
// site's $id chain; a fragment enclosed by a different chain has its own
|
|
6069
|
+
// $refs resolved in place first, by a nested visitor seeded with that chain
|
|
6070
|
+
const hasDifferentEnclosingBase = (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.resolveSchema$ids)((0,_util_ts__WEBPACK_IMPORTED_MODULE_20__.resolveArazzo$selfField)(reference.uri, reference.value.result), ancestorSchema$ids) !== (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.resolveSchema$ids)(rootBaseURI, (0,_openapi_3_1_util_ts__WEBPACK_IMPORTED_MODULE_19__.schema$idsOf)(path.getAncestorNodes().reverse()));
|
|
6071
|
+
if ((isExternalReference || isNonEntryDocument || hasDifferentEnclosingBase || (0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_12__.isJSONSchemaElement)(referencedElement) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(referencedElement.$ref) || shouldDetectCircular && !this.visited.has(referencedElement)) && !ancestorsLineage.includesCycle(referencedElement)) {
|
|
5689
6072
|
if (shouldDetectCircular) {
|
|
5690
6073
|
this.visited.add(referencedElement);
|
|
5691
6074
|
}
|
|
@@ -5696,10 +6079,12 @@ class Arazzo1DereferenceVisitor {
|
|
|
5696
6079
|
reference,
|
|
5697
6080
|
indirections: [...this.indirections],
|
|
5698
6081
|
options: this.options,
|
|
6082
|
+
schema$idIndex: this.schema$idIndex,
|
|
5699
6083
|
visited: this.visited,
|
|
5700
|
-
ancestors: ancestorsLineage
|
|
6084
|
+
ancestors: ancestorsLineage,
|
|
6085
|
+
ancestorSchema$ids
|
|
5701
6086
|
});
|
|
5702
|
-
referencedElement = await (0,
|
|
6087
|
+
referencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_9__.traverseAsync)(referencedElement, visitor, {
|
|
5703
6088
|
mutable: true,
|
|
5704
6089
|
skipVisited: 'skip'
|
|
5705
6090
|
});
|
|
@@ -5709,11 +6094,11 @@ class Arazzo1DereferenceVisitor {
|
|
|
5709
6094
|
}
|
|
5710
6095
|
|
|
5711
6096
|
// Boolean JSON Schemas
|
|
5712
|
-
if ((0,
|
|
5713
|
-
const booleanJsonSchemaElement = (0,
|
|
6097
|
+
if ((0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_13__.isBooleanJSONSchemaElement)(referencedElement)) {
|
|
6098
|
+
const booleanJsonSchemaElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(referencedElement);
|
|
5714
6099
|
// annotate referenced element with info about original referencing element
|
|
5715
6100
|
booleanJsonSchemaElement.meta.set('ref-fields', {
|
|
5716
|
-
$ref: (0,
|
|
6101
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref)
|
|
5717
6102
|
});
|
|
5718
6103
|
// annotate referenced element with info about origin
|
|
5719
6104
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
@@ -5726,17 +6111,17 @@ class Arazzo1DereferenceVisitor {
|
|
|
5726
6111
|
/**
|
|
5727
6112
|
* Creating a new version of JSON Schema by merging fields from referenced Schema with referencing one.
|
|
5728
6113
|
*/
|
|
5729
|
-
if ((0,
|
|
5730
|
-
const mergedElement = (0,
|
|
6114
|
+
if ((0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_12__.isJSONSchemaElement)(referencedElement)) {
|
|
6115
|
+
const mergedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneShallow)(referencedElement);
|
|
5731
6116
|
// existing keywords from referencing schema overrides ones from referenced schema
|
|
5732
6117
|
referencingElement.forEach((value, keyElement, item) => {
|
|
5733
|
-
mergedElement.remove((0,
|
|
6118
|
+
mergedElement.remove((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(keyElement));
|
|
5734
6119
|
mergedElement.content.push(item);
|
|
5735
6120
|
});
|
|
5736
6121
|
mergedElement.remove('$ref');
|
|
5737
6122
|
// annotate referenced element with info about original referencing element
|
|
5738
6123
|
mergedElement.meta.set('ref-fields', {
|
|
5739
|
-
$ref: (0,
|
|
6124
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref)
|
|
5740
6125
|
});
|
|
5741
6126
|
// annotate fragment with info about origin
|
|
5742
6127
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
@@ -5748,7 +6133,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
5748
6133
|
*/
|
|
5749
6134
|
path.replaceWith(referencedElement);
|
|
5750
6135
|
} catch (error) {
|
|
5751
|
-
const $ref = (0,
|
|
6136
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_6__["default"])(referencingElement.$ref);
|
|
5752
6137
|
this.handleError(`Error while dereferencing Schema Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
5753
6138
|
} finally {
|
|
5754
6139
|
if (this.indirections.length > indirectionsSize) this.indirections.pop();
|
|
@@ -8030,6 +8415,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8030
8415
|
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(98979);
|
|
8031
8416
|
/* harmony import */ var _ReferenceSet_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(24131);
|
|
8032
8417
|
/* harmony import */ var _visitor_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4224);
|
|
8418
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(60888);
|
|
8419
|
+
|
|
8033
8420
|
|
|
8034
8421
|
|
|
8035
8422
|
|
|
@@ -8093,7 +8480,8 @@ class OpenAPI3_1DereferenceStrategy extends _DereferenceStrategy_ts__WEBPACK_IMP
|
|
|
8093
8480
|
const shouldDetectCircular = ['error', 'replace'].includes(options.dereference.circular);
|
|
8094
8481
|
const visitor = new _visitor_ts__WEBPACK_IMPORTED_MODULE_8__["default"]({
|
|
8095
8482
|
reference: reference,
|
|
8096
|
-
options
|
|
8483
|
+
options,
|
|
8484
|
+
ancestorSchema$ids: (0,_util_ts__WEBPACK_IMPORTED_MODULE_10__.detachedRootSchema$ids)(refSet.rootRef.value.result)
|
|
8097
8485
|
});
|
|
8098
8486
|
const dereferencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_2__.traverseAsync)(refSet.rootRef.value, visitor, {
|
|
8099
8487
|
mutable: true,
|
|
@@ -8139,9 +8527,9 @@ class OpenAPI3_1DereferenceStrategy extends _DereferenceStrategy_ts__WEBPACK_IMP
|
|
|
8139
8527
|
"use strict";
|
|
8140
8528
|
__webpack_require__.r(__webpack_exports__);
|
|
8141
8529
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
8142
|
-
/* harmony export */ EvaluationJsonSchema$anchorError: () => (/* reexport safe */ _errors_EvaluationJsonSchema$
|
|
8143
|
-
/* harmony export */ InvalidJsonSchema$anchorError: () => (/* reexport safe */ _errors_InvalidJsonSchema$
|
|
8144
|
-
/* harmony export */ JsonSchema$anchorError: () => (/* reexport safe */ _errors_JsonSchema$
|
|
8530
|
+
/* harmony export */ EvaluationJsonSchema$anchorError: () => (/* reexport safe */ _errors_EvaluationJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_7__["default"]),
|
|
8531
|
+
/* harmony export */ InvalidJsonSchema$anchorError: () => (/* reexport safe */ _errors_InvalidJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_8__["default"]),
|
|
8532
|
+
/* harmony export */ JsonSchema$anchorError: () => (/* reexport safe */ _errors_JsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_9__["default"])
|
|
8145
8533
|
/* harmony export */ });
|
|
8146
8534
|
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33031);
|
|
8147
8535
|
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(64988);
|
|
@@ -8149,9 +8537,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8149
8537
|
/* harmony import */ var _speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80796);
|
|
8150
8538
|
/* harmony import */ var _speclynx_apidom_ns_json_schema_2020_12__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7557);
|
|
8151
8539
|
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(30658);
|
|
8152
|
-
/* harmony import */ var
|
|
8153
|
-
/* harmony import */ var
|
|
8154
|
-
/* harmony import */ var
|
|
8540
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(60888);
|
|
8541
|
+
/* harmony import */ var _errors_EvaluationJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(21376);
|
|
8542
|
+
/* harmony import */ var _errors_InvalidJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(56335);
|
|
8543
|
+
/* harmony import */ var _errors_JsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(75578);
|
|
8544
|
+
|
|
8155
8545
|
|
|
8156
8546
|
|
|
8157
8547
|
|
|
@@ -8186,35 +8576,83 @@ const uriToAnchor = uri => {
|
|
|
8186
8576
|
*/
|
|
8187
8577
|
const parse = anchor => {
|
|
8188
8578
|
if (!isAnchor(anchor)) {
|
|
8189
|
-
throw new _errors_InvalidJsonSchema$
|
|
8579
|
+
throw new _errors_InvalidJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_8__["default"](anchor);
|
|
8190
8580
|
}
|
|
8191
8581
|
return anchor;
|
|
8192
8582
|
};
|
|
8193
8583
|
|
|
8194
8584
|
/**
|
|
8195
|
-
*
|
|
8585
|
+
* Locates the schema identified by JSON Schema $anchor within ApiDOM fragment,
|
|
8586
|
+
* along with the `$id`s of the schemas enclosing it, the search root included.
|
|
8196
8587
|
* @public
|
|
8197
8588
|
*/
|
|
8198
|
-
const
|
|
8589
|
+
const locate = (anchor, element) => {
|
|
8199
8590
|
const token = parse(anchor);
|
|
8200
8591
|
const resultPath = (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_3__.find)(element,
|
|
8201
8592
|
// @ts-ignore
|
|
8202
8593
|
path => (0,_speclynx_apidom_ns_json_schema_2020_12__WEBPACK_IMPORTED_MODULE_4__.isJSONSchemaElement)(path.node) && (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(path.node.$anchor) === token);
|
|
8203
8594
|
if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(resultPath)) {
|
|
8204
|
-
throw new _errors_EvaluationJsonSchema$
|
|
8595
|
+
throw new _errors_EvaluationJsonSchema$anchorError_ts__WEBPACK_IMPORTED_MODULE_7__["default"](`Evaluation failed on token: "${token}"`);
|
|
8205
8596
|
}
|
|
8206
|
-
return
|
|
8597
|
+
return {
|
|
8598
|
+
element: resultPath.node,
|
|
8599
|
+
ancestorSchema$ids: (0,_util_ts__WEBPACK_IMPORTED_MODULE_6__.schema$idsOf)(resultPath.getAncestorNodes().reverse())
|
|
8600
|
+
};
|
|
8207
8601
|
};
|
|
8208
8602
|
|
|
8603
|
+
/**
|
|
8604
|
+
* Evaluates JSON Schema $anchor against ApiDOM fragment.
|
|
8605
|
+
* @public
|
|
8606
|
+
*/
|
|
8607
|
+
const evaluate = (anchor, element) => locate(anchor, element).element;
|
|
8608
|
+
|
|
8209
8609
|
|
|
8210
8610
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
8211
8611
|
/* harmony export */ "evaluate", 0, /* binding */ evaluate,
|
|
8212
8612
|
/* harmony export */ "isAnchor", 0, /* binding */ isAnchor,
|
|
8613
|
+
/* harmony export */ "locate", 0, /* binding */ locate,
|
|
8213
8614
|
/* harmony export */ "parse", 0, /* binding */ parse,
|
|
8214
8615
|
/* harmony export */ "uriToAnchor", 0, /* binding */ uriToAnchor
|
|
8215
8616
|
/* harmony export */ ]);
|
|
8216
8617
|
|
|
8217
8618
|
|
|
8619
|
+
/***/ },
|
|
8620
|
+
|
|
8621
|
+
/***/ 37517
|
|
8622
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8623
|
+
|
|
8624
|
+
"use strict";
|
|
8625
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8626
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12020);
|
|
8627
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(60888);
|
|
8628
|
+
|
|
8629
|
+
|
|
8630
|
+
|
|
8631
|
+
/**
|
|
8632
|
+
* Locates the element addressed by JSON Pointer within ApiDOM fragment, along
|
|
8633
|
+
* with the `$id`s of the schemas enclosing it: the elements the pointer walks
|
|
8634
|
+
* through on its way to the target, the search root included.
|
|
8635
|
+
*/
|
|
8636
|
+
const locate = (element, jsonPointer) => {
|
|
8637
|
+
const trace = {
|
|
8638
|
+
steps: []
|
|
8639
|
+
};
|
|
8640
|
+
const result = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_0__.evaluate)(element, jsonPointer, {
|
|
8641
|
+
trace
|
|
8642
|
+
});
|
|
8643
|
+
|
|
8644
|
+
// each step's input is the node the token was applied to, so the inputs are
|
|
8645
|
+
// exactly the walked nodes minus the target
|
|
8646
|
+
return {
|
|
8647
|
+
element: result,
|
|
8648
|
+
ancestorSchema$ids: (0,_util_ts__WEBPACK_IMPORTED_MODULE_1__.schema$idsOf)(trace.steps.map(step => step.input))
|
|
8649
|
+
};
|
|
8650
|
+
};
|
|
8651
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
8652
|
+
/* harmony export */ "locate", 0, /* binding */ locate
|
|
8653
|
+
/* harmony export */ ]);
|
|
8654
|
+
|
|
8655
|
+
|
|
8218
8656
|
/***/ },
|
|
8219
8657
|
|
|
8220
8658
|
/***/ 56481
|
|
@@ -8223,19 +8661,18 @@ const evaluate = (anchor, element) => {
|
|
|
8223
8661
|
"use strict";
|
|
8224
8662
|
__webpack_require__.r(__webpack_exports__);
|
|
8225
8663
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
8226
|
-
/* harmony export */ EvaluationJsonSchemaUriError: () => (/* reexport safe */
|
|
8227
|
-
/* harmony export */ JsonSchemaUriError: () => (/* reexport safe */
|
|
8664
|
+
/* harmony export */ EvaluationJsonSchemaUriError: () => (/* reexport safe */ _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_4__["default"]),
|
|
8665
|
+
/* harmony export */ JsonSchemaUriError: () => (/* reexport safe */ _errors_JsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_8__["default"])
|
|
8228
8666
|
/* harmony export */ });
|
|
8229
8667
|
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33031);
|
|
8230
8668
|
/* harmony import */ var _speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(80796);
|
|
8231
|
-
/* harmony import */ var
|
|
8232
|
-
/* harmony import */ var
|
|
8233
|
-
/* harmony import */ var
|
|
8234
|
-
/* harmony import */ var
|
|
8235
|
-
/* harmony import */ var
|
|
8236
|
-
/* harmony import */ var
|
|
8237
|
-
/* harmony import */ var
|
|
8238
|
-
/* harmony import */ var _errors_JsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(51651);
|
|
8669
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(61198);
|
|
8670
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30658);
|
|
8671
|
+
/* harmony import */ var _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(44477);
|
|
8672
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(60888);
|
|
8673
|
+
/* harmony import */ var _$anchor_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(32054);
|
|
8674
|
+
/* harmony import */ var _json_pointer_ts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(37517);
|
|
8675
|
+
/* harmony import */ var _errors_JsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(51651);
|
|
8239
8676
|
|
|
8240
8677
|
|
|
8241
8678
|
|
|
@@ -8246,41 +8683,68 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8246
8683
|
|
|
8247
8684
|
|
|
8248
8685
|
/**
|
|
8249
|
-
*
|
|
8686
|
+
* Index of `$id`-bearing schemas per indexed element (a document root, or the
|
|
8687
|
+
* fragment a visitor traverses). Each entry pairs a schema with the `$id`s of its
|
|
8688
|
+
* enclosing schema resources (outermost first, including its own). The index is
|
|
8689
|
+
* populated once per element and never refreshed, so callers scope it
|
|
8690
|
+
* to a single dereference/bundle run instead of sharing it globally. Within a run the
|
|
8691
|
+
* `$id` graph of an indexed document is stable: the bundle strategies mutate deep
|
|
8692
|
+
* clones and place components only after the entry traversal ends, and the
|
|
8693
|
+
* dereference strategies only replace `$ref`-bearing schemas.
|
|
8250
8694
|
* @public
|
|
8251
8695
|
*/
|
|
8252
|
-
const evaluate = (uri, element) => {
|
|
8253
|
-
const {
|
|
8254
|
-
cache
|
|
8255
|
-
} = evaluate;
|
|
8256
|
-
const uriStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_5__.stripHash(uri);
|
|
8257
|
-
const isJSONSchemaElementWith$id = path => (0,_speclynx_apidom_ns_json_schema_2020_12__WEBPACK_IMPORTED_MODULE_2__.isJSONSchemaElement)(path.node) && typeof path.node.$id !== 'undefined';
|
|
8258
8696
|
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
cache.set(element, schemaObjectPaths.map(path => path.node));
|
|
8263
|
-
}
|
|
8697
|
+
/**
|
|
8698
|
+
* @public
|
|
8699
|
+
*/
|
|
8264
8700
|
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8701
|
+
const indexSchema$ids = element => (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_1__.filter)(element, path => (0,_util_ts__WEBPACK_IMPORTED_MODULE_5__.isJSONSchemaElementWith$id)(path.node)).map(path => ({
|
|
8702
|
+
schema: path.node,
|
|
8703
|
+
$ids: (0,_util_ts__WEBPACK_IMPORTED_MODULE_5__.collectSchema$ids)(path)
|
|
8704
|
+
}));
|
|
8705
|
+
|
|
8706
|
+
/**
|
|
8707
|
+
* Locates the schema addressed by JSON Schema $ref containing unknown URI within
|
|
8708
|
+
* ApiDOM fragment, along with the `$id`s of the schemas enclosing it.
|
|
8709
|
+
* @public
|
|
8710
|
+
*/
|
|
8711
|
+
const locate = (uri, element, options = {}) => {
|
|
8712
|
+
const uriStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_3__.stripHash(uri);
|
|
8713
|
+
const {
|
|
8714
|
+
baseURI = uriStrippedHash,
|
|
8715
|
+
index = new WeakMap()
|
|
8716
|
+
} = options;
|
|
8717
|
+
if (!index.has(element)) {
|
|
8718
|
+
index.set(element, indexSchema$ids(element));
|
|
8272
8719
|
}
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8720
|
+
|
|
8721
|
+
// search for the schema whose canonical URI matches
|
|
8722
|
+
const entry = index.get(element).find(({
|
|
8723
|
+
$ids
|
|
8724
|
+
}) => (0,_util_ts__WEBPACK_IMPORTED_MODULE_5__.resolveSchema$ids)(baseURI, $ids) === uriStrippedHash);
|
|
8725
|
+
if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_0__["default"])(entry)) {
|
|
8726
|
+
throw new _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_4__["default"](`Evaluation failed on URI: "${uri}"`);
|
|
8276
8727
|
}
|
|
8277
|
-
|
|
8728
|
+
|
|
8729
|
+
// the fragment is resolved within the matched schema, whose own $id is the
|
|
8730
|
+
// last of its chain; the fragment walk contributes it again when descending
|
|
8731
|
+
const fragmentLocation = (0,_$anchor_ts__WEBPACK_IMPORTED_MODULE_6__.isAnchor)((0,_$anchor_ts__WEBPACK_IMPORTED_MODULE_6__.uriToAnchor)(uri)) ? (0,_$anchor_ts__WEBPACK_IMPORTED_MODULE_6__.locate)((0,_$anchor_ts__WEBPACK_IMPORTED_MODULE_6__.uriToAnchor)(uri), entry.schema) : (0,_json_pointer_ts__WEBPACK_IMPORTED_MODULE_7__.locate)(entry.schema, _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_2__.URIFragmentIdentifier.fromURIReference(uri));
|
|
8732
|
+
return {
|
|
8733
|
+
element: fragmentLocation.element,
|
|
8734
|
+
ancestorSchema$ids: [...entry.$ids.slice(0, -1), ...fragmentLocation.ancestorSchema$ids]
|
|
8735
|
+
};
|
|
8278
8736
|
};
|
|
8279
|
-
|
|
8737
|
+
|
|
8738
|
+
/**
|
|
8739
|
+
* Evaluates JSON Schema $ref containing unknown URI against ApiDOM fragment.
|
|
8740
|
+
* @public
|
|
8741
|
+
*/
|
|
8742
|
+
const evaluate = (uri, element, options = {}) => locate(uri, element, options).element;
|
|
8280
8743
|
|
|
8281
8744
|
|
|
8282
8745
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
8283
|
-
/* harmony export */ "evaluate", 0, /* binding */ evaluate
|
|
8746
|
+
/* harmony export */ "evaluate", 0, /* binding */ evaluate,
|
|
8747
|
+
/* harmony export */ "locate", 0, /* binding */ locate
|
|
8284
8748
|
/* harmony export */ ]);
|
|
8285
8749
|
|
|
8286
8750
|
|
|
@@ -8292,10 +8756,14 @@ evaluate.cache = new WeakMap();
|
|
|
8292
8756
|
"use strict";
|
|
8293
8757
|
__webpack_require__.r(__webpack_exports__);
|
|
8294
8758
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(97797);
|
|
8295
|
-
/* harmony import */ var
|
|
8296
|
-
/* harmony import */ var
|
|
8297
|
-
/* harmony import */ var
|
|
8298
|
-
/* harmony import */ var
|
|
8759
|
+
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(85102);
|
|
8760
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(25162);
|
|
8761
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(44673);
|
|
8762
|
+
/* harmony import */ var _speclynx_apidom_ns_json_schema_2020_12__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7557);
|
|
8763
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(24329);
|
|
8764
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(30658);
|
|
8765
|
+
|
|
8766
|
+
|
|
8299
8767
|
|
|
8300
8768
|
|
|
8301
8769
|
|
|
@@ -8303,31 +8771,84 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8303
8771
|
|
|
8304
8772
|
|
|
8305
8773
|
/**
|
|
8774
|
+
* A schema located within a document, together with the `$id`s of the JSON Schema
|
|
8775
|
+
* elements enclosing it (outermost first; the located schema's own `$id` excluded).
|
|
8306
8776
|
* @public
|
|
8307
8777
|
*/
|
|
8308
|
-
|
|
8309
|
-
|
|
8778
|
+
|
|
8779
|
+
/**
|
|
8780
|
+
* Whether the element is a JSON Schema element declaring a `$id`.
|
|
8781
|
+
*/
|
|
8782
|
+
const isJSONSchemaElementWith$id = element => (0,_speclynx_apidom_ns_json_schema_2020_12__WEBPACK_IMPORTED_MODULE_4__.isJSONSchemaElement)(element) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(element.$id);
|
|
8783
|
+
|
|
8784
|
+
/**
|
|
8785
|
+
* `$id`s declared by the JSON Schema elements among `nodes`, in order.
|
|
8786
|
+
*/
|
|
8787
|
+
const schema$idsOf = nodes => nodes.filter(isJSONSchemaElementWith$id).map(node => (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(node.$id));
|
|
8788
|
+
|
|
8789
|
+
/**
|
|
8790
|
+
* `$id`s of the JSON Schema elements on `path` (outermost first, the node itself
|
|
8791
|
+
* included). The `$id`s are read from the elements themselves rather than from
|
|
8792
|
+
* refraction-time metadata, so a `$id` assigned after refraction (e.g. by the
|
|
8793
|
+
* bundler) is honored.
|
|
8794
|
+
*/
|
|
8795
|
+
const collectSchema$ids = path => schema$idsOf([...path.getAncestorNodes().reverse(), path.node]);
|
|
8796
|
+
|
|
8797
|
+
/**
|
|
8798
|
+
* `$id`s of the schemas enclosing a traversal root that is a fragment detached
|
|
8799
|
+
* from its document, read from the `ancestorsSchemaIdentifiers` meta the JSON
|
|
8800
|
+
* Schema refractors record. The meta also carries the root's own `$id`, which
|
|
8801
|
+
* the ancestor walk contributes itself, so it is dropped. A detached fragment
|
|
8802
|
+
* has no live ancestors, so the meta is the only carrier of its lexical
|
|
8803
|
+
* context; this is the one reader of it the refractors must keep serving.
|
|
8804
|
+
*/
|
|
8805
|
+
const detachedRootSchema$ids = root => {
|
|
8806
|
+
const meta = root?.meta.get('ancestorsSchemaIdentifiers');
|
|
8807
|
+
const $ids = Array.isArray(meta) ? meta.filter(ramda_adjunct__WEBPACK_IMPORTED_MODULE_1__["default"]) : [];
|
|
8808
|
+
const own$id = isJSONSchemaElementWith$id(root) ? (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(root.$id) : undefined;
|
|
8809
|
+
return $ids.length > 0 && $ids.at(-1) === own$id ? $ids.slice(0, -1) : $ids;
|
|
8810
|
+
};
|
|
8811
|
+
|
|
8812
|
+
/**
|
|
8813
|
+
* Resolves a chain of `$id`s (outermost first) against `baseURI`, each `$id`
|
|
8814
|
+
* refining the base the next one resolves against.
|
|
8815
|
+
*/
|
|
8816
|
+
const resolveSchema$ids = (baseURI, $ids) => (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])((acc, $id) => _util_url_ts__WEBPACK_IMPORTED_MODULE_6__.resolve(acc, _util_url_ts__WEBPACK_IMPORTED_MODULE_6__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_6__.stripHash($id))), baseURI, $ids);
|
|
8817
|
+
|
|
8818
|
+
/**
|
|
8819
|
+
* Resolves the base URI of the schema at `path`: `baseURI` (the base URI in
|
|
8820
|
+
* effect at the traversal root) refined by each `$id` on the schema's ancestor
|
|
8821
|
+
* chain in turn, the schema's own `$id` included.
|
|
8822
|
+
*/
|
|
8823
|
+
const resolveSchemaBaseURI = (baseURI, path) => resolveSchema$ids(baseURI, collectSchema$ids(path));
|
|
8824
|
+
|
|
8825
|
+
/**
|
|
8826
|
+
* Resolves the `$ref` of the schema against its base URI (see
|
|
8827
|
+
* `resolveSchemaBaseURI`), or returns `undefined` when the schema has no string `$ref`.
|
|
8828
|
+
*
|
|
8829
|
+
* @public
|
|
8830
|
+
*/
|
|
8831
|
+
const resolveSchema$refField = (schemaBaseURI, schemaElement) => {
|
|
8832
|
+
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(schemaElement.$ref)) {
|
|
8310
8833
|
return undefined;
|
|
8311
8834
|
}
|
|
8312
|
-
const
|
|
8313
|
-
const
|
|
8314
|
-
const $refBaseURI = (
|
|
8315
|
-
return _util_url_ts__WEBPACK_IMPORTED_MODULE_4__.resolve(acc, _util_url_ts__WEBPACK_IMPORTED_MODULE_4__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_4__.stripHash(uri)));
|
|
8316
|
-
}, retrievalURI, [...ancestorsSchemaIdentifiers, (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_2__["default"])(schemaElement.$ref)]);
|
|
8835
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(schemaElement.$ref);
|
|
8836
|
+
const hash = _util_url_ts__WEBPACK_IMPORTED_MODULE_6__.getHash($ref);
|
|
8837
|
+
const $refBaseURI = resolveSchema$ids(schemaBaseURI, [$ref]);
|
|
8317
8838
|
return `${$refBaseURI}${hash === '#' ? '' : hash}`;
|
|
8318
8839
|
};
|
|
8319
8840
|
|
|
8320
8841
|
/**
|
|
8842
|
+
* Resolves the `$id` of the schema against `baseURI`, the base URI in effect
|
|
8843
|
+
* where the schema sits, or returns `undefined` when the schema declares no string `$id`.
|
|
8844
|
+
*
|
|
8321
8845
|
* @public
|
|
8322
8846
|
*/
|
|
8323
|
-
const resolveSchema$idField = (
|
|
8324
|
-
if (
|
|
8847
|
+
const resolveSchema$idField = (baseURI, schemaElement) => {
|
|
8848
|
+
if (!(0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isStringElement)(schemaElement.$id)) {
|
|
8325
8849
|
return undefined;
|
|
8326
8850
|
}
|
|
8327
|
-
|
|
8328
|
-
return (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])((acc, $id) => {
|
|
8329
|
-
return _util_url_ts__WEBPACK_IMPORTED_MODULE_4__.resolve(acc, _util_url_ts__WEBPACK_IMPORTED_MODULE_4__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_4__.stripHash($id)));
|
|
8330
|
-
}, retrievalURI, ancestorsSchemaIdentifiers);
|
|
8851
|
+
return resolveSchema$ids(baseURI, [(0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_3__["default"])(schemaElement.$id)]);
|
|
8331
8852
|
};
|
|
8332
8853
|
|
|
8333
8854
|
/**
|
|
@@ -8337,7 +8858,7 @@ const refractToSchemaElement = element => {
|
|
|
8337
8858
|
if (refractToSchemaElement.cache.has(element)) {
|
|
8338
8859
|
return refractToSchemaElement.cache.get(element);
|
|
8339
8860
|
}
|
|
8340
|
-
const refracted = (0,
|
|
8861
|
+
const refracted = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_5__.refractSchema)(element);
|
|
8341
8862
|
refractToSchemaElement.cache.set(element, refracted);
|
|
8342
8863
|
return refracted;
|
|
8343
8864
|
};
|
|
@@ -8351,16 +8872,22 @@ const maybeRefractToSchemaElement = element => {
|
|
|
8351
8872
|
* Conditional version of refractToSchemaElement, that acts as an identity
|
|
8352
8873
|
* function for all non-primitive Element instances.
|
|
8353
8874
|
*/
|
|
8354
|
-
if ((0,
|
|
8875
|
+
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_2__.isPrimitiveElement)(element)) {
|
|
8355
8876
|
return refractToSchemaElement(element);
|
|
8356
8877
|
}
|
|
8357
8878
|
return element;
|
|
8358
8879
|
};
|
|
8359
8880
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, [
|
|
8881
|
+
/* harmony export */ "collectSchema$ids", 0, /* binding */ collectSchema$ids,
|
|
8882
|
+
/* harmony export */ "detachedRootSchema$ids", 0, /* binding */ detachedRootSchema$ids,
|
|
8883
|
+
/* harmony export */ "isJSONSchemaElementWith$id", 0, /* binding */ isJSONSchemaElementWith$id,
|
|
8360
8884
|
/* harmony export */ "maybeRefractToSchemaElement", 0, /* binding */ maybeRefractToSchemaElement,
|
|
8361
8885
|
/* harmony export */ "refractToSchemaElement", 0, /* binding */ refractToSchemaElement,
|
|
8362
8886
|
/* harmony export */ "resolveSchema$idField", 0, /* binding */ resolveSchema$idField,
|
|
8363
|
-
/* harmony export */ "resolveSchema$
|
|
8887
|
+
/* harmony export */ "resolveSchema$ids", 0, /* binding */ resolveSchema$ids,
|
|
8888
|
+
/* harmony export */ "resolveSchema$refField", 0, /* binding */ resolveSchema$refField,
|
|
8889
|
+
/* harmony export */ "resolveSchemaBaseURI", 0, /* binding */ resolveSchemaBaseURI,
|
|
8890
|
+
/* harmony export */ "schema$idsOf", 0, /* binding */ schema$idsOf
|
|
8364
8891
|
/* harmony export */ ]);
|
|
8365
8892
|
|
|
8366
8893
|
|
|
@@ -8375,31 +8902,34 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8375
8902
|
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6352);
|
|
8376
8903
|
/* harmony import */ var ramda_adjunct__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(33031);
|
|
8377
8904
|
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(25162);
|
|
8378
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
8379
|
-
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
8380
|
-
/* harmony import */ var
|
|
8381
|
-
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(
|
|
8382
|
-
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(
|
|
8383
|
-
/* harmony import */ var
|
|
8384
|
-
/* harmony import */ var
|
|
8385
|
-
/* harmony import */ var
|
|
8386
|
-
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
8387
|
-
/* harmony import */ var
|
|
8388
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(
|
|
8389
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(
|
|
8390
|
-
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(
|
|
8391
|
-
/* harmony import */ var
|
|
8392
|
-
/* harmony import */ var
|
|
8393
|
-
/* harmony import */ var
|
|
8394
|
-
/* harmony import */ var
|
|
8395
|
-
/* harmony import */ var
|
|
8396
|
-
/* harmony import */ var
|
|
8397
|
-
/* harmony import */ var
|
|
8398
|
-
/* harmony import */ var
|
|
8399
|
-
/* harmony import */ var
|
|
8400
|
-
/* harmony import */ var
|
|
8401
|
-
/* harmony import */ var
|
|
8402
|
-
/* harmony import */ var
|
|
8905
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(96911);
|
|
8906
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(12111);
|
|
8907
|
+
/* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(78894);
|
|
8908
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(37205);
|
|
8909
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(44673);
|
|
8910
|
+
/* harmony import */ var _speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(16280);
|
|
8911
|
+
/* harmony import */ var _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(44641);
|
|
8912
|
+
/* harmony import */ var _speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(80796);
|
|
8913
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(12020);
|
|
8914
|
+
/* harmony import */ var _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(61198);
|
|
8915
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(96681);
|
|
8916
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(21314);
|
|
8917
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(24329);
|
|
8918
|
+
/* harmony import */ var _speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(76332);
|
|
8919
|
+
/* harmony import */ var _selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(32054);
|
|
8920
|
+
/* harmony import */ var _selectors_uri_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(56481);
|
|
8921
|
+
/* harmony import */ var _selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(37517);
|
|
8922
|
+
/* harmony import */ var _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(37757);
|
|
8923
|
+
/* harmony import */ var _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(51325);
|
|
8924
|
+
/* harmony import */ var _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(8853);
|
|
8925
|
+
/* harmony import */ var _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(44477);
|
|
8926
|
+
/* harmony import */ var _util_url_ts__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(30658);
|
|
8927
|
+
/* harmony import */ var _parse_index_ts__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(35014);
|
|
8928
|
+
/* harmony import */ var _Reference_ts__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(98979);
|
|
8929
|
+
/* harmony import */ var _File_ts__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(10682);
|
|
8930
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(60888);
|
|
8931
|
+
/* harmony import */ var _util_ts__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(53429);
|
|
8932
|
+
|
|
8403
8933
|
|
|
8404
8934
|
|
|
8405
8935
|
|
|
@@ -8433,8 +8963,23 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8433
8963
|
reference;
|
|
8434
8964
|
options;
|
|
8435
8965
|
refractCache;
|
|
8966
|
+
|
|
8967
|
+
/**
|
|
8968
|
+
* Index of `$id`-bearing schemas per document, shared across nested visitors
|
|
8969
|
+
* of a single dereference run so it never outlives mutations of the documents.
|
|
8970
|
+
*/
|
|
8971
|
+
schema$idIndex;
|
|
8436
8972
|
visited;
|
|
8437
8973
|
|
|
8974
|
+
/**
|
|
8975
|
+
* `$id`s of the JSON Schema elements enclosing the traversal root within its
|
|
8976
|
+
* document (outermost first). Empty when the root is the document itself; a
|
|
8977
|
+
* nested visitor traversing a fragment is seeded with the `$id`s of the
|
|
8978
|
+
* schemas the fragment sits under, so the `$ref`s and `$id`s within resolve
|
|
8979
|
+
* against the same base as they would from the document root.
|
|
8980
|
+
*/
|
|
8981
|
+
ancestorSchema$ids;
|
|
8982
|
+
|
|
8438
8983
|
/**
|
|
8439
8984
|
* Tracks element ancestors across dive-deep traversal boundaries.
|
|
8440
8985
|
* Used for cycle detection: if a referenced element is found in
|
|
@@ -8446,29 +8991,33 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8446
8991
|
options,
|
|
8447
8992
|
indirections = [],
|
|
8448
8993
|
refractCache = new WeakMap(),
|
|
8449
|
-
|
|
8450
|
-
|
|
8994
|
+
schema$idIndex = new WeakMap(),
|
|
8995
|
+
ancestors = new _util_ts__WEBPACK_IMPORTED_MODULE_30__.AncestorLineage(),
|
|
8996
|
+
visited = new WeakSet(),
|
|
8997
|
+
ancestorSchema$ids = []
|
|
8451
8998
|
}) {
|
|
8452
8999
|
this.indirections = indirections;
|
|
8453
9000
|
this.reference = reference;
|
|
8454
9001
|
this.options = options;
|
|
8455
9002
|
this.refractCache = refractCache;
|
|
8456
|
-
this.
|
|
9003
|
+
this.schema$idIndex = schema$idIndex;
|
|
9004
|
+
this.ancestors = new _util_ts__WEBPACK_IMPORTED_MODULE_30__.AncestorLineage(...ancestors);
|
|
8457
9005
|
this.visited = visited;
|
|
9006
|
+
this.ancestorSchema$ids = ancestorSchema$ids;
|
|
8458
9007
|
}
|
|
8459
9008
|
toAncestorLineage(path) {
|
|
8460
9009
|
const ancestorNodes = path.getAncestorNodes();
|
|
8461
9010
|
const directAncestors = new Set(ancestorNodes.filter(_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isElement));
|
|
8462
|
-
const ancestorsLineage = new
|
|
9011
|
+
const ancestorsLineage = new _util_ts__WEBPACK_IMPORTED_MODULE_30__.AncestorLineage(...this.ancestors, directAncestors);
|
|
8463
9012
|
return [ancestorsLineage, directAncestors];
|
|
8464
9013
|
}
|
|
8465
9014
|
toBaseURI(uri) {
|
|
8466
|
-
return
|
|
9015
|
+
return _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.resolve(this.reference.uri, _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.sanitize(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(uri)));
|
|
8467
9016
|
}
|
|
8468
9017
|
async toReference(uri) {
|
|
8469
9018
|
// detect maximum depth of resolution
|
|
8470
9019
|
if (this.reference.depth >= this.options.resolve.maxDepth) {
|
|
8471
|
-
throw new
|
|
9020
|
+
throw new _errors_MaximumResolveDepthError_ts__WEBPACK_IMPORTED_MODULE_22__["default"](`Maximum resolution depth of ${this.options.resolve.maxDepth} has been exceeded by file "${this.reference.uri}"`, {
|
|
8472
9021
|
maxDepth: this.options.resolve.maxDepth,
|
|
8473
9022
|
uri: this.reference.uri
|
|
8474
9023
|
});
|
|
@@ -8482,7 +9031,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8482
9031
|
if (refSet.has(baseURI)) {
|
|
8483
9032
|
return refSet.find((0,ramda__WEBPACK_IMPORTED_MODULE_1__["default"])(baseURI, 'uri'));
|
|
8484
9033
|
}
|
|
8485
|
-
const parseResult = await (0,
|
|
9034
|
+
const parseResult = await (0,_parse_index_ts__WEBPACK_IMPORTED_MODULE_26__["default"])(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize(baseURI), {
|
|
8486
9035
|
...this.options,
|
|
8487
9036
|
parse: {
|
|
8488
9037
|
...this.options.parse,
|
|
@@ -8505,15 +9054,15 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8505
9054
|
// context always sees raw, unresolved elements and processes them with its own
|
|
8506
9055
|
// ancestors/indirections. The trade-off is that elements referenced by multiple
|
|
8507
9056
|
// documents would be resolved once per context instead of being reused.
|
|
8508
|
-
const mutableReference = new
|
|
9057
|
+
const mutableReference = new _Reference_ts__WEBPACK_IMPORTED_MODULE_27__["default"]({
|
|
8509
9058
|
uri: baseURI,
|
|
8510
|
-
value: this.options.dereference.immutable ? (0,
|
|
9059
|
+
value: this.options.dereference.immutable ? (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneDeep)(parseResult) : parseResult,
|
|
8511
9060
|
depth: this.reference.depth + 1
|
|
8512
9061
|
});
|
|
8513
9062
|
refSet.add(mutableReference);
|
|
8514
9063
|
if (this.options.dereference.immutable) {
|
|
8515
9064
|
// register new immutable reference with original parseResult
|
|
8516
|
-
const immutableReference = new
|
|
9065
|
+
const immutableReference = new _Reference_ts__WEBPACK_IMPORTED_MODULE_27__["default"]({
|
|
8517
9066
|
uri: `immutable://${baseURI}`,
|
|
8518
9067
|
value: parseResult,
|
|
8519
9068
|
depth: this.reference.depth + 1
|
|
@@ -8537,10 +9086,10 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8537
9086
|
const {
|
|
8538
9087
|
continueOnError
|
|
8539
9088
|
} = this.options.dereference;
|
|
8540
|
-
const isEntryDocument =
|
|
9089
|
+
const isEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.refSet?.rootRef?.uri ?? '') === this.reference.uri;
|
|
8541
9090
|
const uri = this.reference.uri;
|
|
8542
9091
|
const type = referencingElement.element;
|
|
8543
|
-
const codeFrame = (0,
|
|
9092
|
+
const codeFrame = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_9__["default"])(referencingElement);
|
|
8544
9093
|
|
|
8545
9094
|
// find element location by identity in the document tree.
|
|
8546
9095
|
// guarded: this.reference.value may not be a ParseResultElement or may lack a result.
|
|
@@ -8549,7 +9098,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8549
9098
|
let location;
|
|
8550
9099
|
const root = this.reference.value.result;
|
|
8551
9100
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isElement)(root)) {
|
|
8552
|
-
(0,
|
|
9101
|
+
(0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverse)(root, {
|
|
8553
9102
|
enter: p => {
|
|
8554
9103
|
if (p.node === referencingElement || this.refractCache.get(p.node) === referencingElement) {
|
|
8555
9104
|
location = p.formatPath();
|
|
@@ -8570,10 +9119,10 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8570
9119
|
|
|
8571
9120
|
// enrich existing error from nested visitor or create new one
|
|
8572
9121
|
let unresolvedError;
|
|
8573
|
-
if (error instanceof
|
|
9122
|
+
if (error instanceof _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_23__["default"]) {
|
|
8574
9123
|
// prefix relative locations for entries belonging to the referenced document
|
|
8575
9124
|
const refBaseURI = this.toBaseURI(refFieldValue);
|
|
8576
|
-
const fragment =
|
|
9125
|
+
const fragment = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference(refFieldValue);
|
|
8577
9126
|
if (fragment) {
|
|
8578
9127
|
if (refBaseURI === error.uri && error.location) {
|
|
8579
9128
|
error.location = fragment + error.location;
|
|
@@ -8586,7 +9135,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8586
9135
|
error.trace = [hop, ...error.trace];
|
|
8587
9136
|
unresolvedError = error;
|
|
8588
9137
|
} else {
|
|
8589
|
-
unresolvedError = new
|
|
9138
|
+
unresolvedError = new _errors_UnresolvableReferenceError_ts__WEBPACK_IMPORTED_MODULE_23__["default"](message, {
|
|
8590
9139
|
cause: error,
|
|
8591
9140
|
type,
|
|
8592
9141
|
uri,
|
|
@@ -8608,8 +9157,8 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8608
9157
|
path.skip();
|
|
8609
9158
|
return;
|
|
8610
9159
|
}
|
|
8611
|
-
const retrievalURI = this.toBaseURI((0,
|
|
8612
|
-
const isInternalReference =
|
|
9160
|
+
const retrievalURI = this.toBaseURI((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
9161
|
+
const isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
8613
9162
|
const isExternalReference = !isInternalReference;
|
|
8614
9163
|
|
|
8615
9164
|
// ignore resolving internal Reference Objects
|
|
@@ -8624,31 +9173,31 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8624
9173
|
path.skip();
|
|
8625
9174
|
return;
|
|
8626
9175
|
}
|
|
8627
|
-
const $refBaseURI =
|
|
9176
|
+
const $refBaseURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.resolve(retrievalURI, (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
8628
9177
|
const indirectionsSize = this.indirections.length;
|
|
8629
9178
|
try {
|
|
8630
|
-
const reference = await this.toReference((0,
|
|
9179
|
+
const reference = await this.toReference((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
8631
9180
|
this.indirections.push(referencingElement);
|
|
8632
|
-
const jsonPointer =
|
|
9181
|
+
const jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
8633
9182
|
|
|
8634
9183
|
// possibly non-semantic fragment
|
|
8635
|
-
let referencedElement = (0,
|
|
9184
|
+
let referencedElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
|
|
8636
9185
|
|
|
8637
9186
|
// applying semantics to a fragment
|
|
8638
9187
|
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
8639
|
-
if (referencedElement.element !== referencedElementType && !(0,
|
|
9188
|
+
if (referencedElement.element !== referencedElementType && !(0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isReferenceElement)(referencedElement)) {
|
|
8640
9189
|
if (this.refractCache.has(referencedElement)) {
|
|
8641
9190
|
referencedElement = this.refractCache.get(referencedElement);
|
|
8642
|
-
} else if ((0,
|
|
9191
|
+
} else if ((0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_15__.isReferenceLikeElement)(referencedElement)) {
|
|
8643
9192
|
// handling generic indirect references
|
|
8644
9193
|
const sourceElement = referencedElement;
|
|
8645
|
-
referencedElement = (0,
|
|
9194
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__.refractReference)(referencedElement);
|
|
8646
9195
|
referencedElement.meta.set('referenced-element', referencedElementType);
|
|
8647
9196
|
this.refractCache.set(sourceElement, referencedElement);
|
|
8648
9197
|
} else {
|
|
8649
9198
|
// handling direct references
|
|
8650
9199
|
const sourceElement = referencedElement;
|
|
8651
|
-
referencedElement = (0,
|
|
9200
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__["default"])(referencedElement, {
|
|
8652
9201
|
element: referencedElementType
|
|
8653
9202
|
});
|
|
8654
9203
|
this.refractCache.set(sourceElement, referencedElement);
|
|
@@ -8657,14 +9206,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8657
9206
|
|
|
8658
9207
|
// detect direct or indirect reference
|
|
8659
9208
|
if (referencingElement === referencedElement) {
|
|
8660
|
-
throw new
|
|
8661
|
-
$ref: (0,
|
|
9209
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Reference Object detected', {
|
|
9210
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8662
9211
|
});
|
|
8663
9212
|
}
|
|
8664
9213
|
|
|
8665
9214
|
// detect maximum depth of dereferencing
|
|
8666
9215
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
8667
|
-
throw new
|
|
9216
|
+
throw new _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_21__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
8668
9217
|
maxDepth: this.options.dereference.maxDepth,
|
|
8669
9218
|
uri: this.reference.uri
|
|
8670
9219
|
});
|
|
@@ -8675,14 +9224,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8675
9224
|
if (ancestorsLineage.includes(referencedElement)) {
|
|
8676
9225
|
reference.refSet.circular = true;
|
|
8677
9226
|
if (this.options.dereference.circular === 'error') {
|
|
8678
|
-
throw new
|
|
8679
|
-
$ref: (0,
|
|
9227
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected', {
|
|
9228
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8680
9229
|
});
|
|
8681
9230
|
} else if (this.options.dereference.circular === 'replace') {
|
|
8682
|
-
const refElement = new
|
|
9231
|
+
const refElement = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__["default"]($refBaseURI, {
|
|
8683
9232
|
type: referencingElement.element,
|
|
8684
9233
|
uri: reference.uri,
|
|
8685
|
-
$ref: (0,
|
|
9234
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8686
9235
|
});
|
|
8687
9236
|
const replacer = this.options.dereference.strategyOpts['openapi-3-1']?.circularReplacer ?? this.options.dereference.circularReplacer;
|
|
8688
9237
|
const replacement = replacer(refElement);
|
|
@@ -8701,9 +9250,9 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8701
9250
|
* 3. Fragment is a Reference Object. We need to follow it to get the eventual value
|
|
8702
9251
|
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
|
|
8703
9252
|
*/
|
|
8704
|
-
const isNonEntryDocument =
|
|
9253
|
+
const isNonEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
|
|
8705
9254
|
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
|
|
8706
|
-
if ((isExternalReference || isNonEntryDocument || (0,
|
|
9255
|
+
if ((isExternalReference || isNonEntryDocument || (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isReferenceElement)(referencedElement) || shouldDetectCircular && !this.visited.has(referencedElement)) && !ancestorsLineage.includesCycle(referencedElement)) {
|
|
8707
9256
|
if (shouldDetectCircular) {
|
|
8708
9257
|
this.visited.add(referencedElement);
|
|
8709
9258
|
}
|
|
@@ -8713,10 +9262,11 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8713
9262
|
indirections: [...this.indirections],
|
|
8714
9263
|
options: this.options,
|
|
8715
9264
|
refractCache: this.refractCache,
|
|
9265
|
+
schema$idIndex: this.schema$idIndex,
|
|
8716
9266
|
visited: this.visited,
|
|
8717
9267
|
ancestors: ancestorsLineage
|
|
8718
9268
|
});
|
|
8719
|
-
referencedElement = await (0,
|
|
9269
|
+
referencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(referencedElement, visitor, {
|
|
8720
9270
|
mutable: true,
|
|
8721
9271
|
skipVisited: 'skip'
|
|
8722
9272
|
});
|
|
@@ -8726,14 +9276,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8726
9276
|
/**
|
|
8727
9277
|
* Creating a new version of referenced element to avoid modifying the original one.
|
|
8728
9278
|
*/
|
|
8729
|
-
const mergedElement = (0,
|
|
9279
|
+
const mergedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(referencedElement);
|
|
8730
9280
|
// annotate fragment with info about original Reference element
|
|
8731
9281
|
mergedElement.meta.set('ref-fields', {
|
|
8732
|
-
$ref: (0,
|
|
9282
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref),
|
|
8733
9283
|
// @ts-ignore
|
|
8734
|
-
description: (0,
|
|
9284
|
+
description: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.description),
|
|
8735
9285
|
// @ts-ignore
|
|
8736
|
-
summary: (0,
|
|
9286
|
+
summary: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.summary)
|
|
8737
9287
|
});
|
|
8738
9288
|
// annotate fragment with info about origin and type
|
|
8739
9289
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
@@ -8741,7 +9291,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8741
9291
|
|
|
8742
9292
|
// override description and summary (outer has higher priority then inner)
|
|
8743
9293
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isObjectElement)(referencedElement) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isObjectElement)(mergedElement)) {
|
|
8744
|
-
const fields = (0,
|
|
9294
|
+
const fields = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_7__.fixedFields)(referencedElement, {
|
|
8745
9295
|
indexed: true
|
|
8746
9296
|
});
|
|
8747
9297
|
if (referencingElement.hasKey('description') && Object.hasOwn(fields, 'description')) {
|
|
@@ -8759,7 +9309,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8759
9309
|
*/
|
|
8760
9310
|
path.replaceWith(mergedElement);
|
|
8761
9311
|
} catch (error) {
|
|
8762
|
-
const $ref = (0,
|
|
9312
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref);
|
|
8763
9313
|
this.handleError(`Error while dereferencing Reference Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
8764
9314
|
} finally {
|
|
8765
9315
|
if (this.indirections.length > indirectionsSize) this.indirections.pop();
|
|
@@ -8778,8 +9328,8 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8778
9328
|
path.skip();
|
|
8779
9329
|
return;
|
|
8780
9330
|
}
|
|
8781
|
-
const retrievalURI = this.toBaseURI((0,
|
|
8782
|
-
const isInternalReference =
|
|
9331
|
+
const retrievalURI = this.toBaseURI((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
9332
|
+
const isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
8783
9333
|
const isExternalReference = !isInternalReference;
|
|
8784
9334
|
|
|
8785
9335
|
// ignore resolving internal Path Item Objects
|
|
@@ -8792,37 +9342,37 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8792
9342
|
// skip traversing this Path Item element but traverse all it's child elements
|
|
8793
9343
|
return;
|
|
8794
9344
|
}
|
|
8795
|
-
const $refBaseURI =
|
|
9345
|
+
const $refBaseURI = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.resolve(retrievalURI, (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
8796
9346
|
const indirectionsSize = this.indirections.length;
|
|
8797
9347
|
try {
|
|
8798
|
-
const reference = await this.toReference((0,
|
|
9348
|
+
const reference = await this.toReference((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref));
|
|
8799
9349
|
this.indirections.push(referencingElement);
|
|
8800
|
-
const jsonPointer =
|
|
9350
|
+
const jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
8801
9351
|
|
|
8802
9352
|
// possibly non-semantic referenced element
|
|
8803
|
-
let referencedElement = (0,
|
|
9353
|
+
let referencedElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
|
|
8804
9354
|
|
|
8805
9355
|
// applying semantics to a referenced element
|
|
8806
|
-
if (!(0,
|
|
9356
|
+
if (!(0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isPathItemElement)(referencedElement)) {
|
|
8807
9357
|
if (this.refractCache.has(referencedElement)) {
|
|
8808
9358
|
referencedElement = this.refractCache.get(referencedElement);
|
|
8809
9359
|
} else {
|
|
8810
9360
|
const sourceElement = referencedElement;
|
|
8811
|
-
referencedElement = (0,
|
|
9361
|
+
referencedElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__.refractPathItem)(referencedElement);
|
|
8812
9362
|
this.refractCache.set(sourceElement, referencedElement);
|
|
8813
9363
|
}
|
|
8814
9364
|
}
|
|
8815
9365
|
|
|
8816
9366
|
// detect direct or indirect reference
|
|
8817
9367
|
if (referencingElement === referencedElement) {
|
|
8818
|
-
throw new
|
|
8819
|
-
$ref: (0,
|
|
9368
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Path Item Object reference detected', {
|
|
9369
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8820
9370
|
});
|
|
8821
9371
|
}
|
|
8822
9372
|
|
|
8823
9373
|
// detect maximum depth of dereferencing
|
|
8824
9374
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
8825
|
-
throw new
|
|
9375
|
+
throw new _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_21__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
8826
9376
|
maxDepth: this.options.dereference.maxDepth,
|
|
8827
9377
|
uri: this.reference.uri
|
|
8828
9378
|
});
|
|
@@ -8833,14 +9383,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8833
9383
|
if (ancestorsLineage.includes(referencedElement)) {
|
|
8834
9384
|
reference.refSet.circular = true;
|
|
8835
9385
|
if (this.options.dereference.circular === 'error') {
|
|
8836
|
-
throw new
|
|
8837
|
-
$ref: (0,
|
|
9386
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected', {
|
|
9387
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8838
9388
|
});
|
|
8839
9389
|
} else if (this.options.dereference.circular === 'replace') {
|
|
8840
|
-
const refElement = new
|
|
9390
|
+
const refElement = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__["default"]($refBaseURI, {
|
|
8841
9391
|
type: referencingElement.element,
|
|
8842
9392
|
uri: reference.uri,
|
|
8843
|
-
$ref: (0,
|
|
9393
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8844
9394
|
});
|
|
8845
9395
|
const replacer = this.options.dereference.strategyOpts['openapi-3-1']?.circularReplacer ?? this.options.dereference.circularReplacer;
|
|
8846
9396
|
const replacement = replacer(refElement);
|
|
@@ -8859,9 +9409,9 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8859
9409
|
* 3. Fragment is a Path Item Object with $ref field. We need to follow it to get the eventual value
|
|
8860
9410
|
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
|
|
8861
9411
|
*/
|
|
8862
|
-
const isNonEntryDocument =
|
|
9412
|
+
const isNonEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
|
|
8863
9413
|
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
|
|
8864
|
-
if ((isExternalReference || isNonEntryDocument || (0,
|
|
9414
|
+
if ((isExternalReference || isNonEntryDocument || (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isPathItemElement)(referencedElement) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(referencedElement.$ref) || shouldDetectCircular && !this.visited.has(referencedElement)) && !ancestorsLineage.includesCycle(referencedElement)) {
|
|
8865
9415
|
if (shouldDetectCircular) {
|
|
8866
9416
|
this.visited.add(referencedElement);
|
|
8867
9417
|
}
|
|
@@ -8871,10 +9421,11 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8871
9421
|
indirections: [...this.indirections],
|
|
8872
9422
|
options: this.options,
|
|
8873
9423
|
refractCache: this.refractCache,
|
|
9424
|
+
schema$idIndex: this.schema$idIndex,
|
|
8874
9425
|
visited: this.visited,
|
|
8875
9426
|
ancestors: ancestorsLineage
|
|
8876
9427
|
});
|
|
8877
|
-
referencedElement = await (0,
|
|
9428
|
+
referencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(referencedElement, visitor, {
|
|
8878
9429
|
mutable: true,
|
|
8879
9430
|
skipVisited: 'skip'
|
|
8880
9431
|
});
|
|
@@ -8884,18 +9435,18 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8884
9435
|
/**
|
|
8885
9436
|
* Creating a new version of Path Item by merging fields from referenced Path Item with referencing one.
|
|
8886
9437
|
*/
|
|
8887
|
-
if ((0,
|
|
8888
|
-
const mergedElement = (0,
|
|
9438
|
+
if ((0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isPathItemElement)(referencedElement)) {
|
|
9439
|
+
const mergedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(referencedElement);
|
|
8889
9440
|
// existing keywords from referencing PathItemElement overrides ones from referenced element
|
|
8890
9441
|
referencingElement.forEach((value, keyElement, item) => {
|
|
8891
|
-
mergedElement.remove((0,
|
|
9442
|
+
mergedElement.remove((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(keyElement));
|
|
8892
9443
|
mergedElement.content.push(item);
|
|
8893
9444
|
});
|
|
8894
9445
|
mergedElement.remove('$ref');
|
|
8895
9446
|
|
|
8896
9447
|
// annotate referenced element with info about original referencing element
|
|
8897
9448
|
mergedElement.meta.set('ref-fields', {
|
|
8898
|
-
$ref: (0,
|
|
9449
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
8899
9450
|
});
|
|
8900
9451
|
// annotate referenced element with info about origin and type
|
|
8901
9452
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
@@ -8908,7 +9459,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8908
9459
|
*/
|
|
8909
9460
|
path.replaceWith(referencedElement);
|
|
8910
9461
|
} catch (error) {
|
|
8911
|
-
const $ref = (0,
|
|
9462
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref);
|
|
8912
9463
|
this.handleError(`Error while dereferencing Path Item Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
8913
9464
|
} finally {
|
|
8914
9465
|
if (this.indirections.length > indirectionsSize) this.indirections.pop();
|
|
@@ -8924,18 +9475,18 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8924
9475
|
|
|
8925
9476
|
// operationRef and operationId fields are mutually exclusive
|
|
8926
9477
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationRef) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationId)) {
|
|
8927
|
-
throw new
|
|
8928
|
-
operationRef: (0,
|
|
8929
|
-
operationId: (0,
|
|
9478
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('LinkElement operationRef and operationId fields are mutually exclusive', {
|
|
9479
|
+
operationRef: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef),
|
|
9480
|
+
operationId: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationId)
|
|
8930
9481
|
});
|
|
8931
9482
|
}
|
|
8932
9483
|
try {
|
|
8933
9484
|
let operationElement;
|
|
8934
9485
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationRef)) {
|
|
8935
9486
|
// possibly non-semantic referenced element
|
|
8936
|
-
const jsonPointer =
|
|
8937
|
-
const retrievalURI = this.toBaseURI((0,
|
|
8938
|
-
const isInternalReference =
|
|
9487
|
+
const jsonPointer = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef));
|
|
9488
|
+
const retrievalURI = this.toBaseURI((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef));
|
|
9489
|
+
const isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
8939
9490
|
const isExternalReference = !isInternalReference;
|
|
8940
9491
|
|
|
8941
9492
|
// ignore resolving internal Operation Object reference
|
|
@@ -8948,24 +9499,24 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8948
9499
|
// skip traversing this Link element but traverse all it's child elements
|
|
8949
9500
|
return;
|
|
8950
9501
|
}
|
|
8951
|
-
const reference = await this.toReference((0,
|
|
8952
|
-
operationElement = (0,
|
|
9502
|
+
const reference = await this.toReference((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef));
|
|
9503
|
+
operationElement = (0,_speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_12__.evaluate)(reference.value.result, jsonPointer);
|
|
8953
9504
|
// applying semantics to a referenced element
|
|
8954
|
-
if (!(0,
|
|
9505
|
+
if (!(0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isOperationElement)(operationElement)) {
|
|
8955
9506
|
if (this.refractCache.has(operationElement)) {
|
|
8956
9507
|
operationElement = this.refractCache.get(operationElement);
|
|
8957
9508
|
} else {
|
|
8958
9509
|
const sourceElement = operationElement;
|
|
8959
|
-
operationElement = (0,
|
|
9510
|
+
operationElement = (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_16__.refractOperation)(operationElement);
|
|
8960
9511
|
this.refractCache.set(sourceElement, operationElement);
|
|
8961
9512
|
}
|
|
8962
9513
|
}
|
|
8963
9514
|
// create shallow clone to be able to annotate with metadata
|
|
8964
|
-
operationElement = (0,
|
|
9515
|
+
operationElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(operationElement);
|
|
8965
9516
|
// annotate operation element with info about origin and type
|
|
8966
9517
|
operationElement.meta.set('ref-origin', reference.uri);
|
|
8967
9518
|
operationElement.meta.set('ref-type', linkElement.element);
|
|
8968
|
-
const linkElementCopy = (0,
|
|
9519
|
+
const linkElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(linkElement);
|
|
8969
9520
|
linkElementCopy.operationRef?.meta.set('operation', operationElement);
|
|
8970
9521
|
|
|
8971
9522
|
/**
|
|
@@ -8975,17 +9526,17 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8975
9526
|
return;
|
|
8976
9527
|
}
|
|
8977
9528
|
if ((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationId)) {
|
|
8978
|
-
const operationId = (0,
|
|
8979
|
-
const reference = await this.toReference(
|
|
8980
|
-
const operationPath = (0,
|
|
9529
|
+
const operationId = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationId);
|
|
9530
|
+
const reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize(this.reference.uri));
|
|
9531
|
+
const operationPath = (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.find)(reference.value.result, path => (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isOperationElement)(path.node) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isElement)(path.node.operationId) && path.node.operationId.equals(operationId));
|
|
8981
9532
|
operationElement = operationPath?.node;
|
|
8982
9533
|
// OperationElement not found by its operationId
|
|
8983
9534
|
if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_2__["default"])(operationElement)) {
|
|
8984
|
-
throw new
|
|
9535
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"](`OperationElement(operationId=${operationId}) not found`, {
|
|
8985
9536
|
operationId
|
|
8986
9537
|
});
|
|
8987
9538
|
}
|
|
8988
|
-
const linkElementCopy = (0,
|
|
9539
|
+
const linkElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(linkElement);
|
|
8989
9540
|
linkElementCopy.operationId?.meta.set('operation', operationElement);
|
|
8990
9541
|
|
|
8991
9542
|
/**
|
|
@@ -8995,7 +9546,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
8995
9546
|
}
|
|
8996
9547
|
} catch (error) {
|
|
8997
9548
|
const refFieldName = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationRef) ? 'operationRef' : 'operationId';
|
|
8998
|
-
const refFieldValue = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationRef) ? (0,
|
|
9549
|
+
const refFieldValue = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(linkElement.operationRef) ? (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationRef) : (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(linkElement.operationId);
|
|
8999
9550
|
this.handleError(`Error while dereferencing Link Object. Cannot resolve ${refFieldName} "${refFieldValue}": ${error.message}`, error, linkElement, refFieldName, refFieldValue, path);
|
|
9000
9551
|
}
|
|
9001
9552
|
}
|
|
@@ -9009,13 +9560,13 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9009
9560
|
|
|
9010
9561
|
// value and externalValue fields are mutually exclusive
|
|
9011
9562
|
if (exampleElement.hasKey('value') && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(exampleElement.externalValue)) {
|
|
9012
|
-
throw new
|
|
9013
|
-
value: (0,
|
|
9014
|
-
externalValue: (0,
|
|
9563
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('ExampleElement value and externalValue fields are mutually exclusive', {
|
|
9564
|
+
value: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.value),
|
|
9565
|
+
externalValue: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue)
|
|
9015
9566
|
});
|
|
9016
9567
|
}
|
|
9017
|
-
const retrievalURI = this.toBaseURI((0,
|
|
9018
|
-
const isInternalReference =
|
|
9568
|
+
const retrievalURI = this.toBaseURI((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue));
|
|
9569
|
+
const isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
9019
9570
|
const isExternalReference = !isInternalReference;
|
|
9020
9571
|
|
|
9021
9572
|
// ignore resolving internal Example Objects
|
|
@@ -9029,14 +9580,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9029
9580
|
return;
|
|
9030
9581
|
}
|
|
9031
9582
|
try {
|
|
9032
|
-
const reference = await this.toReference((0,
|
|
9583
|
+
const reference = await this.toReference((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue));
|
|
9033
9584
|
|
|
9034
9585
|
// shallow clone of the referenced element
|
|
9035
|
-
const valueElement = (0,
|
|
9586
|
+
const valueElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(reference.value.result);
|
|
9036
9587
|
// annotate element with info about origin and type
|
|
9037
9588
|
valueElement.meta.set('ref-origin', reference.uri);
|
|
9038
9589
|
valueElement.meta.set('ref-type', exampleElement.element);
|
|
9039
|
-
const exampleElementCopy = (0,
|
|
9590
|
+
const exampleElementCopy = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(exampleElement);
|
|
9040
9591
|
exampleElementCopy.value = valueElement;
|
|
9041
9592
|
|
|
9042
9593
|
/**
|
|
@@ -9044,7 +9595,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9044
9595
|
*/
|
|
9045
9596
|
path.replaceWith(exampleElementCopy);
|
|
9046
9597
|
} catch (error) {
|
|
9047
|
-
const externalValue = (0,
|
|
9598
|
+
const externalValue = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(exampleElement.externalValue);
|
|
9048
9599
|
this.handleError(`Error while dereferencing Example Object. Cannot resolve externalValue "${externalValue}": ${error.message}`, error, exampleElement, 'externalValue', externalValue, path);
|
|
9049
9600
|
}
|
|
9050
9601
|
}
|
|
@@ -9064,30 +9615,69 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9064
9615
|
const indirectionsSize = this.indirections.length;
|
|
9065
9616
|
try {
|
|
9066
9617
|
// compute baseURI using rules around $id and $ref keywords
|
|
9067
|
-
let reference = await this.toReference(
|
|
9618
|
+
let reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize(this.reference.uri));
|
|
9068
9619
|
let {
|
|
9069
9620
|
uri: retrievalURI
|
|
9070
9621
|
} = reference;
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
const
|
|
9622
|
+
// base URI in effect at the traversal root: the document base refined by
|
|
9623
|
+
// the $ids of the schemas enclosing the root when the root is a fragment
|
|
9624
|
+
const rootBaseURI = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.resolveSchema$ids)(retrievalURI, this.ancestorSchema$ids);
|
|
9625
|
+
const schemaBaseURI = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.resolveSchemaBaseURI)(rootBaseURI, path);
|
|
9626
|
+
const $refBaseURI = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.resolveSchema$refField)(schemaBaseURI, referencingElement);
|
|
9627
|
+
const $refBaseURIStrippedHash = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash($refBaseURI);
|
|
9628
|
+
const file = new _File_ts__WEBPACK_IMPORTED_MODULE_28__["default"]({
|
|
9074
9629
|
uri: $refBaseURIStrippedHash
|
|
9075
9630
|
});
|
|
9076
9631
|
const isUnknownURI = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(r => r.canRead(file), this.options.resolve.resolvers);
|
|
9077
9632
|
const isURL = !isUnknownURI;
|
|
9078
|
-
let isInternalReference =
|
|
9633
|
+
let isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === $refBaseURI;
|
|
9079
9634
|
let isExternalReference = !isInternalReference;
|
|
9080
9635
|
|
|
9081
9636
|
// determining reference, proper evaluation and selection mechanism
|
|
9082
9637
|
let referencedElement;
|
|
9638
|
+
// $ids of the schemas enclosing the referenced element within its document
|
|
9639
|
+
let ancestorSchema$ids;
|
|
9083
9640
|
try {
|
|
9084
9641
|
if (isUnknownURI || isURL) {
|
|
9085
9642
|
// we're dealing with canonical URI or URL with possible fragment
|
|
9086
9643
|
retrievalURI = this.toBaseURI($refBaseURI);
|
|
9087
9644
|
const selector = $refBaseURI;
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9645
|
+
// the fragment being traversed is searched before the whole document: a
|
|
9646
|
+
// fragment referenced from another document (a Response, Parameter, Path
|
|
9647
|
+
// Item, ...) is refracted with its own semantics, so the Schema Objects it
|
|
9648
|
+
// contains are indexed, whereas the referenced document as a whole is
|
|
9649
|
+
// parsed generically and refracted as a bare JSON Schema, which leaves
|
|
9650
|
+
// those Schema Objects (under `content`, `schema`, ...) unrecognized and
|
|
9651
|
+
// their `$id`s out of the index
|
|
9652
|
+
const documentElement = reference.value.result;
|
|
9653
|
+
const rootNode = path.getAncestorNodes().at(-1) ?? path.node;
|
|
9654
|
+
const fragmentElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.isParseResultElement)(rootNode) ? rootNode.result : rootNode;
|
|
9655
|
+
try {
|
|
9656
|
+
// the fragment's $ids resolve against the base its enclosing chain
|
|
9657
|
+
// leaves in effect, which then also prefixes the located schema's chain
|
|
9658
|
+
({
|
|
9659
|
+
element: referencedElement,
|
|
9660
|
+
ancestorSchema$ids
|
|
9661
|
+
} = (0,_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_19__.locate)(selector, (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(fragmentElement), {
|
|
9662
|
+
baseURI: rootBaseURI,
|
|
9663
|
+
index: this.schema$idIndex
|
|
9664
|
+
}));
|
|
9665
|
+
ancestorSchema$ids = [...this.ancestorSchema$ids, ...ancestorSchema$ids];
|
|
9666
|
+
} catch (error) {
|
|
9667
|
+
if (!(error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_24__["default"]) || fragmentElement === documentElement) {
|
|
9668
|
+
throw error;
|
|
9669
|
+
}
|
|
9670
|
+
// the document index is rooted at the document, so the located chain
|
|
9671
|
+
// is already document-relative and takes no prefix
|
|
9672
|
+
({
|
|
9673
|
+
element: referencedElement,
|
|
9674
|
+
ancestorSchema$ids
|
|
9675
|
+
} = (0,_selectors_uri_ts__WEBPACK_IMPORTED_MODULE_19__.locate)(selector, (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(documentElement), {
|
|
9676
|
+
baseURI: reference.uri,
|
|
9677
|
+
index: this.schema$idIndex
|
|
9678
|
+
}));
|
|
9679
|
+
}
|
|
9680
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(referencedElement);
|
|
9091
9681
|
|
|
9092
9682
|
// ignore resolving internal Schema Objects
|
|
9093
9683
|
if (!this.options.resolve.internal && isInternalReference) {
|
|
@@ -9102,7 +9692,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9102
9692
|
} else {
|
|
9103
9693
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
9104
9694
|
retrievalURI = this.toBaseURI($refBaseURI);
|
|
9105
|
-
isInternalReference =
|
|
9695
|
+
isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
9106
9696
|
isExternalReference = !isInternalReference;
|
|
9107
9697
|
|
|
9108
9698
|
// ignore resolving internal Schema Objects
|
|
@@ -9115,21 +9705,24 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9115
9705
|
// skip traversing this schema element but traverse all it's child elements
|
|
9116
9706
|
return;
|
|
9117
9707
|
}
|
|
9118
|
-
reference = await this.toReference(
|
|
9119
|
-
const selector =
|
|
9120
|
-
const referenceAsSchema = (0,
|
|
9121
|
-
|
|
9122
|
-
|
|
9708
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize($refBaseURI));
|
|
9709
|
+
const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
9710
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(reference.value.result);
|
|
9711
|
+
({
|
|
9712
|
+
element: referencedElement,
|
|
9713
|
+
ancestorSchema$ids
|
|
9714
|
+
} = (0,_selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_20__.locate)(referenceAsSchema, selector));
|
|
9715
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(referencedElement);
|
|
9123
9716
|
}
|
|
9124
9717
|
} catch (error) {
|
|
9125
9718
|
/**
|
|
9126
9719
|
* SchemaElement($id=URL) was not found, so we're going to try to resolve
|
|
9127
9720
|
* the URL and assume the returned response is a JSON Schema.
|
|
9128
9721
|
*/
|
|
9129
|
-
if (isURL && error instanceof
|
|
9130
|
-
if ((0,_selectors_$
|
|
9722
|
+
if (isURL && error instanceof _errors_EvaluationJsonSchemaUriError_ts__WEBPACK_IMPORTED_MODULE_24__["default"]) {
|
|
9723
|
+
if ((0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_18__.isAnchor)((0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_18__.uriToAnchor)($refBaseURI))) {
|
|
9131
9724
|
// we're dealing with JSON Schema $anchor here
|
|
9132
|
-
isInternalReference =
|
|
9725
|
+
isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
9133
9726
|
isExternalReference = !isInternalReference;
|
|
9134
9727
|
|
|
9135
9728
|
// ignore resolving internal Schema Objects
|
|
@@ -9142,15 +9735,18 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9142
9735
|
// skip traversing this schema element but traverse all it's child elements
|
|
9143
9736
|
return;
|
|
9144
9737
|
}
|
|
9145
|
-
reference = await this.toReference(
|
|
9146
|
-
const selector = (0,_selectors_$
|
|
9147
|
-
const referenceAsSchema = (0,
|
|
9148
|
-
|
|
9149
|
-
|
|
9738
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize($refBaseURI));
|
|
9739
|
+
const selector = (0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_18__.uriToAnchor)($refBaseURI);
|
|
9740
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(reference.value.result);
|
|
9741
|
+
({
|
|
9742
|
+
element: referencedElement,
|
|
9743
|
+
ancestorSchema$ids
|
|
9744
|
+
} = (0,_selectors_$anchor_ts__WEBPACK_IMPORTED_MODULE_18__.locate)(selector, referenceAsSchema));
|
|
9745
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(referencedElement);
|
|
9150
9746
|
} else {
|
|
9151
9747
|
// we're assuming here that we're dealing with JSON Pointer here
|
|
9152
9748
|
retrievalURI = this.toBaseURI($refBaseURI);
|
|
9153
|
-
isInternalReference =
|
|
9749
|
+
isInternalReference = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(this.reference.uri) === retrievalURI;
|
|
9154
9750
|
isExternalReference = !isInternalReference;
|
|
9155
9751
|
|
|
9156
9752
|
// ignore resolving internal Schema Objects
|
|
@@ -9163,11 +9759,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9163
9759
|
// skip traversing this schema element but traverse all it's child elements
|
|
9164
9760
|
return;
|
|
9165
9761
|
}
|
|
9166
|
-
reference = await this.toReference(
|
|
9167
|
-
const selector =
|
|
9168
|
-
const referenceAsSchema = (0,
|
|
9169
|
-
|
|
9170
|
-
|
|
9762
|
+
reference = await this.toReference(_util_url_ts__WEBPACK_IMPORTED_MODULE_25__.unsanitize($refBaseURI));
|
|
9763
|
+
const selector = _speclynx_apidom_json_pointer__WEBPACK_IMPORTED_MODULE_13__.URIFragmentIdentifier.fromURIReference($refBaseURI);
|
|
9764
|
+
const referenceAsSchema = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(reference.value.result);
|
|
9765
|
+
({
|
|
9766
|
+
element: referencedElement,
|
|
9767
|
+
ancestorSchema$ids
|
|
9768
|
+
} = (0,_selectors_json_pointer_ts__WEBPACK_IMPORTED_MODULE_20__.locate)(referenceAsSchema, selector));
|
|
9769
|
+
referencedElement = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.maybeRefractToSchemaElement)(referencedElement);
|
|
9171
9770
|
}
|
|
9172
9771
|
} else {
|
|
9173
9772
|
throw error;
|
|
@@ -9177,14 +9776,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9177
9776
|
|
|
9178
9777
|
// detect direct or indirect reference
|
|
9179
9778
|
if (referencingElement === referencedElement) {
|
|
9180
|
-
throw new
|
|
9181
|
-
$ref: (0,
|
|
9779
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Recursive Schema Object reference detected', {
|
|
9780
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
9182
9781
|
});
|
|
9183
9782
|
}
|
|
9184
9783
|
|
|
9185
9784
|
// detect maximum depth of dereferencing
|
|
9186
9785
|
if (this.indirections.length > this.options.dereference.maxDepth) {
|
|
9187
|
-
throw new
|
|
9786
|
+
throw new _errors_MaximumDereferenceDepthError_ts__WEBPACK_IMPORTED_MODULE_21__["default"](`Maximum dereference depth of "${this.options.dereference.maxDepth}" has been exceeded in file "${this.reference.uri}"`, {
|
|
9188
9787
|
maxDepth: this.options.dereference.maxDepth,
|
|
9189
9788
|
uri: this.reference.uri
|
|
9190
9789
|
});
|
|
@@ -9195,14 +9794,14 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9195
9794
|
if (ancestorsLineage.includes(referencedElement)) {
|
|
9196
9795
|
reference.refSet.circular = true;
|
|
9197
9796
|
if (this.options.dereference.circular === 'error') {
|
|
9198
|
-
throw new
|
|
9199
|
-
$ref: (0,
|
|
9797
|
+
throw new _speclynx_apidom_error__WEBPACK_IMPORTED_MODULE_10__["default"]('Circular reference detected', {
|
|
9798
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
9200
9799
|
});
|
|
9201
9800
|
} else if (this.options.dereference.circular === 'replace') {
|
|
9202
|
-
const refElement = new
|
|
9801
|
+
const refElement = new _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__["default"]($refBaseURI, {
|
|
9203
9802
|
type: referencingElement.element,
|
|
9204
9803
|
uri: reference.uri,
|
|
9205
|
-
$ref: (0,
|
|
9804
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
9206
9805
|
});
|
|
9207
9806
|
const replacer = this.options.dereference.strategyOpts['openapi-3-1']?.circularReplacer ?? this.options.dereference.circularReplacer;
|
|
9208
9807
|
const replacement = replacer(refElement);
|
|
@@ -9221,9 +9820,13 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9221
9820
|
* 3. Fragment is a Schema Object with $ref field. We need to follow it to get the eventual value
|
|
9222
9821
|
* 4. We are dereferencing the fragment lazily/eagerly depending on circular mode
|
|
9223
9822
|
*/
|
|
9224
|
-
const isNonEntryDocument =
|
|
9823
|
+
const isNonEntryDocument = _util_url_ts__WEBPACK_IMPORTED_MODULE_25__.stripHash(reference.refSet.rootRef.uri) !== reference.uri;
|
|
9225
9824
|
const shouldDetectCircular = ['error', 'replace'].includes(this.options.dereference.circular);
|
|
9226
|
-
|
|
9825
|
+
// content transplanted into the referencing site is traversed under that
|
|
9826
|
+
// site's $id chain; a fragment enclosed by a different chain has its own
|
|
9827
|
+
// $refs resolved in place first, by a nested visitor seeded with that chain
|
|
9828
|
+
const hasDifferentEnclosingBase = (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.resolveSchema$ids)(reference.uri, ancestorSchema$ids) !== (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.resolveSchema$ids)(rootBaseURI, (0,_util_ts__WEBPACK_IMPORTED_MODULE_29__.schema$idsOf)(path.getAncestorNodes().reverse()));
|
|
9829
|
+
if ((isExternalReference || isNonEntryDocument || hasDifferentEnclosingBase || (0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isSchemaElement)(referencedElement) && (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_3__.isStringElement)(referencedElement.$ref) || shouldDetectCircular && !this.visited.has(referencedElement)) && !ancestorsLineage.includesCycle(referencedElement)) {
|
|
9227
9830
|
if (shouldDetectCircular) {
|
|
9228
9831
|
this.visited.add(referencedElement);
|
|
9229
9832
|
}
|
|
@@ -9233,10 +9836,12 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9233
9836
|
indirections: [...this.indirections],
|
|
9234
9837
|
options: this.options,
|
|
9235
9838
|
refractCache: this.refractCache,
|
|
9839
|
+
schema$idIndex: this.schema$idIndex,
|
|
9236
9840
|
visited: this.visited,
|
|
9237
|
-
ancestors: ancestorsLineage
|
|
9841
|
+
ancestors: ancestorsLineage,
|
|
9842
|
+
ancestorSchema$ids
|
|
9238
9843
|
});
|
|
9239
|
-
referencedElement = await (0,
|
|
9844
|
+
referencedElement = await (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_11__.traverseAsync)(referencedElement, visitor, {
|
|
9240
9845
|
mutable: true,
|
|
9241
9846
|
skipVisited: 'skip'
|
|
9242
9847
|
});
|
|
@@ -9244,11 +9849,11 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9244
9849
|
}
|
|
9245
9850
|
|
|
9246
9851
|
// Boolean JSON Schemas
|
|
9247
|
-
if ((0,
|
|
9248
|
-
const booleanJsonSchemaElement = (0,
|
|
9852
|
+
if ((0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_14__.isBooleanJSONSchemaElement)(referencedElement)) {
|
|
9853
|
+
const booleanJsonSchemaElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneDeep)(referencedElement);
|
|
9249
9854
|
// annotate referenced element with info about original referencing element
|
|
9250
9855
|
booleanJsonSchemaElement.meta.set('ref-fields', {
|
|
9251
|
-
$ref: (0,
|
|
9856
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
9252
9857
|
});
|
|
9253
9858
|
// annotate referenced element with info about origin and type
|
|
9254
9859
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
@@ -9261,17 +9866,17 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9261
9866
|
/**
|
|
9262
9867
|
* Creating a new version of Schema Object by merging fields from referenced Schema Object with referencing one.
|
|
9263
9868
|
*/
|
|
9264
|
-
if ((0,
|
|
9265
|
-
const mergedElement = (0,
|
|
9869
|
+
if ((0,_speclynx_apidom_ns_openapi_3_1__WEBPACK_IMPORTED_MODULE_17__.isSchemaElement)(referencedElement)) {
|
|
9870
|
+
const mergedElement = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_5__.cloneShallow)(referencedElement);
|
|
9266
9871
|
// existing keywords from referencing schema overrides ones from referenced schema
|
|
9267
9872
|
referencingElement.forEach((value, keyElement, item) => {
|
|
9268
|
-
mergedElement.remove((0,
|
|
9873
|
+
mergedElement.remove((0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(keyElement));
|
|
9269
9874
|
mergedElement.content.push(item);
|
|
9270
9875
|
});
|
|
9271
9876
|
mergedElement.remove('$ref');
|
|
9272
9877
|
// annotate referenced element with info about original referencing element
|
|
9273
9878
|
mergedElement.meta.set('ref-fields', {
|
|
9274
|
-
$ref: (0,
|
|
9879
|
+
$ref: (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref)
|
|
9275
9880
|
});
|
|
9276
9881
|
// annotate fragment with info about origin and type
|
|
9277
9882
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
@@ -9283,7 +9888,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
9283
9888
|
*/
|
|
9284
9889
|
path.replaceWith(referencedElement);
|
|
9285
9890
|
} catch (error) {
|
|
9286
|
-
const $ref = (0,
|
|
9891
|
+
const $ref = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_8__["default"])(referencingElement.$ref);
|
|
9287
9892
|
this.handleError(`Error while dereferencing Schema Object. Cannot resolve $ref "${$ref}": ${error.message}`, error, referencingElement, '$ref', $ref, path);
|
|
9288
9893
|
} finally {
|
|
9289
9894
|
if (this.indirections.length > indirectionsSize) this.indirections.pop();
|
|
@@ -13355,6 +13960,38 @@ const resolve = (from, to) => {
|
|
|
13355
13960
|
return resolvedUrl.toString();
|
|
13356
13961
|
};
|
|
13357
13962
|
|
|
13963
|
+
/**
|
|
13964
|
+
* Computes the URI reference that resolves to `to` against `from` — the inverse
|
|
13965
|
+
* of `resolve`: `resolve(from, relative(from, to)) === to`. The reference is
|
|
13966
|
+
* relative to the directory of `from` (its last path segment is the document,
|
|
13967
|
+
* not a directory). When the two URIs differ in scheme or authority, or either
|
|
13968
|
+
* has no hierarchical path (e.g. a URN), no relative form exists and `to` is
|
|
13969
|
+
* returned unchanged.
|
|
13970
|
+
* @public
|
|
13971
|
+
*/
|
|
13972
|
+
const relative = (from, to) => {
|
|
13973
|
+
const fromURL = new URL(from, 'resolve://');
|
|
13974
|
+
const toURL = new URL(to, 'resolve://');
|
|
13975
|
+
|
|
13976
|
+
// the authority is host plus userinfo; a relative reference keeps both from `from`
|
|
13977
|
+
if (fromURL.protocol !== toURL.protocol || fromURL.host !== toURL.host || fromURL.username !== toURL.username || fromURL.password !== toURL.password || !fromURL.pathname.startsWith('/') || !toURL.pathname.startsWith('/')) {
|
|
13978
|
+
return to;
|
|
13979
|
+
}
|
|
13980
|
+
const fromSegments = fromURL.pathname.split('/').slice(0, -1);
|
|
13981
|
+
const toSegments = toURL.pathname.split('/');
|
|
13982
|
+
let common = 0;
|
|
13983
|
+
while (common < fromSegments.length && common < toSegments.length - 1 && fromSegments[common] === toSegments[common]) {
|
|
13984
|
+
common += 1;
|
|
13985
|
+
}
|
|
13986
|
+
const segments = [...fromSegments.slice(common).map(() => '..'), ...toSegments.slice(common)];
|
|
13987
|
+
// a leading segment with a colon would be parsed as a scheme, and an empty
|
|
13988
|
+
// reference (`to` is the directory of `from`) would resolve back to `from`
|
|
13989
|
+
if (segments[0].includes(':') || segments.join('/') === '') {
|
|
13990
|
+
segments.unshift('.');
|
|
13991
|
+
}
|
|
13992
|
+
return segments.join('/') + toURL.search + toURL.hash;
|
|
13993
|
+
};
|
|
13994
|
+
|
|
13358
13995
|
/**
|
|
13359
13996
|
* Sanitizes/Encodes URI to it's url encoded form.
|
|
13360
13997
|
*
|
|
@@ -13400,6 +14037,7 @@ const unsanitize = uri => {
|
|
|
13400
14037
|
/* harmony export */ "isFileSystemPath", 0, /* binding */ isFileSystemPath,
|
|
13401
14038
|
/* harmony export */ "isHttpUrl", 0, /* binding */ isHttpUrl,
|
|
13402
14039
|
/* harmony export */ "isURI", 0, /* binding */ isURI,
|
|
14040
|
+
/* harmony export */ "relative", 0, /* binding */ relative,
|
|
13403
14041
|
/* harmony export */ "resolve", 0, /* binding */ resolve,
|
|
13404
14042
|
/* harmony export */ "sanitize", 0, /* binding */ sanitize,
|
|
13405
14043
|
/* harmony export */ "stripHash", 0, /* binding */ stripHash,
|