code: func (a *APIDefinition) IterateResources(it ResourceIterator) error {
  	res := make([]*ResourceDefinition, len(a.Resources))
  	i := 0
  	for _, r := range a.Resources {
  		res[i] = r
  		i++
  	}
  	// Iterate parent resources first so that action parameters are
  	// finalized prior to child actions needing them.
  	isParent := func(p, c *ResourceDefinition) bool {
  		par := c.Parent()
  		for par != nil {
  			if par == p {
  				return true
  			}
  			par = par.Parent()
  		}
  		return false
  	}
  	sort.Slice(res, func(i, j int) bool {
  		if isParent(res[i], res[j]) {
  			return true
  		}
  		if isParent(res[j], res[i]) {
  			return false
  		}
  		return res[i].Name < res[j].Name
  	})
  	for _, r := range res {
  		if err := it(r); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // IterateResources calls the given iterator passing in each resource sorted in alphabetical order.
  // Iteration stops if an iterator returns an error and in this case IterateResources returns that
  // error.