diff --git a/gen/_template/parameter_encode.tmpl b/gen/_template/parameter_encode.tmpl index 55544514c..f6b3a46e0 100644 --- a/gen/_template/parameter_encode.tmpl +++ b/gen/_template/parameter_encode.tmpl @@ -90,10 +90,10 @@ cookie := uri.NewCookieEncoder(r) {{- $param := $ }} {{- $el := elem $param.Type (printf "params.%s" $param.Name) }} {{- if $param.Spec.Content }} - enc := jx.GetEncoder() + var enc jx.Encoder func(e *jx.Encoder) { {{- template "json/enc" $el }} - }(enc) + }(&enc) return e.EncodeValue(string(enc.Bytes())) {{- else }} {{- template "uri/encode" $el }} diff --git a/gen/_template/request_encode.tmpl b/gen/_template/request_encode.tmpl index 584eb2586..9d04b20fd 100644 --- a/gen/_template/request_encode.tmpl +++ b/gen/_template/request_encode.tmpl @@ -121,7 +121,7 @@ func encode{{ $op.Name }}Request( }) ht.SetCloserBody(r, body, contentType) {{- else }} - e := jx.GetEncoder() + e := new(jx.Encoder) { {{- template "json/enc" elem $type "req" }} } diff --git a/gen/_template/response_encode.tmpl b/gen/_template/response_encode.tmpl index 9cdc5e13a..8bfd98157 100644 --- a/gen/_template/response_encode.tmpl +++ b/gen/_template/response_encode.tmpl @@ -76,10 +76,10 @@ func encode{{ $op.Name }}Response(response {{ $op.Responses.GoType }}, w http.Re if err := h.EncodeParam(cfg, func(e uri.Encoder) error{ {{- $el := elem $header.Type (printf "response.%s" $header.Name) }} {{- if $header.Spec.Content }} - enc := jx.GetEncoder() + var enc jx.Encoder func(e *jx.Encoder) { {{ template "json/enc" $el }} - }(enc) + }(&enc) return e.EncodeValue(string(enc.Bytes())) {{- else }} {{- template "uri/encode" $el }} @@ -132,7 +132,7 @@ func encode{{ $op.Name }}Response(response {{ $op.Responses.GoType }}, w http.Re return errors.Wrap(err, "flush streaming") } {{- else }} - e := jx.GetEncoder() + e := new(jx.Encoder) {{- template "json/enc" elem $type $var }} if _, err := e.WriteTo(w); err != nil { return errors.Wrap(err, "write")