mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
[go-server] fix addResponseHeaders tpl option typo (#9814)
According to the [documentation](https://openapi-generator.tech/docs/generators/go-server) the go-server generator should support an `addResponseHeaders` option but a template uses an `addResponseHeader` option in some places which this PR fixes. Closes #9795 Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
This commit is contained in:
parent
939b5f6bb8
commit
2e85ccdec8
@ -88,7 +88,7 @@ func NewRouter(routers ...Router) {{#routers}}{{#mux}}*mux.Router{{/mux}}{{#chi}
|
|||||||
|
|
||||||
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
||||||
func EncodeJSONResponse(i interface{}, status *int,{{#addResponseHeaders}} headers map[string][]string,{{/addResponseHeaders}} w http.ResponseWriter) error {
|
func EncodeJSONResponse(i interface{}, status *int,{{#addResponseHeaders}} headers map[string][]string,{{/addResponseHeaders}} w http.ResponseWriter) error {
|
||||||
{{#addResponseHeader}}
|
{{#addResponseHeaders}}
|
||||||
wHeader := w.Header()
|
wHeader := w.Header()
|
||||||
if headers != nil {
|
if headers != nil {
|
||||||
for key, values := range headers {
|
for key, values := range headers {
|
||||||
@ -98,10 +98,10 @@ func EncodeJSONResponse(i interface{}, status *int,{{#addResponseHeaders}} heade
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wHeader.Set("Content-Type", "application/json; charset=UTF-8")
|
wHeader.Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
{{/addResponseHeader}}
|
{{/addResponseHeaders}}
|
||||||
{{^addResponseHeader}}
|
{{^addResponseHeaders}}
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
{{/addResponseHeader}}
|
{{/addResponseHeaders}}
|
||||||
if status != nil {
|
if status != nil {
|
||||||
w.WriteHeader(*status)
|
w.WriteHeader(*status)
|
||||||
} else {
|
} else {
|
||||||
|
@ -61,7 +61,15 @@ func NewRouter(routers ...Router) *mux.Router {
|
|||||||
|
|
||||||
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
||||||
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error {
|
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
wHeader := w.Header()
|
||||||
|
if headers != nil {
|
||||||
|
for key, values := range headers {
|
||||||
|
for _, value := range values {
|
||||||
|
wHeader.Add(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wHeader.Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
if status != nil {
|
if status != nil {
|
||||||
w.WriteHeader(*status)
|
w.WriteHeader(*status)
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +57,15 @@ func NewRouter(routers ...Router) chi.Router {
|
|||||||
|
|
||||||
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
|
||||||
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error {
|
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
wHeader := w.Header()
|
||||||
|
if headers != nil {
|
||||||
|
for key, values := range headers {
|
||||||
|
for _, value := range values {
|
||||||
|
wHeader.Add(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wHeader.Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
if status != nil {
|
if status != nil {
|
||||||
w.WriteHeader(*status)
|
w.WriteHeader(*status)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user