Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
System-Glitch committed Jul 1, 2023
1 parent 47a3007 commit 6d9ff3f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
18 changes: 8 additions & 10 deletions route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
5 changes: 4 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6d9ff3f

Please sign in to comment.