I've got more comments about what's going on in my follow up code but I'll summarize here. It looks through the types that can be passed as arguments, and the types that are returned in the first pass. Then in the second pass it looks through all the models it just added to get any types that they reference. This is the way swagger-node-express does it, I guess it would be possible to recurse each model as it's added. Now that I think about it, I'm not sure the current code recurses any models added in the second pass, which is troubling since as I mentioned this logic is copied from swagger-node-express which is from @wordnik