Add a Description property to the ProducesResponseTypeAttribute<T> #57272
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-web-frameworks
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
✔️ Resolution: Duplicate
Resolved as a duplicate of another issue
Status: Resolved
Background and Motivation
When using Swashbuckle to generate Swagger for an API I found myself choosing between using the ProducesResponseTypeAttribute and xml doc with nodes. If I use the attribute I don't get to write my own description text, if I use the XML docs I don't get to specify the return type. I've opted into using the XML docs because in most cases the response type is ProblemDetails and the important thing is the human-written description of when a certain status code happens. While it is probably possible to make the tooling in a way that reads both the xml status code and the ProducesResponseTypeAttribute it requires much more effort to implement compared to a simple solution - adding a string? Description property to the ProducesResponseTypeAttribute
Proposed API
Add a string? Description to the ProducesResponseTypeAttribute and maybe to the ProducesResponseTypeAttribute. Maybe add a constructor overload that accepts it
Usage Examples
[ProducesResponseType(409, description: "Some conflict with existing items")]
public async Task CreateCustomer(CustomerCreateDto customerCreateDto)
Risks
There is a risk that someone already implemented the proper tooling to read both the XML docs and the ApiExplorer data and there might be a clash but probably one would just override the other
Additional Notes
To maximize the usefulness of this property it should be surfaced in the ApiExplorer data
The text was updated successfully, but these errors were encountered: