gen/data_types.go
func (d *APIDescriptor) Merge(other *APIDescriptor) error {
	if d.Version != other.Version {
		return fmt.Errorf("Can't merge API descriptors with different versions")
	}
	for _, name := range d.ResourceNames {
		for _, otherName := range other.ResourceNames {
			if name == otherName {
				return fmt.Errorf("%s is a resource that exists in multiple APIs, generate separate clients", name)
			}
		}
	}
	for _, name := range d.TypeNames {
		for i, otherName := range other.TypeNames {
			if name == otherName {
				newName := MakeUniq(otherName, append(d.TypeNames, other.TypeNames...))
				first := other.TypeNames[:i]
				last := append([]string{newName}, other.TypeNames[i+1:]...)
				other.TypeNames = append(first, last...)
				typ := other.Types[name]
				delete(other.Types, name)
				typ.TypeName = newName
				other.Types[newName] = typ
			}
		}
	}
	for name, resource := range other.Resources {
		d.Resources[name] = resource
	}
	for name, typ := range other.Types {
		d.Types[name] = typ
	}
	d.ResourceNames = append(d.ResourceNames, other.ResourceNames...)
	d.TypeNames = append(d.TypeNames, other.TypeNames...)
	return nil
}
func (d *APIDescriptor) Merge(other *APIDescriptor) error {
	if d.Version != other.Version {
		return fmt.Errorf("Can't merge API descriptors with different versions")
	}
	for _, name := range d.ResourceNames {
		for _, otherName := range other.ResourceNames {
			if name == otherName {
				return fmt.Errorf("%s is a resource that exists in multiple APIs, generate separate clients", name)
			}
		}
	}
	for _, name := range d.TypeNames {
		for i, otherName := range other.TypeNames {
			if name == otherName {
				newName := MakeUniq(otherName, append(d.TypeNames, other.TypeNames...))
				first := other.TypeNames[:i]
				last := append([]string{newName}, other.TypeNames[i+1:]...)
				other.TypeNames = append(first, last...)
				typ := other.Types[name]
				delete(other.Types, name)
				typ.TypeName = newName
				other.Types[newName] = typ
			}
		}
	}
	for name, resource := range other.Resources {
		d.Resources[name] = resource
	}
	for name, typ := range other.Types {
		d.Types[name] = typ
	}
	d.ResourceNames = append(d.ResourceNames, other.ResourceNames...)
	d.TypeNames = append(d.TypeNames, other.TypeNames...)
	return nil
}
// Merge two descriptors together, make sure there are no duplicate resource names and that
// common types are compatible.