-
Notifications
You must be signed in to change notification settings - Fork 2.1k
StatusCode Metadata #4101
Comments
Swashbuckle defines it's own response attributes for specifying the additional metadata needed for Swagger generation. @rynowak Should we have built-in attributes for capturing this metadata and make the metadata available via ApiExplorer? |
Yes, status codes should be available via the ApiExplorer too. Right now, each vender is creating their own custom attribute to get around this limitation. Almost all tooling around Web APIs needs to know about the status codes. - help docs, swagger, ect. |
Knowing the status codes is every bit as important as knowing the response type. |
@domaindrivendev FYI |
Awesome! |
+1 - Awesome! |
Some design notes on this: Example
Update
Update Add
Move Update the |
@kichalla - added some design notes @domaindrivendev - any concerns with this? |
Should the ProducesAttribute still have a Type property if we are going to introduce a ProducesResponseTypeAttribute? |
👍 on what @danroth27 mentioned. |
I think it's nicer to have as a shorthand for when you only want to specify one + you're already specifying a content type. |
One thing; would you flip the order of the I think it makes more sense to specify which status code produces which model, instead of the other way around: [ProducesResponseTypeAttribute(200, typeof(Customer))]
[ProducesResponseTypeAttribute(500, typeof(GenericError))]
[ProducesResponseTypeAttribute(422, typeof(ValidationError))]
public IActionResult DoThing() { } |
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
I like @khellang's suggestion here. One of the scenarios I am encountering where this makes more sense is with overriding. Example: [ProducesResponseType(500, typeof(GenericError))]
public class TestController
{
[Produces("text/json", "application/json", typeof(ProductDetails))]
[ProducesResponseType(500, typeof(MoreSpecificErrorForThisAction))]
public IActionResult Details()
{
....
}
} So for the @rynowak thoughts? |
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
The overriding part just falls out of the nature of being a filter. re: the ordering of parameters, let's come up with a name that we like and let that dictate what order we use. |
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
…er to expose response type and StatusCode. [Fixes #4101] StatusCode Metadata
Will there be a way to add metadata to my API actions depicting the different status codes it returns?
For example:
I believe this will be useful for the various tooling ( Swagger Generators and Help Doc Generators ) to understand the types of HTTP status codes your Web API can return.
The text was updated successfully, but these errors were encountered: