mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Fix input validation in multi file APIs
This commit is contained in:
@@ -4815,6 +4815,16 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @description Takes in a the root files obtains the related files and
|
||||
* generates the result object
|
||||
* @param {object} parsedRootFiles - found parsed root files
|
||||
* @param {array} inputData - file data information [{path, content}]
|
||||
* @param {Array} origin - process origin (BROWSER or node)
|
||||
*
|
||||
* @returns {object} process result { rootFile, relatedFiles, missingRelatedFiles }
|
||||
*/
|
||||
getRelatedFilesData(parsedRootFiles, inputData, origin) {
|
||||
const data = parsedRootFiles.map((root) => {
|
||||
let relatedData = getRelatedFiles(root, inputData, origin),
|
||||
@@ -4828,6 +4838,17 @@ module.exports = {
|
||||
return data;
|
||||
},
|
||||
|
||||
/*
|
||||
*
|
||||
* @description Takes in parsed root files and bundle it
|
||||
* @param {object} parsedRootFiles - found parsed root files
|
||||
* @param {array} inputData - file data information [{path, content}]
|
||||
* @param {Array} origin - process origin (BROWSER or node)
|
||||
* @param {string} format - output format could be either YAML or JSON
|
||||
* @param {string} version - specification version specified in the input
|
||||
*
|
||||
* @returns {object} process result { rootFile, bundledContent }
|
||||
*/
|
||||
getBundledFileData(parsedRootFiles, inputData, origin, format) {
|
||||
const data = parsedRootFiles.map((root) => {
|
||||
let bundleData = getBundleContentAndComponents(root, inputData, origin);
|
||||
@@ -4923,6 +4944,28 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @description Validates the input for multi file APIs
|
||||
* @param {string} processInput - Process input data
|
||||
*
|
||||
* @returns {undefined} - nothing
|
||||
*/
|
||||
validateInputMultiFileAPI(processInput) {
|
||||
if (_.isEmpty(processInput)) {
|
||||
throw new Error('Input object must have "type" and "data" information');
|
||||
}
|
||||
if (!processInput.type) {
|
||||
throw new Error('"Type" parameter should be provided');
|
||||
}
|
||||
if (!processInput.data || processInput.data.length === 0) {
|
||||
throw new Error('"Data" parameter should be provided');
|
||||
}
|
||||
if (processInput.data[0].path === '') {
|
||||
throw new Error('"Path" of the data element should be provided');
|
||||
}
|
||||
},
|
||||
|
||||
parseFileOrThrow(fileContent) {
|
||||
const result = parse.getOasObject(fileContent);
|
||||
if (result.result === false) {
|
||||
|
||||
Reference in New Issue
Block a user