func (a *APIAnalyzer) addType(ec EvalCtx, dt *gen.ObjectDataType, r Ref) {
	a.api.NeedJSON = true
	if a.refByType[dt.TypeName] == r.ID() {
		return
	}

	if other, ok := a.api.Types[dt.TypeName]; ok {
		if !ec.IsResult {
			// If its an input parameter, fix the collision by amending this types name
			dt.TypeName += "Param"
			if a.refByType[dt.TypeName] == r.ID() {
				return
			}
		}
		oldFields := []string{}
		newFields := []string{}
		for _, f := range other.Fields {
			oldFields = append(oldFields, f.Name)
		}
		for _, f := range dt.Fields {
			newFields = append(newFields, f.Name)
		}
		use := "Old"
		if len(newFields) > len(oldFields) {
			use = "New"
		}
		if strings.Join(oldFields, ",") != strings.Join(newFields, ",") {
			warn("Warning: Type collision when adding new type %s!\n  New: id %s fields %v\n  Old: id %s fields %v\n  Using %s, which has more fields\n",
				dt.TypeName, r.ID(), newFields, a.refByType[dt.TypeName], oldFields, use)
		}
		if use == "Old" {
			return
		}
	}
	dbg("DEBUG NEW TYPE %s\n", prettify(dt))
	a.refByType[dt.TypeName] = r.ID()
	a.api.Types[dt.TypeName] = dt
}
func (a *APIAnalyzer) addType(ec EvalCtx, dt *gen.ObjectDataType, r Ref) {
	a.api.NeedJSON = true
	if a.refByType[dt.TypeName] == r.ID() {
		return
	}

	if other, ok := a.api.Types[dt.TypeName]; ok {
		if !ec.IsResult {
			// If its an input parameter, fix the collision by amending this types name
			dt.TypeName += "Param"
			if a.refByType[dt.TypeName] == r.ID() {
				return
			}
		}
		oldFields := []string{}
		newFields := []string{}
		for _, f := range other.Fields {
			oldFields = append(oldFields, f.Name)
		}
		for _, f := range dt.Fields {
			newFields = append(newFields, f.Name)
		}
		use := "Old"
		if len(newFields) > len(oldFields) {
			use = "New"
		}
		if strings.Join(oldFields, ",") != strings.Join(newFields, ",") {
			warn("Warning: Type collision when adding new type %s!\n  New: id %s fields %v\n  Old: id %s fields %v\n  Using %s, which has more fields\n",
				dt.TypeName, r.ID(), newFields, a.refByType[dt.TypeName], oldFields, use)
		}
		if use == "Old" {
			return
		}
	}
	dbg("DEBUG NEW TYPE %s\n", prettify(dt))
	a.refByType[dt.TypeName] = r.ID()
	a.api.Types[dt.TypeName] = dt
}
// addType conditionally adds a new type, trying its best to avoid type
// collisions. This is the downside of swagger 2 vs swagger 3. For swagger 2
// if you the same type like "User" returned in multiple places, each have to
// create their own definition in the swagger "definitions" section for goa
// v2. So they'll be X copies of identical definition for a User struct lets
// say. This tries to collapse those things down into one return type struct.