-
Notifications
You must be signed in to change notification settings - Fork 1.4k
V2: --parseFuncBody does not work in conjunction with --v3.1 #2139
Copy link
Copy link
Open
Description
Describe the bug
When using the --v3.1 and --parseFuncBody flags together, the spec is generated but comments inside function bodies are not parsed.
Dropping the --v3.1 flag results in the function body comments being parsed correctly.
To Reproduce
Steps to reproduce the behavior:
- Create a function with swagger comments in the body:
func (s *Server) AddHandlers() {
router := s.router.PathPrefix("/motd").Subrouter()
// @Description "Get all Message of the Day objects"
// @Tags Motd
// @Success 200 {array} models.MotdMessage
// @Router /motd [get]
router.Path("").HandlerFunc(HandleGetAll[models.MotdMessage](s, "Motd")).Methods("GET")
// @Description "Create a new Message of the Day object"
// @Tags Motd
// @Param request body models.MotdMessage true "Partial Motd values for creating"
// @Success 201 {object} models.MotdMessage
// @Router /motd [post]
router.Path("").HandlerFunc(HandleCreate[models.MotdMessage](s)).Methods("POST")
}- Run
swag init --v3.1 --parseFuncBody - Notice the resulting spec does not include the routes from the function body comments.
- Running
swag init --parseFuncBodydoes work to generate a swagger 2.0 spec.
Expected behavior
Comments in the function body should be parsed.
Your swag version
v2.0.0-rc5
Your go version
1.25.5
Desktop (please complete the following information):
- OS: Linux (via WSL2)
- Browser: Firefox
Additional context
Function ParseRouterAPIInfoV3 in parserv3.go doesn't have any checks for parser.ParseFuncBody, so parsing the comments in the function body isn't even attempted.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels