swaggo / swag

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

Renaming of models #1789

Open aurelius15 opened 3 months ago

aurelius15 commented 3 months ago

Hello,

Could someone help me understand why annotations are added to rename the model at the end of the structure? From my point of view, it would be more consistent if we had it at the top of the structure.

https://github.com/swaggo/swag?tab=readme-ov-file#rename-model-to-display

From

type Resp struct {
    Code int
}//@name Response

To

// Resp - some info...
// @name MyAwesomeResponse
type Resp struct {
    Code int
}
sdghchj commented 3 months ago

As you known, the comments at the top of a function is taken as the doc element, so does goparser. But, it is a pity that goparser does not take the comments on the top of the type as its doc element. That is to say, in the eyes of goparser, the comments above a type definition have nothing to do with the type.