From 6d9ff3f3be2d8cce032639009f52078dd90839bb Mon Sep 17 00:00:00 2001 From: SystemGlitch Date: Sat, 1 Jul 2023 22:06:50 +0200 Subject: [PATCH] Fix lint issues --- route.go | 18 ++++++++---------- route_test.go | 6 +++--- ui.go | 5 ++++- validation.go | 5 ++++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/route.go b/route.go index ed13e73..ed6503c 100644 --- a/route.go +++ b/route.go @@ -169,15 +169,14 @@ func (c *RouteConverter) convertPathParameters(path *openapi3.PathItem, spec *op } path.Parameters = append(path.Parameters, paramRef) break - } else { - param := openapi3.NewPathParameter(p) - param.Schema = schemaRef - spec.Components.Parameters[paramName] = &openapi3.ParameterRef{Value: param} - paramRef := &openapi3.ParameterRef{Ref: "#/components/parameters/" + paramName} - c.refs.Parameters[paramName] = paramRef - path.Parameters = append(path.Parameters, paramRef) - break } + param := openapi3.NewPathParameter(p) + param.Schema = schemaRef + spec.Components.Parameters[paramName] = &openapi3.ParameterRef{Value: param} + paramRef := &openapi3.ParameterRef{Ref: "#/components/parameters/" + paramName} + c.refs.Parameters[paramName] = paramRef + path.Parameters = append(path.Parameters, paramRef) + break } } } @@ -201,9 +200,8 @@ func (c *RouteConverter) getParamSchema(paramName, format string, spec *openapi3 i++ schemaName = fmt.Sprintf("%s.%d", originalSchemaName, i) continue - } else { - return cached } + return cached } break } diff --git a/route_test.go b/route_test.go index b05b13c..4703828 100644 --- a/route_test.go +++ b/route_test.go @@ -193,17 +193,17 @@ func (suite *RouteTestSuite) TestReadDescriptionCached() { } // HandlerTest a test handler for AST reading -func HandlerTest(resp *goyave.Response, req *goyave.Request) { +func HandlerTest(resp *goyave.Response, _ *goyave.Request) { resp.Status(http.StatusOK) } type testController struct{} -func (c *testController) handlerStar(resp *goyave.Response, req *goyave.Request) { +func (c *testController) handlerStar(resp *goyave.Response, _ *goyave.Request) { resp.Status(http.StatusOK) } -func (c testController) handler(resp *goyave.Response, req *goyave.Request) { +func (c testController) handler(resp *goyave.Response, _ *goyave.Request) { resp.Status(http.StatusOK) } diff --git a/ui.go b/ui.go index 1218a5e..54f30ff 100644 --- a/ui.go +++ b/ui.go @@ -123,7 +123,10 @@ func Serve(router *goyave.Router, uri string, opts *UIOptions) { tmpl := template.Must(template.New("swaggerui").Parse(uiTemplate)) buf := bytes.NewBuffer(nil) - tmpl.Execute(buf, opts) + err := tmpl.Execute(buf, opts) + if err != nil { + panic(err) + } b := buf.Bytes() r.Get("/", func(resp *goyave.Response, req *goyave.Request) { diff --git a/validation.go b/validation.go index d977728..1030893 100644 --- a/validation.go +++ b/validation.go @@ -208,7 +208,10 @@ func addSchema(field *validation.Field, path *walk.Path, currentElement *openapi } switch path.Type { case walk.PathTypeElement: - mergo.Merge(element.Value, schema) + err := mergo.Merge(element.Value, schema) + if err != nil { + panic(err) + } if field.IsRequired() && path.Name != "" { currentElement.Value.Required = append(currentElement.Value.Required, path.Name) }