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

Setting the Description in a ProducesResponseTypeAttribute works correctly for Minimal API #60539

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sander1095
Copy link
Contributor

Setting the Description in a ProducesResponseTypeAttribute works correctly for Minimal API

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Using ProducesResponseType with the Description property works with Minimal API

Description

This PR fixes the issue where the description is not set in a Minimal API application:

app.MapGet("/weatherforecast",
[ProducesResponseType<IEnumerable<WeatherForecast>>(StatusCodes.Status200OK, Description = "The service is healthy.")]
() =>
{
    return new Something();
}

This did work for Controllers AND for Minimal API's when the method body was empty. The tests sadly did not cover scenarios where the method body did have content.

This PR adds test cases in several places to check that the Description is added correctly to the OpenAPI document. It also fixes the underlying issues.

Please perform a careful review of the tests in the ApiExlorer project! I made some changes and am not 100% sure that the tests are 100% valid and represent real scenarios.

Fixes #60518

@sander1095 sander1095 requested review from captainsafia, a team and halter73 as code owners February 21, 2025 14:14
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Feb 21, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 21, 2025
Copy link
Contributor

Thanks for your PR, @sander1095. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Description parameter of ProducesResponseTypeAttribute does not work in minimal API app
1 participant