Skip to content

Commit 8c6e031

Browse files
committed
fix: port over indirections and cloning fix
1 parent 515aa10 commit 8c6e031

File tree

2 files changed

+5
-2
lines changed
  • packages/apidom-reference
    • src/dereference/strategies/openapi-3-1
    • test/resolve/strategies/openapi-3-1/discriminator-mapping-object

2 files changed

+5
-2
lines changed

packages/apidom-reference/src/dereference/strategies/openapi-3-1/visitor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ class OpenAPI3_1DereferenceVisitor {
734734
return false;
735735
}
736736

737+
this.indirections.push(memberElement);
738+
737739
const [ancestorsLineage, directAncestors] = this.toAncestorLineage([...ancestors, parent]);
738740
const parentSchemaElement = [...directAncestors].findLast(isSchemaElement);
739741
const ancestorsSchemaIdentifiers = cloneDeep(
@@ -772,9 +774,10 @@ class OpenAPI3_1DereferenceVisitor {
772774

773775
// remove referencing reference from ancestors lineage
774776
directAncestors.delete(schemaElement);
777+
this.indirections.pop();
775778

776779
// annotate MemberElement with referenced schema
777-
const memberElementCopy: MemberElement = cloneDeep(memberElement);
780+
const memberElementCopy: MemberElement = cloneShallow(memberElement);
778781
(memberElementCopy.value as StringElement).setMetaProperty('ref-schema', referencedElement);
779782

780783
/**

packages/apidom-reference/test/resolve/strategies/openapi-3-1/discriminator-mapping-object/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('resolve', function () {
102102
// @ts-ignore
103103
assert.instanceOf(error.cause.cause, MaximumDereferenceDepthError);
104104
// @ts-ignore
105-
assert.match(error.cause.cause.message, /fixtures\/max-depth\/ex2.json"$/);
105+
assert.match(error.cause.cause.message, /fixtures\/max-depth\/ex1.json"$/);
106106
}
107107
});
108108
});

0 commit comments

Comments
 (0)