-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go Swagger Annotation Considered deadcode #1304
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Work around
|
It's not mentioned anywhere, you need to use it somewhere in the code. Now the I would suggest you to use it in the handler: func (s *IntegrationService) handlePostItem(c echo.Context) error {
var doc appSwaggerParameterDefinition
c.Bind(&doc)
...
} |
@SVilgelm Your solution is clever, however I think Go Swagger ties the annotation in the handler and struct definition so instantiating the struct from the context in the handler isn't necessary. |
nope, it's not doing any magic, If you have a generated code and that code uses the otherwise you have a definition, but go does not use it and it probably uses map[string]interface{} instead of the |
Well the code is not used in production however the Swagger annotation is used by the ( swagger ) cli which will use a code ( model scan ) to generate apidocs. Thus maybe the best solution is to just use ( nolint:deadcode ). |
actually you just store the definitions and uses them in another project. In this case yes you are right, using the |
Yeah right probably not a ( deadcode ) bug I see now. |
so. I'm closing the issue |
Yeah close, hopefully other people who are confused by swaggers interaction with deadcode can find this thread useful and use ( nolint:deadcode ) |
The golangci-lint deadcode lint incorrectly considers swagger annotation as dead code.
The golangci-lint version
The golangcli-lint validation failure
However this is not dead code as it is a type of swagger annotation.
The text was updated successfully, but these errors were encountered: