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

Documentation says there is no compile-time check for ProducesResponseType validation in Controllers, which is incorrect #35010

Closed
sander1095 opened this issue Mar 19, 2025 · 0 comments · Fixed by #35011

Comments

@sander1095
Copy link
Contributor

sander1095 commented Mar 19, 2025

Description

The docs say:

Note that there are no compile-time checks to ensure that the response metadata specified with a [ProducesResponseType] attribute is consistent with the actual behavior of the action method, which may return a different status code or response body type than specified by the metadata.

This is incorrect. The "Use web API analyzers" page does allow you to enable analyzers to enable (some form of) compile-time checks:

https://learn.microsoft.com/en-us/aspnet/core/web-api/advanced/analyzers?view=aspnetcore-10.0#analyzers-for-web-api-conventions

I believe that these pages need to be linked.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/include-metadata?view=aspnetcore-10.0&tabs=minimal-apis

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/openapi/include-metadata.md

Document ID

cbc730ec-642f-480d-4a41-044c6c6ef7d3

Platform Id

4bbf4c77-ca40-25d5-0673-fab1102c2291

Article author

@captainsafia

Metadata

  • ID: cbc730ec-642f-480d-4a41-044c6c6ef7d3
  • PlatformId: 4bbf4c77-ca40-25d5-0673-fab1102c2291
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant