Reputation: 60
I am trying to copy the definitions portion of a yaml file into a js doc for a codegen project. I tried using regular expressions (which worked great for copying methods out of swagger generated js files) but apparently regexp does not handle info from yaml files very well. I managed to print MOST of what I want to the commandline through console.log. There are a few arrays that just say [Object], which is problematic. I would like to have their full contents printed. HOWEVER, this is not the main problem. When I try to write this output to a file instead of the console...it just says "[object Object] [object Object]" for my 2 definitions. Has anyone done anything like this before? Here is a snippet of my code and what the console output looks like vs the two lines above TIA!
var doc = yaml.safeLoad(fs.readFileSync('path to my file\swagger.yaml', 'utf8'));
for(var d in doc['definitions']){
logit(doc['definitions'][d]); //logit write to consle and a file
}
Upvotes: 0
Views: 2712