dotnet / dotnet/aspnetcore

Response description

Open
#63,766 7 comments 0 reactions 0 assignees View on GitHub
area-minimal feature-openapi Needs: Attention :wave:
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

As far as i can see there is no way to provide a description to a response type. The standard `.Produce` methods don't have any parameter for it, and I've even tried this with no luck -
```csharp
.WithOpenApi(operation =>
{
operation.Responses["200"].Description = "Downloadable HTML file containing all todos in a formatted table";
operation.Responses["204"].Description = "No todos available to export";
return operation;
})
```
and
```csharp
.WithMetadata(new ProducesResponseTypeMetadata(StatusCodes.Status200OK, null, ["text/html"]) { Description = "Downloadable HTML file containing all todos in a formatted table" })
```

### Describe the solution you'd like

An extra parameter added to the `.Produces` method to add the description field

### Additional context

Looks like currently internally it populates it with the response status code name. Ideally, we should be able to override it or append to it

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.