Skip to content

Commit

Permalink
[Golang] Move utility functions from client.mustache to utils.mustache (
Browse files Browse the repository at this point in the history
#19001)

* [Golang] Move utility functions from client.mustache to utils.mustache

* re-generate Go samples

* re-generate Go samples again

* re-generate samples once more

* update go samples

---------

Co-authored-by: Martin Lakov <martin.lakov@ocado.com>
  • Loading branch information
wing328 and martinlakov authored Jun 24, 2024
1 parent 1064cb6 commit d5f4250
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 108 deletions.
12 changes: 0 additions & 12 deletions modules/openapi-generator/src/main/resources/go/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,6 @@ func addFile(w *multipart.Writer, fieldName, path string) error {
return err
}

// Prevent trying to import "fmt"
func reportError(format string, a ...interface{}) error {
return fmt.Errorf(format, a...)
}

// A wrapper for strict JSON decoding
func newStrictDecoder(data []byte) *json.Decoder {
dec := json.NewDecoder(bytes.NewBuffer(data))
dec.DisallowUnknownFields()
return dec
}

// Set request body from an interface{}
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
if bodyBuf == nil {
Expand Down
14 changes: 14 additions & 0 deletions modules/openapi-generator/src/main/resources/go/utils.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
package {{packageName}}

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"time"
)
Expand Down Expand Up @@ -336,3 +338,15 @@ func IsNil(i interface{}) bool {
type MappedNullable interface {
ToMap() (map[string]interface{}, error)
}

// A wrapper for strict JSON decoding
func newStrictDecoder(data []byte) *json.Decoder {
dec := json.NewDecoder(bytes.NewBuffer(data))
dec.DisallowUnknownFields()
return dec
}

// Prevent trying to import "fmt"
func reportError(format string, a ...interface{}) error {
return fmt.Errorf(format, a...)
}
12 changes: 0 additions & 12 deletions samples/client/echo_api/go-external-refs/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions samples/client/echo_api/go-external-refs/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions samples/client/echo_api/go/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions samples/client/echo_api/go/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions samples/client/others/go/oneof-anyof-required/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions samples/client/others/go/oneof-anyof-required/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions samples/client/petstore/go/go-petstore/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions samples/client/petstore/go/go-petstore/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions samples/openapi3/client/petstore/go/go-petstore/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5f4250

Please # to comment.