swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.4k stars 1.18k forks source link

--parseDepth not working #1347

Open ElegantSoft opened 1 year ago

ElegantSoft commented 1 year ago

Describe the bug when I add --parseDepth 1 the generated code has more than 1 depth

To Reproduce Steps to reproduce the behavior:

  1. create any struct with more than 1 depth
  2. generate swag init --parseDepth 1 --parseDependency --parseInternal
  3. the result not respect depth flag

Expected behavior generated docs respect depth flag.

Screenshots image

Your swag version v1.8.6

Your go version go version go1.19.1 linux/amd64

Desktop (please complete the following information):

Waruhu commented 1 year ago

I have same issue with this feature, need help from you guys, is very help full if some can give me the explanation or comment this thread.

I have indirect import package like this when I implement feature-flags direct Import: github.com/thomaspoignant/go-feature-flag Indirect Import: https://github.com/antlr/antlr4

github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20220911224424-aa1f1f12a846 // indirect

Then when I execute make swaggo on my project than I got the issue like this:

image

and I go in-deep to this file diagnostic_error_listener.go then I see there a function that make a comment same with swaggo common parameter @param https://github.com/swaggo/swag#declarative-comments-format:~:text=Mime%20Types.-,param,type%2Cdata%20type%2Cis%20mandatory%3F%2Ccomment%20attribute(optional),-security

// Computes the set of conflicting or ambiguous alternatives from a
// configuration set, if that information was not already provided by the
// parser.
//
// @param ReportedAlts The set of conflicting or ambiguous alternatives, as
// Reported by the parser.
// @param configs The conflicting or ambiguous configuration set.
// @return Returns {@code ReportedAlts} if it is not {@code nil}, otherwise
// returns the set of alternatives represented in {@code configs}.
func (d *DiagnosticErrorListener) getConflictingAlts(ReportedAlts *BitSet, set ATNConfigSet) *BitSet {
    if ReportedAlts != nil {
        return ReportedAlts
    }
    result := NewBitSet()
    for _, c := range set.GetItems() {
        result.add(c.GetAlt())
    }

    return result
}

I try to run with command --parseDepth 1 is not working @go env GOPATH/bin/swag init -g ./src/cmd/main.go -o ./docs/swagger --pd --parseInternal --parseDepth 1 --parseGoList -q