OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generating a Go client generates code which does not pass golint. Passing golint checks is important because it can detect Go anti-patterns. I listed some of the output below
api_health.go:27:6: type `HealthApiService` should be `HealthAPIService` (golint)
type HealthApiService service
^
api_public.go:1270:2: don't use underscores in Go names; struct field error_ should be error (golint)
error_ *string
^
api_public.go:1273:49: don't use underscores in Go names; method Error_ should be Error (golint)
func (r PublicApiApiGetSelfServiceErrorRequest) Error_(error_ string) PublicApiApiGetSelfServiceErrorRequest {
^
errcheck is not golint but detects missing error checks:
client.go:245:18: Error return value of `w.WriteField` is not checked (errcheck)
w.WriteField(k, iv)
^
client.go:115:6: SA6005: should use strings.EqualFold instead (staticcheck)
if strings.ToLower(a) == strings.ToLower(needle) {
^
Other code-"smells" not detected by golint or golangci-lint are:
[ ] non-nilable errors #8483
[ ] Abbreviated names are not capitalized (struct{ Id string `json:"id"` }) but should be (e.g. struct {ID string `json:"id"`})
[ ] Slice fields are referenced as pointers (struct Foo { Bar *[]Bar }) but should be referenced as regular slices (e.g. struct Foo { Bar []Bar }.
Bug Report Checklist
Description
Generating a Go client generates code which does not pass golint. Passing golint checks is important because it can detect Go anti-patterns. I listed some of the output below
errcheck
is not golint but detects missing error checks:Other code-"smells" not detected by golint or golangci-lint are:
struct{ Id string `json:"id"` }
) but should be (e.g.struct {ID string `json:"id"`}
)struct Foo { Bar *[]Bar }
) but should be referenced as regular slices (e.g.struct Foo { Bar []Bar }
.openapi-generator version
5.0.0
OpenAPI declaration file content or url
Any valid OpenAPI 3.0 schema.
Generation Details
Steps to reproduce
See above