Skip to content

Include known error responses in OpenAPI metadata/generated OpenAPI doc #58719

@mikekistler

Description

@mikekistler

Is there an existing issue for this?

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions