You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it currently stands, comments inside of a function body are not parsed by swag. As an example, given an anonymous handler inside of a function with a comment and another handler outside, also with a comment:
// @Router /api/inside [get] will not be parsed while // @Router /api/outside [get] will get parsed. This behavior means that the use of anonymous function handlers is not possible if you also want to use swag.
Solution
I would like to add support for parsing comments inside of function bodies. This could be achieved by adding an optional boolean flag to control parsing all comments as opposed to only doc comments as it is today. The ast.File object that is currently used for parsing doc comments already contains all comments from a given source file. As such, adding this feature would require only minimal changes to the package. Additionally, by adding a flag to control this behavior, it would be opt-in only and would not disrupt users who are expecting the current behavior.
The text was updated successfully, but these errors were encountered:
Problem
Hello all!
As it currently stands, comments inside of a function body are not parsed by
swag
. As an example, given an anonymous handler inside of a function with a comment and another handler outside, also with a comment:// @Router /api/inside [get]
will not be parsed while// @Router /api/outside [get]
will get parsed. This behavior means that the use of anonymous function handlers is not possible if you also want to useswag
.Solution
I would like to add support for parsing comments inside of function bodies. This could be achieved by adding an optional boolean flag to control parsing all comments as opposed to only doc comments as it is today. The
ast.File
object that is currently used for parsing doc comments already contains all comments from a given source file. As such, adding this feature would require only minimal changes to the package. Additionally, by adding a flag to control this behavior, it would be opt-in only and would not disrupt users who are expecting the current behavior.The text was updated successfully, but these errors were encountered: