Add reusable referenced path item object

Add reusable referenced path item object
This commit is contained in:
Luis Tejeda
2022-06-14 12:25:48 -05:00
parent 5c27400ebc
commit 6ade03062a
9 changed files with 386 additions and 42 deletions

View File

@@ -6,7 +6,7 @@
const { ParseError } = require('./common/ParseError.js');
const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/schemaUtilsCommon.js'),
{ getConcreteSchemaUtils } = require('./common/versionUtils.js'),
{ getConcreteSchemaUtils, SWAGGER_VERSION } = require('./common/versionUtils.js'),
async = require('async'),
sdk = require('postman-collection'),
schemaFaker = require('../assets/json-schema-faker.js'),
@@ -4874,9 +4874,9 @@ module.exports = {
*
* @returns {object} process result { rootFile, bundledContent }
*/
getBundledFileData(parsedRootFiles, inputData, origin, format) {
getBundledFileData(parsedRootFiles, inputData, origin, format, version) {
const data = parsedRootFiles.map((root) => {
let bundleData = getBundleContentAndComponents(root, inputData, origin);
let bundleData = getBundleContentAndComponents(root, inputData, origin, version);
return bundleData;
});
@@ -4904,10 +4904,13 @@ module.exports = {
let parsedContent = parseFileOrThrow(rootFile.content);
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
}).filter((rootWithParsedContent) => {
return compareVersion(version, rootWithParsedContent.parsed.oasObject.openapi);
let fileVersion = version === SWAGGER_VERSION ?
rootWithParsedContent.parsed.oasObject.swagger :
rootWithParsedContent.parsed.oasObject.openapi;
return compareVersion(version, fileVersion);
}),
data = toBundle ?
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat) :
this.getBundledFileData(parsedRootFiles, inputData, origin, bundleFormat, version) :
this.getRelatedFilesData(parsedRootFiles, inputData, origin);
return data;