mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
filtering collections from convertedSpec
This commit is contained in:
19
index.js
19
index.js
@@ -67,13 +67,24 @@ module.exports = {
|
|||||||
|
|
||||||
_.forEach(convertedSpecs, (convertedSpec) => {
|
_.forEach(convertedSpecs, (convertedSpec) => {
|
||||||
if (convertedSpec.result) {
|
if (convertedSpec.result) {
|
||||||
conversionResult = convertedSpec.result;
|
let result;
|
||||||
convertedCollections.push(convertedSpec.output[0]);
|
conversionResult = conversionResult || convertedSpec.result;
|
||||||
|
|
||||||
|
function returnCollections (resultSpec) {
|
||||||
|
if (resultSpec.type === 'collection') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// filtering out the collections from the convertedSpec
|
||||||
|
result = convertedSpec.output.filter(returnCollections);
|
||||||
|
result.forEach((collection) => {
|
||||||
|
convertedCollections.push(collection);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
conversionResult = convertedSpec.result;
|
conversionResult = conversionResult || convertedSpec.result;
|
||||||
reasonForFail = convertedSpec.reason;
|
reasonForFail = convertedSpec.reason;
|
||||||
return false; // it will break out from the loop
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -162,11 +162,11 @@ module.exports = {
|
|||||||
return yamlParse.parse(content, { prettyErrors: true });
|
return yamlParse.parse(content, { prettyErrors: true });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw new ReadError('\nLine: ' + err.linePos.start.line + ', col: ' +
|
throw new Error('\nLine: ' + err.linePos.start.line + ', col: ' +
|
||||||
err.linePos.start.col + ' ' + err.message);
|
err.linePos.start.col + ' ' + err.message);
|
||||||
}
|
}
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
throw new OpenError(err.message);
|
throw new Error(err.message);
|
||||||
})
|
})
|
||||||
.then((unresolved) => {
|
.then((unresolved) => {
|
||||||
if (options.resolve === true) {
|
if (options.resolve === true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user