mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
add inline objects to ref map
This commit is contained in:
@@ -323,7 +323,9 @@ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, ve
|
||||
[, local] = tempRef.split(localPointer),
|
||||
nodeFromData,
|
||||
refHasContent = false,
|
||||
parseResult;
|
||||
parseResult,
|
||||
newRefInDoc,
|
||||
inline;
|
||||
|
||||
newValue = Object.assign({}, this.node);
|
||||
nodeFromData = findNodeFromPath(tempRef, allData);
|
||||
@@ -337,15 +339,21 @@ function getReferences (currentNode, isOutOfRoot, pathSolver, parentFilename, ve
|
||||
}
|
||||
this.update({ $ref: tempRef });
|
||||
|
||||
if (nodeTrace.length === 0) {
|
||||
inline = true;
|
||||
newRefInDoc = localPointer + jsonPointerLevelSeparator + traceToParent.join(jsonPointerLevelSeparator);
|
||||
}
|
||||
|
||||
nodeReferenceDirectory[tempRef] = {
|
||||
local,
|
||||
keyInComponents: nodeTrace,
|
||||
node: newValue,
|
||||
reference: referenceInDocument,
|
||||
reference: inline ? newRefInDoc : referenceInDocument,
|
||||
traceToParent,
|
||||
parentNodeKey: parentFilename,
|
||||
mainKeyInTrace: nodeTrace[nodeTrace.length - 1],
|
||||
refHasContent
|
||||
refHasContent,
|
||||
inline
|
||||
};
|
||||
|
||||
mainKeys[componentKey] = tempRef;
|
||||
@@ -469,7 +477,6 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
|
||||
}
|
||||
else {
|
||||
refData.nodeContent = documentContext.nodeContents[nodeRef];
|
||||
refData.inline = refData.keyInComponents.length === 0;
|
||||
}
|
||||
if (local) {
|
||||
let contentFromTrace = getContentFromTrace(refData.nodeContent, local);
|
||||
@@ -524,14 +531,17 @@ function generateComponentsWrapper(parsedOasObject) {
|
||||
* Generates a map of generated refernce to the original reference
|
||||
*
|
||||
* @param {object} globalReferences - Global references present at each root file context
|
||||
* @returns {object} referncce map
|
||||
* @returns {object} reference map
|
||||
*/
|
||||
function getReferenceMap(globalReferences) {
|
||||
const output = {};
|
||||
|
||||
_.forEach(globalReferences, (globalReference, refKey) => {
|
||||
if (_.isString(refKey) && _.isString(globalReference.reference)) {
|
||||
output[globalReference.reference] = refKey;
|
||||
output[globalReference.reference] = {
|
||||
path: refKey,
|
||||
type: globalReference.inline ? 'inline' : 'component'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user