-
Notifications
You must be signed in to change notification settings - Fork 10.3k
ProducesResponseType(typeof(void), ...) causes ApiExplorer to indicate the return type is ProblemDetails #7874
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
Comments
Originally reported to Swashbuckle team here: domaindrivendev/Swashbuckle.AspNetCore#1043 |
I'm marking this as a bug to see if there's interest in making this work out of the box. For 2.2, you could do this by specifying a [ProducesErrorResponseType(typeof(void)]
[ProducesResponseType(StatusCodes.Unauthorized)]
public IActionResult Method() => {} That said, do you actually see an empty body in the response? |
Sorry, was away for a week. Yes, the actual body is empty on a 401, which is what I would expect (probably). Swagger shows that it returns a ProblemDetails, but it does not in actual use. Adding |
@pranavkm Is there anything actionable here then? |
We are using NSwag to produce TypeScript client classes and we encountered this issue, to summarize:
May we know the status of this fix? Will it be released in v3.1 or in v5.0? |
I found a work-around here: domaindrivendev/Swashbuckle.AspNetCore#1752 (comment) |
Describe the bug
ApiExplorer/ProducesResponseType exposes incorrect value when the return type is void. It seems to override any attempt to indicate that the response produces no results/body with ProblemDetails.
To Reproduce
Steps to reproduce the behavior:
[ProducesResponseType(typeof(void), (int)HttpStatusCode.Unauthorized)
Expected behavior
ApiExplorer should say the return type is void.
The text was updated successfully, but these errors were encountered: