dotnet / dotnet/aspnetcore

Include known error responses in OpenAPI metadata/generated OpenAPI doc

Open
#58,719 2 comments 15 reactions 0 assignees View on GitHub
area-minimal area-mvc feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

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.

There are some cases where the framework / middleware pipeline can generate error responses, such as when the endpoint defines a required parameter -- if the parameter is not present in the request, the framework generates a status code 400 response. And if the ProblemDetails service was added to the DI container, it is used to generate a ProblemDetails response body for this.

However, these responses are not represented in the generated OpenAPI document.

### Describe the solution you'd like

For the case indicated, and perhaps others, these responses should be included in the generated OpenAPI document. However, I think we'll want to be careful about this -- for example I'm not sure we should add 401 and 403 responses for operations that require authentication.

### Additional context

_No response_

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.