mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Adding safe parsing to the node's content parsing
This commit is contained in:
@@ -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');
|
||||
/* eslint-enable */
|
||||
|
||||
// See https://github.com/json-schema-faker/json-schema-faker/tree/master/docs#available-options
|
||||
@@ -4867,7 +4867,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) => {
|
||||
let fileVersion = version === SWAGGER_VERSION ?
|
||||
@@ -4931,14 +4931,5 @@ module.exports = {
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
},
|
||||
|
||||
parseFileOrThrow(fileContent) {
|
||||
const result = parse.getOasObject(fileContent);
|
||||
if (result.result === false) {
|
||||
throw new ParseError(result.reason);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user