Skip to content

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

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

Open
1 task done
mikekistler opened this issue Oct 30, 2024 · 2 comments
Open
1 task done
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi

Comments

@mikekistler
Copy link
Contributor

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

@mikekistler mikekistler added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi labels Oct 30, 2024
@sander1095
Copy link
Contributor

Hi Mike!

Are you talking about OpenAPI's default response here? For example, when I create a Minimal API endpoint that I set up to return a 200 OK with TodoItem DTO's, would the document have an additional default response pointing to the ProblemDetails schema in case an unknown/unhandled exception occurs in the endpoint?

@mikekistler
Copy link
Contributor Author

I'm not really referring to "default". I'm thinking of more specific cases like parameter validation that fails with a 400 response.

I am not a fan of "default" as I believe it is too broad -- it could cover 1xx or 3xx responses for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi
Projects
None yet
Development

No branches or pull requests

2 participants