swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
3.66k stars 266 forks source link

support for function scoped struct in type method #277

Open win-arturo opened 10 months ago

win-arturo commented 10 months ago

Is your feature request related to a problem? Please describe. Using the gin framework, we have the handlers generally defined in a "service struct". The handlers often define their own input and output structs. The current function scoped struct support does not handle this case.

package bob

type service struct {}

// @Success 200 {object} bob.service.handleARequest.output "object containing the A" func (s service) handleARequest(ctx gin.context) { type input struct {} type output struct {A int} c.JSON(http.StatusOK, output{A:5} } Describe the solution you'd like Extend the function scoped struct feature to support methods of a type. Describe alternatives you've considered Pulling the struct out of the method works but is not the desired solution.

Additional context If this is desirable, I can probably add it.