| 2754 | } |
| 2755 | |
| 2756 | func collectHTTPUnionTypes(att *expr.AttributeExpr, scope *codegen.NameScope, unions map[string]*service.UnionTypeData, seen map[string]struct{}) { |
| 2757 | if att == nil || att.Type == expr.Empty { |
| 2758 | return |
| 2759 | } |
| 2760 | switch dt := att.Type.(type) { |
| 2761 | case expr.UserType: |
| 2762 | if _, ok := seen[dt.ID()]; ok { |
| 2763 | return |
| 2764 | } |
| 2765 | seen[dt.ID()] = struct{}{} |
| 2766 | collectHTTPUnionTypes(dt.Attribute(), scope, unions, seen) |
| 2767 | case *expr.Object: |
| 2768 | for _, nat := range sortedNamedAttributes(*dt) { |
| 2769 | collectHTTPUnionTypes(nat.Attribute, scope, unions, seen) |
| 2770 | } |
| 2771 | case *expr.Array: |
| 2772 | collectHTTPUnionTypes(dt.ElemType, scope, unions, seen) |
| 2773 | case *expr.Map: |
| 2774 | collectHTTPUnionTypes(dt.KeyType, scope, unions, seen) |
| 2775 | collectHTTPUnionTypes(dt.ElemType, scope, unions, seen) |
| 2776 | case *expr.Union: |
| 2777 | hash := dt.Hash() |
| 2778 | if _, ok := unions[hash]; !ok { |
| 2779 | unions[hash] = buildHTTPUnionTypeData(dt, scope) |
| 2780 | } |
| 2781 | for _, nat := range dt.Values { |
| 2782 | collectHTTPUnionTypes(nat.Attribute, scope, unions, seen) |
| 2783 | } |
| 2784 | } |
| 2785 | } |
| 2786 | |
| 2787 | // effectiveClientResponseBody returns the response body shape used by client |
| 2788 | // code generation. When the design fixes the response to a single view, the |