Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Description property to the ProducesResponseTypeAttribute<T> #57272

Closed
Eirenarch opened this issue Aug 11, 2024 · 2 comments
Closed

Add a Description property to the ProducesResponseTypeAttribute<T> #57272

Eirenarch opened this issue Aug 11, 2024 · 2 comments
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

Comments

@Eirenarch
Copy link

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

@Eirenarch Eirenarch added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Aug 11, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 11, 2024
@martincostello martincostello added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Aug 11, 2024
@captainsafia
Copy link
Member

@Eirenarch Thanks for filing this issue! I believe this is a dupe of #55656 which we need to move from api-suggestion to api-ready-to-review. For now, I'll close this as a dupe and recommend following the issue for further updates on this new API.

@captainsafia captainsafia added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Aug 14, 2024
Copy link
Contributor

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants