Skip to content

Commit 20c3865

Browse files
minenok-tutuMikailBag
authored andcommitted
File return type fix (OpenAPITools#5644)
* file return type fix * Update client.mustache
1 parent 804f2fc commit 20c3865

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/openapi-generator/src/main/resources/go/client.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"io"
12+
"io/ioutil"
1213
"log"
1314
"mime/multipart"
1415
"net/http"
@@ -392,6 +393,15 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
392393
*s = string(b)
393394
return nil
394395
}
396+
if f, ok := v.(**os.File); ok {
397+
*f, err = ioutil.TempFile("", "HttpClientFile")
398+
if err != nil {
399+
return
400+
}
401+
_, err = (*f).Write(b)
402+
_, err = (*f).Seek(0, io.SeekStart)
403+
return
404+
}
395405
if xmlCheck.MatchString(contentType) {
396406
if err = xml.Unmarshal(b, v); err != nil {
397407
return err

0 commit comments

Comments
 (0)