Resolving properties as a reusable component

Resolve each property as a different schema instead of inline
This commit is contained in:
Erik Mendoza
2022-06-07 21:39:53 -05:00
parent b9a01676de
commit 446e8651e5
30 changed files with 1141 additions and 195 deletions

View File

@@ -92,7 +92,7 @@ const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/sc
{ getRelatedFiles } = require('./relatedFiles'),
{ compareVersion } = require('./common/versionUtils.js'),
parse = require('./parse'),
{ getBundleContentAndComponents } = require('./bundle.js'),
{ getBundleContentAndComponents, parseFileOrThrow } = require('./bundle.js'),
MULTI_FILE_API_TYPE_ALLOWED_VALUE = 'multiFile';
/* eslint-enable */
@@ -4884,7 +4884,7 @@ module.exports = {
mapProcessRelatedFiles(rootFiles, inputData, origin, version, format, toBundle = false) {
let bundleFormat = format,
parsedRootFiles = rootFiles.map((rootFile) => {
let parsedContent = this.parseFileOrThrow(rootFile.content);
let parsedContent = parseFileOrThrow(rootFile.content);
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
}).filter((rootWithParsedContent) => {
bundleFormat = bundleFormat ? bundleFormat : rootWithParsedContent.parsed.inputFormat;
@@ -4968,13 +4968,5 @@ module.exports = {
throw new Error('"Path" of the data element should be provided');
}
},
parseFileOrThrow(fileContent) {
const result = parse.getOasObject(fileContent);
if (result.result === false) {
throw new ParseError(result.reason);
}
return result;
},
MULTI_FILE_API_TYPE_ALLOWED_VALUE
};