Skip to content

ProducesResponseType should support setting a Description #54064

@sander1095

Description

@sander1095

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.

I am trying to use ASP.NET Core's [ProducesResponseType] to properly define my OpenAPI definition. The OpenAPI spec contains a Description that can be set for each response, which is very useful if you want to explain why a specific status code is returned.

You can not set the Description using [ProducesResponseType], so you need to use NSwag/Swashbuckle's SwaggerResponse which DOES roughly the same thing as [ProducesResponseType], but this can't be mixed with the cleaner looking, generic supporting [ProducesResponseType].

Having to use NSwag/Swashbuckle's specific attributes locks you into that library, whereas ProducesResponseType is library-agnostic and therefore my preferred approach.

Describe the solution you'd like

I would like to be able to use [ProducesResponseType] (and the other ones like [ProducesDefaultResponse]) and specify a Description like so:

[ProducesResponseType<User>(StatusCodes.Status200OK, Description = "A description of this response")]

This shouldn't be too tough to implement and if the .NET team would like to see this implemented, I wouldn't mind trying to create a PR for this, which is an exciting opportunity for me!

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