diff --git a/examples/petstore-expanded/api/petstore.gen.go b/examples/petstore-expanded/api/petstore.gen.go index c2774862..d09052a5 100644 --- a/examples/petstore-expanded/api/petstore.gen.go +++ b/examples/petstore-expanded/api/petstore.gen.go @@ -225,7 +225,11 @@ func (siw *ServerInterfaceWrapper) FindPets(w http.ResponseWriter, r *http.Reque var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.FindPets(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -239,7 +243,11 @@ func (siw *ServerInterfaceWrapper) AddPet(w http.ResponseWriter, r *http.Request var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.AddPet(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -261,7 +269,11 @@ func (siw *ServerInterfaceWrapper) DeletePet(w http.ResponseWriter, r *http.Requ var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.DeletePet(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -283,7 +295,11 @@ func (siw *ServerInterfaceWrapper) FindPetByID(w http.ResponseWriter, r *http.Re var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.FindPetByID(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) diff --git a/internal/test/components/components.gen.go b/internal/test/components/components.gen.go index 18d90640..42ea0230 100644 --- a/internal/test/components/components.gen.go +++ b/internal/test/components/components.gen.go @@ -863,7 +863,11 @@ func (siw *ServerInterfaceWrapper) EnsureEverythingIsReferenced(w http.ResponseW var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.EnsureEverythingIsReferenced(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -896,7 +900,11 @@ func (siw *ServerInterfaceWrapper) ParamsWithAddProps(w http.ResponseWriter, r * var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.ParamsWithAddProps(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -910,7 +918,11 @@ func (siw *ServerInterfaceWrapper) BodyWithAddProps(w http.ResponseWriter, r *ht var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.BodyWithAddProps(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) diff --git a/internal/test/parameters/parameters.gen.go b/internal/test/parameters/parameters.gen.go index 36b02ede..adb2ee21 100644 --- a/internal/test/parameters/parameters.gen.go +++ b/internal/test/parameters/parameters.gen.go @@ -251,7 +251,11 @@ func (siw *ServerInterfaceWrapper) GetContentObject(w http.ResponseWriter, r *ht var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetContentObject(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -357,7 +361,11 @@ func (siw *ServerInterfaceWrapper) GetCookie(w http.ResponseWriter, r *http.Requ var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetCookie(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -520,7 +528,11 @@ func (siw *ServerInterfaceWrapper) GetHeader(w http.ResponseWriter, r *http.Requ var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetHeader(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -542,7 +554,11 @@ func (siw *ServerInterfaceWrapper) GetLabelExplodeArray(w http.ResponseWriter, r var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetLabelExplodeArray(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -564,7 +580,11 @@ func (siw *ServerInterfaceWrapper) GetLabelExplodeObject(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetLabelExplodeObject(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -586,7 +606,11 @@ func (siw *ServerInterfaceWrapper) GetLabelNoExplodeArray(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetLabelNoExplodeArray(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -608,7 +632,11 @@ func (siw *ServerInterfaceWrapper) GetLabelNoExplodeObject(w http.ResponseWriter var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetLabelNoExplodeObject(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -630,7 +658,11 @@ func (siw *ServerInterfaceWrapper) GetMatrixExplodeArray(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetMatrixExplodeArray(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -652,7 +684,11 @@ func (siw *ServerInterfaceWrapper) GetMatrixExplodeObject(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetMatrixExplodeObject(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -674,7 +710,11 @@ func (siw *ServerInterfaceWrapper) GetMatrixNoExplodeArray(w http.ResponseWriter var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetMatrixNoExplodeArray(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -696,7 +736,11 @@ func (siw *ServerInterfaceWrapper) GetMatrixNoExplodeObject(w http.ResponseWrite var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetMatrixNoExplodeObject(w, r, id) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -715,7 +759,11 @@ func (siw *ServerInterfaceWrapper) GetPassThrough(w http.ResponseWriter, r *http var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetPassThrough(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -740,7 +788,11 @@ func (siw *ServerInterfaceWrapper) GetDeepObject(w http.ResponseWriter, r *http. var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetDeepObject(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -834,7 +886,11 @@ func (siw *ServerInterfaceWrapper) GetQueryForm(w http.ResponseWriter, r *http.R var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetQueryForm(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -856,7 +912,11 @@ func (siw *ServerInterfaceWrapper) GetSimpleExplodeArray(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimpleExplodeArray(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -878,7 +938,11 @@ func (siw *ServerInterfaceWrapper) GetSimpleExplodeObject(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimpleExplodeObject(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -900,7 +964,11 @@ func (siw *ServerInterfaceWrapper) GetSimpleNoExplodeArray(w http.ResponseWriter var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimpleNoExplodeArray(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -922,7 +990,11 @@ func (siw *ServerInterfaceWrapper) GetSimpleNoExplodeObject(w http.ResponseWrite var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimpleNoExplodeObject(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -944,7 +1016,11 @@ func (siw *ServerInterfaceWrapper) GetSimplePrimitive(w http.ResponseWriter, r * var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimplePrimitive(w, r, param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -963,7 +1039,11 @@ func (siw *ServerInterfaceWrapper) GetStartingWithNumber(w http.ResponseWriter, var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetStartingWithNumber(w, r, n1param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) diff --git a/internal/test/schemas/schemas.gen.go b/internal/test/schemas/schemas.gen.go index 3c4c8463..dcc5e8c0 100644 --- a/internal/test/schemas/schemas.gen.go +++ b/internal/test/schemas/schemas.gen.go @@ -320,7 +320,11 @@ func (siw *ServerInterfaceWrapper) EnsureEverythingIsReferenced(w http.ResponseW var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.EnsureEverythingIsReferenced(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -336,7 +340,11 @@ func (siw *ServerInterfaceWrapper) Issue127(w http.ResponseWriter, r *http.Reque var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue127(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -352,7 +360,11 @@ func (siw *ServerInterfaceWrapper) Issue185(w http.ResponseWriter, r *http.Reque var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue185(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -376,7 +388,11 @@ func (siw *ServerInterfaceWrapper) Issue209(w http.ResponseWriter, r *http.Reque var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue209(w, r, str) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -400,7 +416,11 @@ func (siw *ServerInterfaceWrapper) Issue30(w http.ResponseWriter, r *http.Reques var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue30(w, r, pFallthrough) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -416,7 +436,11 @@ func (siw *ServerInterfaceWrapper) GetIssues375(w http.ResponseWriter, r *http.R var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetIssues375(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -440,7 +464,11 @@ func (siw *ServerInterfaceWrapper) Issue41(w http.ResponseWriter, r *http.Reques var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue41(w, r, n1param) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -467,7 +495,11 @@ func (siw *ServerInterfaceWrapper) Issue9(w http.ResponseWriter, r *http.Request var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.Issue9(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -494,7 +526,11 @@ func (siw *ServerInterfaceWrapper) GetPr66(w http.ResponseWriter, r *http.Reques var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetPr66(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -521,7 +557,11 @@ func (siw *ServerInterfaceWrapper) PostPr66(w http.ResponseWriter, r *http.Reque var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.PostPr66(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) diff --git a/internal/test/server/server.gen.go b/internal/test/server/server.gen.go index a6b6c426..4d163bf3 100644 --- a/internal/test/server/server.gen.go +++ b/internal/test/server/server.gen.go @@ -375,7 +375,11 @@ func (siw *ServerInterfaceWrapper) GetEveryTypeOptional(w http.ResponseWriter, r var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetEveryTypeOptional(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -389,7 +393,11 @@ func (siw *ServerInterfaceWrapper) GetSimple(w http.ResponseWriter, r *http.Requ var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetSimple(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -442,7 +450,11 @@ func (siw *ServerInterfaceWrapper) GetWithArgs(w http.ResponseWriter, r *http.Re var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetWithArgs(w, r, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -472,7 +484,11 @@ func (siw *ServerInterfaceWrapper) GetWithReferences(w http.ResponseWriter, r *h var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetWithReferences(w, r, globalArgument, argument) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -494,7 +510,11 @@ func (siw *ServerInterfaceWrapper) GetWithContentType(w http.ResponseWriter, r * var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetWithContentType(w, r, contentType) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -508,7 +528,11 @@ func (siw *ServerInterfaceWrapper) GetReservedKeyword(w http.ResponseWriter, r * var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetReservedKeyword(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -530,7 +554,11 @@ func (siw *ServerInterfaceWrapper) CreateResource(w http.ResponseWriter, r *http var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.CreateResource(w, r, argument) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -563,7 +591,11 @@ func (siw *ServerInterfaceWrapper) CreateResource2(w http.ResponseWriter, r *htt var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.CreateResource2(w, r, inlineArgument, params) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -585,7 +617,11 @@ func (siw *ServerInterfaceWrapper) UpdateResource3(w http.ResponseWriter, r *htt var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.UpdateResource3(w, r, pFallthrough) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -599,7 +635,11 @@ func (siw *ServerInterfaceWrapper) GetResponseWithReference(w http.ResponseWrite var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetResponseWithReference(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -613,7 +653,11 @@ func (siw *ServerInterfaceWrapper) GetWithTaggedMiddleware(w http.ResponseWriter var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.GetWithTaggedMiddleware(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) @@ -630,7 +674,11 @@ func (siw *ServerInterfaceWrapper) PostWithTaggedMiddleware(w http.ResponseWrite var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.PostWithTaggedMiddleware(w, r) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } }) diff --git a/templates/middleware.tmpl b/templates/middleware.tmpl index 8f02ff59..a4d4271b 100644 --- a/templates/middleware.tmpl +++ b/templates/middleware.tmpl @@ -158,7 +158,11 @@ func (siw *ServerInterfaceWrapper) {{$opid}}(w http.ResponseWriter, r *http.Requ var handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { resp := siw.Handler.{{.OperationID}}(w, r{{genParamNames .PathParams}}{{if .RequiresParamObject}}, params{{end}}) if resp != nil { - render.Render(w, r, resp) + if resp.body != nil { + render.Render(w, r, resp) + } else { + w.WriteHeader(resp.Code) + } } })