swaggo / swag

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

feat: ParseComment error to contain the comment #1777

Open stokito opened 5 months ago

stokito commented 5 months ago

When a comment has an error then we print only a file name and the error text but not the comment that caused an error. To make it easier to understand print it.

Context: I spent a lot of time while investigating the error message:

Generating dto.DeleteRequest
Key is not supported paramType

It turned out that the DTO was fine but a problem was in another place with a comment:

// @Param User Key body dto.UserRequest true "Event"

In the comment instead of UserKey it was written User Key and the Key was threatened as a paramType. I wasn't able to figure out which key they are talking about.

So the change should significantly improve troubleshooting which is important.