Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function bundle(swaggerFile) {
var root = yaml.safeLoad(fs.readFileSync(swaggerFile, 'utf8'));
var options = {
filter : ['relative', 'remote'],
resolveCirculars: true,
location: swaggerFile,
loaderOptions : {
processContent : function (res, callback) {
callback(undefined, yaml.safeLoad(res.text));
}
}
};
JsonRefs.clearCache();
return JsonRefs.resolveRefs(root, options).then(function (results) {
var resErrors = {};
for (const [k,v] of Object.entries(results.refs)) {
if ('missing' in v && v.missing === true && (v.type == 'relative' || v.type === 'remote'))
resErrors[k] = v.error;
}
if (Object.keys(resErrors).length > 0) {
return Promise.reject(dictToString(resErrors));
}
return results.resolved;
}, function (e) {
var error = {};
Object.getOwnPropertyNames(e).forEach(function (key) {
error[key] = e[key];
function bundle(swaggerFile) {
var root = yaml.safeLoad(fs.readFileSync(swaggerFile, 'utf8'));
var options = {
filter : ['relative', 'remote'],
resolveCirculars: true,
location: swaggerFile,
loaderOptions : {
processContent : function (res, callback) {
callback(undefined, yaml.safeLoad(res.text));
}
}
};
JsonRefs.clearCache();
return JsonRefs.resolveRefs(root, options).then(function (results) {
var resErrors = {};
for (const [k,v] of Object.entries(results.refs)) {
if ('missing' in v && v.missing === true)
resErrors[k] = v.error;
}
if (Object.keys(resErrors).length > 0) {
return Promise.reject(dictToString(resErrors));
}
return results.resolved;
}, function (e) {
var error = {};
Object.getOwnPropertyNames(e).forEach(function (key) {
error[key] = e[key];