mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
added check for https, changed behaviour of callback back to err throwing in convert function
This commit is contained in:
22
index.js
22
index.js
@@ -40,17 +40,10 @@ module.exports = {
|
|||||||
.then((spec) => {
|
.then((spec) => {
|
||||||
converter.convert(spec, options, (err, result) => {
|
converter.convert(spec, options, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(null, {
|
return callback(err);
|
||||||
result: false,
|
|
||||||
reason: err
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-else-return
|
|
||||||
else {
|
|
||||||
convertedSpecs.push(result);
|
convertedSpecs.push(result);
|
||||||
return callback(null);
|
return callback(null);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -59,7 +52,14 @@ module.exports = {
|
|||||||
reason: err
|
reason: err
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, () => {
|
}, (err) => {
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
return cb({
|
||||||
|
result: false,
|
||||||
|
reason: 'input type:' + input.type + ' is not valid'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var conversionResult = false,
|
var conversionResult = false,
|
||||||
convertedCollections = [],
|
convertedCollections = [],
|
||||||
@@ -73,6 +73,7 @@ module.exports = {
|
|||||||
else {
|
else {
|
||||||
conversionResult = convertedSpec.result;
|
conversionResult = convertedSpec.result;
|
||||||
reasonForFail = convertedSpec.reason;
|
reasonForFail = convertedSpec.reason;
|
||||||
|
return false; // it will break out from the loop
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,8 +117,7 @@ module.exports = {
|
|||||||
else if (input.type === 'folder') {
|
else if (input.type === 'folder') {
|
||||||
if (!_.isEmpty(parse.getRootFiles(input.data))) {
|
if (!_.isEmpty(parse.getRootFiles(input.data))) {
|
||||||
return {
|
return {
|
||||||
result: true,
|
result: true
|
||||||
reason: 'valid input type'
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,10 +273,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Unhandled exception, rethrow
|
// Unhandled exception, rethrow
|
||||||
callback(null, {
|
callback(e);
|
||||||
result: false,
|
|
||||||
reason: e.message
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ module.exports = {
|
|||||||
|
|
||||||
getOasObject: function (file) {
|
getOasObject: function (file) {
|
||||||
let oasObj = file;
|
let oasObj = file;
|
||||||
|
|
||||||
if (typeof oasObj === 'string') {
|
|
||||||
try {
|
try {
|
||||||
oasObj = JSON.parse(oasObj);
|
oasObj = JSON.parse(oasObj);
|
||||||
}
|
}
|
||||||
@@ -121,7 +119,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
// valid YAML
|
// valid YAML
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return oasObj;
|
return oasObj;
|
||||||
},
|
},
|
||||||
@@ -187,7 +184,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
readSpecFile: function (file) {
|
readSpecFile: function (file) {
|
||||||
if (file && file.startsWith('http')) {
|
if (file.startsWith('http') || file.startsWith('https')) {
|
||||||
// remote file
|
// remote file
|
||||||
return fetch(file).then((res) => {
|
return fetch(file).then((res) => {
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
|
|||||||
Reference in New Issue
Block a user