From 779d3371cff6f7f466c0eec7f7a490d28ca108f1 Mon Sep 17 00:00:00 2001 From: Hamed Abdollahpour Date: Mon, 14 Nov 2022 18:40:43 +0100 Subject: [PATCH] Fix error handler for required query parameters --- pkg/codegen/templates/gin/gin-wrappers.tmpl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/codegen/templates/gin/gin-wrappers.tmpl b/pkg/codegen/templates/gin/gin-wrappers.tmpl index 3c11bcdbe3..1757d95826 100644 --- a/pkg/codegen/templates/gin/gin-wrappers.tmpl +++ b/pkg/codegen/templates/gin/gin-wrappers.tmpl @@ -62,16 +62,15 @@ func (siw *ServerInterfaceWrapper) {{$opid}}(c *gin.Context) { var value {{.TypeDef}} err = json.Unmarshal([]byte(paramValue), &value) if err != nil { - siw.ErrorHandler(c, fmt.Errorf("Error unmarshalling parameter '{{.ParamName}}' as JSON: %s", err), http.StatusBadRequest) { + siw.ErrorHandler(c, fmt.Errorf("Error unmarshalling parameter '{{.ParamName}}' as JSON: %s", err), http.StatusBadRequest) return } params.{{.GoName}} = {{if not .Required}}&{{end}}value {{end}} }{{if .Required}} else { - if !siw.ErrorHandler(c, fmt.Errorf("Query argument {{.ParamName}} is required, but not found: %s", err), http.StatusBadRequest) { - return - } + siw.ErrorHandler(c, fmt.Errorf("Query argument {{.ParamName}} is required, but not found: %s", err), http.StatusBadRequest) + return }{{end}} {{end}}