gen/goav2gen/definition.go
func (a *APIAnalyzer) AnalyzeDefinition(ec EvalCtx, def *Definition, refID string) gen.DataType {
	switch def.Type {
	case "array":
		elemT := a.typeForRef(ec, def.Items)
		apElem := &gen.ActionParam{
			Location: gen.PayloadParam,
			Type:     elemT,
		}
		return &gen.ArrayDataType{
			ElemType: apElem,
		}
	default:
		name := a.guessType(ec, def, refID)
		if name == "string" || name == "boolean" || name == "integer" {
			return basicType("string")
		}
		// else: object is assumed
		isRequired := map[string]bool{}
		for _, r := range def.Required {
			isRequired[r] = true
		}

		obj := &gen.ObjectDataType{TypeName: name}
		keys := []string{}
		for propName := range def.Properties {
			keys = append(keys, propName)
		}
		sort.Strings(keys)
		for _, propName := range keys {
			prop := def.Properties[propName]
			attr := a.AnalyzeProperty(ec.WithTrail(name), propName, isRequired[propName], prop)
			obj.Fields = append(obj.Fields, attr)
		}
		return obj
	}
}
func (a *APIAnalyzer) AnalyzeDefinition(ec EvalCtx, def *Definition, refID string) gen.DataType {
	switch def.Type {
	case "array":
		elemT := a.typeForRef(ec, def.Items)
		apElem := &gen.ActionParam{
			Location: gen.PayloadParam,
			Type:     elemT,
		}
		return &gen.ArrayDataType{
			ElemType: apElem,
		}
	default:
		name := a.guessType(ec, def, refID)
		if name == "string" || name == "boolean" || name == "integer" {
			return basicType("string")
		}
		// else: object is assumed
		isRequired := map[string]bool{}
		for _, r := range def.Required {
			isRequired[r] = true
		}

		obj := &gen.ObjectDataType{TypeName: name}
		keys := []string{}
		for propName := range def.Properties {
			keys = append(keys, propName)
		}
		sort.Strings(keys)
		for _, propName := range keys {
			prop := def.Properties[propName]
			attr := a.AnalyzeProperty(ec.WithTrail(name), propName, isRequired[propName], prop)
			obj.Fields = append(obj.Fields, attr)
		}
		return obj
	}
}
// AnalyzeDefinition analyzes a definition which is an object. Definitions are referenced by
// both inputs to requests (parameters) and outputs from requests (return types). EvalCtx
// will store which we're analyzing currently.