effectiveClientResponseBody returns the response body shape used by client code generation. When the design fixes the response to a single view, the returned attribute uses that projected ResultType so type collection, union collection, and client decode/init all agree on one transport body.
(body *expr.AttributeExpr, e *expr.HTTPEndpointExpr, md *service.MethodData)
| 2789 | // returned attribute uses that projected ResultType so type collection, union |
| 2790 | // collection, and client decode/init all agree on one transport body. |
| 2791 | func effectiveClientResponseBody(body *expr.AttributeExpr, e *expr.HTTPEndpointExpr, md *service.MethodData) *expr.AttributeExpr { |
| 2792 | if body == nil { |
| 2793 | return body |
| 2794 | } |
| 2795 | view := clientResponseViewName(e, md) |
| 2796 | if view == "" { |
| 2797 | return body |
| 2798 | } |
| 2799 | body = expr.DupAtt(body) |
| 2800 | rt, ok := body.Type.(*expr.ResultTypeExpr) |
| 2801 | if !ok { |
| 2802 | return body |
| 2803 | } |
| 2804 | projected, err := expr.Project(rt, view) |
| 2805 | if err != nil { |
| 2806 | panic(err) // bug |
| 2807 | } |
| 2808 | body.Type = projected |
| 2809 | return body |
| 2810 | } |
| 2811 | |
| 2812 | // clientResponseViewName returns the response view used by client code |
| 2813 | // generation when the design fixes the response to a single view. An empty |
no test coverage detected