forked from loafle/openapi-generator-original
fix(golang): make sure xml.Encoder is closed (#16141)
This commit is contained in:
parent
30c38ed7ad
commit
90eacb685c
@ -609,7 +609,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
|
|||||||
} else if jsonCheck.MatchString(contentType) {
|
} else if jsonCheck.MatchString(contentType) {
|
||||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||||
} else if xmlCheck.MatchString(contentType) {
|
} else if xmlCheck.MatchString(contentType) {
|
||||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
var bs []byte
|
||||||
|
bs, err = xml.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
bodyBuf.Write(bs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -556,7 +556,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
|
|||||||
} else if jsonCheck.MatchString(contentType) {
|
} else if jsonCheck.MatchString(contentType) {
|
||||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||||
} else if xmlCheck.MatchString(contentType) {
|
} else if xmlCheck.MatchString(contentType) {
|
||||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
var bs []byte
|
||||||
|
bs, err = xml.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
bodyBuf.Write(bs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -524,7 +524,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
|
|||||||
} else if jsonCheck.MatchString(contentType) {
|
} else if jsonCheck.MatchString(contentType) {
|
||||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||||
} else if xmlCheck.MatchString(contentType) {
|
} else if xmlCheck.MatchString(contentType) {
|
||||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
var bs []byte
|
||||||
|
bs, err = xml.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
bodyBuf.Write(bs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -574,7 +574,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
|
|||||||
} else if jsonCheck.MatchString(contentType) {
|
} else if jsonCheck.MatchString(contentType) {
|
||||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||||
} else if xmlCheck.MatchString(contentType) {
|
} else if xmlCheck.MatchString(contentType) {
|
||||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
var bs []byte
|
||||||
|
bs, err = xml.Marshal(body)
|
||||||
|
if err == nil {
|
||||||
|
bodyBuf.Write(bs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user