Skip to content

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

@sander1095

Description

@sander1095

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions