Add scenario referenced path points to local schema

Add scenario referenced path points to local schema
This commit is contained in:
Luis Tejeda
2022-05-31 13:17:00 -05:00
parent c9741f04c9
commit fc0753c854
7 changed files with 203 additions and 10 deletions

View File

@@ -26,7 +26,8 @@ let path = require('path'),
'securitySchemes',
'links',
'callbacks'
];
],
deref = require('./deref.js');
/**
@@ -137,9 +138,7 @@ function getContentFromTrace(content, partial) {
partial = partial[0] === jsonPointerLevelSeparator ? partial.substring(1) : partial;
const trace = partial.split(jsonPointerLevelSeparator);
let currentValue = content;
for (let place of trace) {
currentValue = currentValue[place];
}
currentValue = deref._getEscaped(content, trace, undefined);
return currentValue;
}
@@ -351,7 +350,13 @@ function generateComponentsObject (documentContext, rootContent, refTypeResolver
refData.inline = refData.keyInComponents.length === 0;
}
if (local) {
refData.nodeContent = getContentFromTrace(refData.nodeContent, local);
let contentFromTrace = getContentFromTrace(refData.nodeContent, local);
if (!contentFromTrace) {
refData.nodeContent = { $ref: `${localPointer + local}` };
}
else {
refData.nodeContent = contentFromTrace;
}
}
if (refData.inline) {
refData.node = refData.nodeContent;