Skip to content

Instantly share code, notes, and snippets.

@norbertpotocki
Last active July 14, 2016 07:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norbertpotocki/0627f642064e91af09e2 to your computer and use it in GitHub Desktop.
Save norbertpotocki/0627f642064e91af09e2 to your computer and use it in GitHub Desktop.
/**
* Combine the swagger specification parts into a single YAML file.
*/
var resolve = require('json-refs').resolveRefs;
var YAML = require('js-yaml');
var fs = require('fs');
process.chdir('spec');
var root = YAML.load(fs.readFileSync('root.yaml').toString());
var options = {
filter: ['relative', 'remote'],
loaderOptions: {
processContent: function (res, callback) {
callback(null, YAML.load(res.text));
}
}
};
resolve(root, options).then(function (results) {
console.log(YAML.dump(results.resolved, null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment