-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Support more ProblemDetails Titles out-of-the-box for Results.Problem() #36417
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
Triage: We will re-evaluate this during .NET7 planning. |
@brunolins16 Would your changes in #42384 make this easier to implement with things being moved around in the layers? If you think it does I'll take a look once your PR gets merged. |
@martincostello probably not but let me check how close we are, because I did not know about this issue before. Thanks. |
I've run into this problem, so an improvement here would be very nice. When I implemented an API Gateway using YARP, it came as a bit of a surprise that Would it also be worth adding more default |
I'd be happy to take a stab at implementing the changes for this if the aspnetcore team could give a steer as to a solution to the layering question at the top. Of course if it's too big a change to do at this stage without other changes, then it can stay here in the backlog. |
@martincostello I'd be more than happy to help on it. I did not participate in the decision of creating the I like this approach:
The very initial simple idea that I have in mind, would love to hear @dotnet/minimal-apis thoughts, is change the I see it as a simple change if no problem referencing |
Thanks for the feedback Bruno. I'll look at pushing up a draft with your suggested preferred approach some time in the next week for you and the team to weigh-in on. |
Let me have a discussion about this design before you start. |
@martincostello Will you also update the URLs to RFC9110? |
I wasn't aware of a need to do it, but I can do so when I make the change if that's something the team is fine with. |
Given all the existing URLs point to obsolete RFCs, I think it makes sense 😅 |
@martincostello I did not hear anything against referencing |
Great, thanks Bruno - I'll try and push up something tomorrow. |
Is your feature request related to a problem? Please describe.
If a developer using Minimal Actions uses the
Results.Problem()
method with an HTTP status code that is not part ofProblemDetailsDefaults
by default, then without it being explicitly set themselves, a defaulttitle
is not returned in the response.Take the following intentionally obscure example:
Calling the
/teapot
resource will return the following JSON:If more default HTTP status codes were built in, the default experience would be more informative:
Describe the solution you'd like
A more comprehensive list of HTTP status code descriptions are available in the
ReasonPhrases
class.However, using it directly in
ObjectResult
here is not possible asMicrosoft.AspNetCore.WebUtilities
is not referenced byMicrosoft.AspNetCore.Http.Results
.The out-of-the-box experience for
Results.Problem()
could be improved with one of the following:Microsoft.AspNetCore.Http.Results
referenceMicrosoft.AspNetCore.WebUtilities
, and then useReasonPhrases.GetReasonPhrase(string)
as a fallback.ObjectResult
and/orProblemDetailsDefaults
and to provide the implementation forReasonPhrases.GetReasonPhrase(string)
.Otherwise, the developer has to manually specify the title for any HTTP status codes not already catered for, like this:
Additional context
Found using .NET SDK version
6.0.100-rc.1.21460.8
The text was updated successfully, but these errors were encountered: