Convention based OpenApi schema generation #4883
marcwittke
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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