Issue Description
Swaggo fails to recursively parse Swagger comments in Go files when using the swag init
command with multiple directories and the --parseDependency
and --parseInternal
flags. Only the comments in the main file specified with the -g
flag are parsed, while the comments in other files within the specified directories are not considered.
Files that contain swaggo comments are internal/transport/http/v1/auth.go, internal/transport/http/v1/trip.go, and cmd/app/main.go
Repo structure is here
commands I have run:
swag init -d cmd[enter image description here][1]/app/ -g main.go --parseDependency --parseInternal
swag init -d cmd/app/,internal/transport/http/v1 -g main.go --parseDependency --parseInternal
All the commands above produces the same result
Results
2023/06/29 17:45:38 Generate swagger docs....
2023/06/29 17:45:38 Generate general API Info, search dir:cmd/app/
2023/06/29 17:45:38 Generate general API Info, search dir:internal/transport/http/v1
2023/06/29 17:45:40 warning: failed to evaluate const mProfCycleWrap at /usr/local/go/src/runtime/mprof.go:165:7, reflect: call of reflect.Value.Len on zero Value
2023/06/29 17:45:40 warning: failed to evaluate const locb at /Users/ikramkamat/go/GoWorkSpace/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.8/internal/characters/utf8.go:183:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const hicb at /Users/ikramkamat/go/GoWorkSpace/pkg/mod/github.com/pelletier/go-toml/v2@v2.0.8/internal/characters/utf8.go:184:2, strconv.ParseUint: parsing "b10111111": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const t1 at /usr/local/go/src/unicode/utf8/utf8.go:29:2, strconv.ParseUint: parsing "b00000000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const tx at /usr/local/go/src/unicode/utf8/utf8.go:30:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const t2 at /usr/local/go/src/unicode/utf8/utf8.go:31:2, strconv.ParseUint: parsing "b11000000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const t3 at /usr/local/go/src/unicode/utf8/utf8.go:32:2, strconv.ParseUint: parsing "b11100000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const t4 at /usr/local/go/src/unicode/utf8/utf8.go:33:2, strconv.ParseUint: parsing "b11110000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const t5 at /usr/local/go/src/unicode/utf8/utf8.go:34:2, strconv.ParseUint: parsing "b11111000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const maskx at /usr/local/go/src/unicode/utf8/utf8.go:36:2, strconv.ParseUint: parsing "b00111111": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const mask2 at /usr/local/go/src/unicode/utf8/utf8.go:37:2, strconv.ParseUint: parsing "b00011111": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const mask3 at /usr/local/go/src/unicode/utf8/utf8.go:38:2, strconv.ParseUint: parsing "b00001111": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const mask4 at /usr/local/go/src/unicode/utf8/utf8.go:39:2, strconv.ParseUint: parsing "b00000111": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const locb at /usr/local/go/src/unicode/utf8/utf8.go:46:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/06/29 17:45:40 warning: failed to evaluate const hicb at /usr/local/go/src/unicode/utf8/utf8.go:47:2, strconv.ParseUint: parsing "b10111111": invalid syntax
2023/06/29 17:45:40 create docs.go at docs/docs.go
2023/06/29 17:45:40 create swagger.json at docs/swagger.json
2023/06/29 17:45:40 create swagger.yaml at docs/swagger.yaml
generated swagger.yaml
basePath: /api/v1
host: localhost:8000
info:
contact: {}
description: REST API for InnoCoTravel App
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
title: InnoCoTravel API
version: "1.0"
paths: {}
securityDefinitions:
ApiKeyAuth:
in: header
name: Authorization
type: apiKey
swagger: "2.0"
Comments in one of the files other than cmd/app/main.g
package v1
import (
"encoding/json"
"net/http"
"github.com/gin-gonic/gin"
_ "github.com/itoqsky/InnoCoTravel-backend/docs"
"github.com/itoqsky/InnoCoTravel-backend/internal/core"
)
// @Summary SignUp
// @Tags auth
// @Description create account
// @ModuleID signUp
// @ID create-account
// @Accept json
// @Produce json
// @Param input body core.User true "sign up info"
// @Success 200 {integer} integer
// @Failure 400 {object} errorResponse
// @Failure 404 {object} errorResponse
// @Failure 500 {object} errorResponse
// @Failure default {object} errorResponse
// @Router /auth/sign-up [post]
func (h *Handler) signUp(c *gin.Context) {
<other code>
swag version e.g. 1.8.12
go version e.g. 1.20.2
OS OSX