Skip to content

Commit 5fec203

Browse files
committed
add circularRefs array
1 parent 8c4673c commit 5fec203

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/bundle.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,9 @@ function handleCircularReference(traverseContext, documentContext) {
520520
*/
521521
function generateComponentsObject (documentContext, rootContent, refTypeResolver, components, version) {
522522
let notInLine = Object.entries(documentContext.globalReferences).filter(([, value]) => {
523-
return value.keyInComponents.length !== 0;
524-
});
523+
return value.keyInComponents.length !== 0;
524+
}),
525+
circularRefsSet = new Set();
525526
const { COMPONENTS_KEYS } = getBundleRulesDataByVersion(version);
526527
notInLine.forEach(([key, value]) => {
527528
let [, partial] = key.split(localPointer);
@@ -572,10 +573,12 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
572573
else if (isCircularReference(this, contentFromTrace)) {
573574
if (refData.inline) {
574575
refData.nodeContent = { [CIRCULAR_OR_REF_EXT_PROP]: tempRef };
576+
circularRefsSet.add(tempRef);
575577
}
576578
else {
577579
refData.node = { [CIRCULAR_OR_REF_EXT_PROP]: refData.reference };
578580
refData.nodeContent = contentFromTrace;
581+
circularRefsSet.add(refData.reference);
579582
}
580583
}
581584
else {
@@ -610,7 +613,8 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
610613
}),
611614
newComponents: traverseUtility(components).map(function () {
612615
handleCircularReference(this, documentContext);
613-
})
616+
}),
617+
circularRefs: [...circularRefsSet]
614618
};
615619
}
616620

@@ -645,7 +649,7 @@ function generateComponentsWrapper(parsedOasObject, version, nodesContent = {})
645649
}
646650

647651
/**
648-
* Generates a map of generated refernce to the original reference
652+
* Generates a map of generated reference to the original reference
649653
*
650654
* @param {object} globalReferences - Global references present at each root file context
651655
* @returns {object} reference map
@@ -739,7 +743,8 @@ module.exports = {
739743
fileContent: finalElements.resRoot,
740744
components: finalElements.newComponents,
741745
fileName: specRoot.fileName,
742-
referenceMap: getReferenceMap(rootContextData.globalReferences)
746+
referenceMap: getReferenceMap(rootContextData.globalReferences),
747+
circularRefs: finalElements.circularRefs
743748
};
744749
},
745750
getReferences,

0 commit comments

Comments
 (0)