mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Filter roots by specification version
Filter roots by specification version
This commit is contained in:
committed by
Erik Mendoza
parent
e040455f46
commit
f3030247ea
@@ -88,7 +88,9 @@ const { formatDataPath, checkIsCorrectType, isKnownType,
|
||||
|
||||
crypto = require('crypto'),
|
||||
DEFAULT_SCHEMA_UTILS = require('./30XUtils/schemaUtils30X'),
|
||||
{ getRelatedFiles } = require('./relatedFiles');
|
||||
{ getRelatedFiles } = require('./relatedFiles'),
|
||||
{ compareVersion } = require('./common/versionUtils.js'),
|
||||
parse = require('./parse');
|
||||
/* eslint-enable */
|
||||
|
||||
// See https://github.com/json-schema-faker/json-schema-faker/tree/master/docs#available-options
|
||||
@@ -4852,17 +4854,25 @@ module.exports = {
|
||||
* @param {object} rootFiles - rootFile:{path:string}
|
||||
* @param {array} inputData - [{path:string}]}
|
||||
* @param {string} origin - process origin
|
||||
* @param {string} version - process specification version
|
||||
*
|
||||
* @returns {object} root files information and data input
|
||||
*/
|
||||
mapProcessRelatedFiles(rootFiles, inputData, origin) {
|
||||
let data = rootFiles.map((root) => {
|
||||
let { relatedFiles, missingRelatedFiles } = getRelatedFiles(root, inputData, origin);
|
||||
return {
|
||||
rootFile: { path: root.fileName },
|
||||
relatedFiles,
|
||||
missingRelatedFiles };
|
||||
});
|
||||
mapProcessRelatedFiles(rootFiles, inputData, origin, version) {
|
||||
let parsedRootFiles = rootFiles.map((rootFile) => {
|
||||
let parsedContent = parse.getOasObject(rootFile.content);
|
||||
return { fileName: rootFile.fileName, content: rootFile.content, parsed: parsedContent };
|
||||
}).filter((rootWithParsedContent) => {
|
||||
return compareVersion(version, rootWithParsedContent.parsed.oasObject.openapi);
|
||||
}),
|
||||
data = parsedRootFiles.map((root) => {
|
||||
let { relatedFiles, missingRelatedFiles } = getRelatedFiles(root, inputData, origin);
|
||||
return {
|
||||
rootFile: { path: root.fileName },
|
||||
relatedFiles,
|
||||
missingRelatedFiles
|
||||
};
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -4890,7 +4900,7 @@ module.exports = {
|
||||
};
|
||||
if (inputRelatedFiles.rootFiles && inputRelatedFiles.rootFiles.length > 0) {
|
||||
res.output.data = this.mapProcessRelatedFiles(inputRelatedFiles.rootFiles, inputRelatedFiles.data,
|
||||
inputRelatedFiles.origin);
|
||||
inputRelatedFiles.origin, version);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user