swaggo / swag

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

Ignore omitted json fields from docs #160

Closed inoda closed 6 years ago

inoda commented 6 years ago

Is your feature request related to a problem? Please describe. I have a struct:

type RevenueMetricsTimeline struct {
    PrevPeriodUpperLimit    int64                     `json:"start"`
    CurrentPeriodUpperLimit int64                     `json:"end"`
    AllMetrisUpperLimit     int64                     `json:"-"`
}

The generated docs show "allMetrisUpperLimit" even though when converting this struct to json AllMetrisUpperLimit will be dropped.

Describe the solution you'd like Honor json encoding tags and omit fields with json:"-" from the documentation

Describe alternatives you've considered I could manually override the generated documentation, or write a script to do it, or create another struct just for documentation purposes.

pei0804 commented 6 years ago

We already support this case. https://github.com/swaggo/swag/blob/master/testdata/simple/web/handler.go#L31