code: function recurvsiveFlatten(name, obj, arr, depth){
  
    var type;
  
    // "items" property flags a nested object or array, so it needs special treatment
    if (obj.hasOwnProperty('items')) {
  
      type = obj.items.type;
  
      // Keep track of what type of array this is (if it is an array type)
      if (obj.type === 'array') {
        type = lodash.capitalize(type) + '[]';
      }
  
      // Add the object or array to the flattened property array
      arr.push({name: name, type: type, description: obj.description || '', depth: depth});
  
      // Loop thru the item's properties and execute the recursive function
      lodash.forIn(obj.items.properties, function (val, key) {
        recurvsiveFlatten(key, val, arr, depth + 1);
      });
  
    } else if (obj.hasOwnProperty('properties')) {
  
      // Add the object to the flattened property array
      arr.push({name: name, type: 'Object', description: obj.description || '', depth: depth});
  
      // Execute the recursive function on all properties
      lodash.forIn(obj.properties, function(val, key){
        recurvsiveFlatten(key, val, arr, depth + 1);
      });
    } else {
  
      // Add the property to the flattened property array
      arr.push({name: name, type: obj.type, description: obj.description, depth: depth});
    }
  
  }
docs: Swagger spec may lead to a high degree of nesting in response objects (objects within objects with objects, etc). This function flattens that schmema and assigns each schema item a "depth" property.  The outer object wrapper has depth -1.