diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache index c73470708d6..a9b82e3ff7d 100644 --- a/modules/openapi-generator/src/main/resources/go/client.mustache +++ b/modules/openapi-generator/src/main/resources/go/client.mustache @@ -101,6 +101,10 @@ func selectHeaderAccept(accepts []string) string { return "" } + if contains(accepts, "application/json") { + return "application/json" + } + return strings.Join(accepts, ",") } diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index ec3dfad98ae..d28e9c440b6 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -109,6 +109,10 @@ func selectHeaderAccept(accepts []string) string { return "" } + if contains(accepts, "application/json") { + return "application/json" + } + return strings.Join(accepts, ",") } diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go index 0a5ca0e52d8..b812ae69158 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go +++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go @@ -94,6 +94,10 @@ func selectHeaderAccept(accepts []string) string { return "" } + if contains(accepts, "application/json") { + return "application/json" + } + return strings.Join(accepts, ",") } diff --git a/samples/openapi3/client/petstore/go/go-petstore/client.go b/samples/openapi3/client/petstore/go/go-petstore/client.go index 260ab6781cf..c3ab7d2b8ec 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/client.go +++ b/samples/openapi3/client/petstore/go/go-petstore/client.go @@ -112,6 +112,10 @@ func selectHeaderAccept(accepts []string) string { return "" } + if contains(accepts, "application/json") { + return "application/json" + } + return strings.Join(accepts, ",") }