You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting tired from adding the same [ProducesResponseType] attribute on my WebAPI controller methods over and over, and I thought there must be an easier, convention based way. I mean, the method clearly tells the return type:
return HTTP 204 NoContent when the return type is void (or just a Task)
return HTTP 200 Ok when the return type is a specific type (or a Task of a specific type) and derive the schema from the CLR's response type
However, this looks way too easy while being too useful for something that hasn't been done before. I am wondering why this one isn't part of NSwag and if I am missing something very important here.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am getting tired from adding the same [ProducesResponseType] attribute on my WebAPI controller methods over and over, and I thought there must be an easier, convention based way. I mean, the method clearly tells the return type:
My first try turned out pretty straight forward by writing an operation processor:
The convention is
HTTP 204 NoContent
when the return type is void (or just a Task)HTTP 200 Ok
when the return type is a specific type (or a Task of a specific type) and derive the schema from the CLR's response typeHowever, this looks way too easy while being too useful for something that hasn't been done before. I am wondering why this one isn't part of NSwag and if I am missing something very important here.
Beta Was this translation helpful? Give feedback.
All reactions