wI2L / fizz

:lemon: Gin wrapper with OpenAPI 3 spec generation
https://pkg.go.dev/github.com/wI2L/fizz
MIT License
214 stars 52 forks source link

desc in Response and ResponseWithExamples does not work #60

Closed jonas0616 closed 2 years ago

jonas0616 commented 3 years ago

I am trying to use fizz.Response to add additional errors in my documentation. However, the description seems does not work as expected. For example, add one of the following fizz options:

fizz.Response(fmt.Sprint(http.StatusNotFound), "my error desc", nil, nil, nil)
fizz.ResponseWithExamples(fmt.Sprint(http.StatusNotFound), "my error desc", nil, nil, nil)

I expect the description of the error should be my error desc, but it only shows Not Found in openapi.json.

wI2L commented 2 years ago

You are right, seems like the code do not honor the description provided with fizz.Response: https://github.com/wI2L/fizz/blob/14ef3251468432c8494c3e132c956d492f189133/openapi/generator.go#L381 we should check if the desc argument is empty, and replace it with a stringified description of the status code only in that case. I'll send a PR asap to fix it.