-
Notifications
You must be signed in to change notification settings - Fork 10.3k
ProblemHttpResult doesn't show in generated OpenApi document #52424
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
@ilmax Thanks for reporting this issue! As I recall, at the moment this is an intentional pattern. Unlike In the past, we rejected an API proposal that attempted to solve this by introducing specific overloads for each status code (#47705) which is not ideal. The proposal indicates that there is a class of users interested in non-500 status codes. I'm open to changing this given we get strong feedback that |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
I was surprised by this yesterday. Had to add .ProducesProblem(StatusCode…) for it to show up. It makes sense since ASP.NET Core can’t know what status code it is. Hence why you annotate. But at least there could be a generated default for 500 if you have enabled problem details for unhandled exceptions etc. |
This is very confusing as a relatively green .NET developer. There are so many ways of doing the same thing. With builder pattern (.Produces), with annotations (ASP.NET MVC style?) and with generic return types (TypedResults). I really liked the I expected the ProblemHttpResult to take a generic argument, just like e.g. BadRequest does for the body shape, but it does not. I mean like this: public static Results<Ok<UserCreatedResponse>, ProblemHttpResult<BadRequest>> CreateUser(...) Again, new to C# and .NET world so i'm not sure if it is possible to have const generics in C#, but being able to do It is not the end of the world, having to add While we're at it, i'm also curious how we would type multiple kinds of errors (e.g. 400, 401, 500) using |
Is there an existing issue for this?
Describe the bug
It seems that
ProblemHttpResult
doesn't implement theIEndpointMetadataProvider
interface hence, a method like the following:Doesn't produce the expected OpenApi response types, only the 200 response ends up in the responses section of the document.
If I'm not reading the documentation wrong, I'd expect the code above to produce 2 responses, a 200 and a 400. am I wrong?
Expected Behavior
The problem details get's correctly added on the endpoint metadata when using
Result<Something, ProblemHttpResult>
and it shows up in the swagger UISteps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
net8.0
Anything else?
No response
The text was updated successfully, but these errors were encountered: