Skip to content

Commit 44a9f8a

Browse files
authored
Add additional ProblemDetails default types and titles (#58101)
* Add additional ProblemDetails default types and titles * Fix unit test --------- Co-authored-by: joegoldman2 <147369450+joegoldman@users.noreply.github.com>
1 parent 80ac2ff commit 44a9f8a

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

src/Mvc/Mvc.Core/test/DependencyInjection/ApiBehaviorOptionsSetupTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ApiBehaviorOptionsSetupTest
1616
public void Configure_AddsClientErrorMappings()
1717
{
1818
// Arrange
19-
var expected = new[] { 400, 401, 403, 404, 405, 406, 408, 409, 412, 415, 422, 426, 500, 502, 503, 504 };
19+
var expected = new[] { 400, 401, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 426, 500, 501, 502, 503, 504, 505 };
2020
var optionsSetup = new ApiBehaviorOptionsSetup();
2121
var options = new ApiBehaviorOptions();
2222

src/Shared/ProblemDetails/ProblemDetailsDefaults.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ internal static class ProblemDetailsDefaults
4646
"Not Acceptable"
4747
),
4848

49+
[407] =
50+
(
51+
"https://tools.ietf.org/html/rfc9110#section-15.5.8",
52+
"Proxy Authentication Required"
53+
),
54+
4955
[408] =
5056
(
5157
"https://tools.ietf.org/html/rfc9110#section-15.5.9",
@@ -58,18 +64,60 @@ internal static class ProblemDetailsDefaults
5864
"Conflict"
5965
),
6066

67+
[410] =
68+
(
69+
"https://tools.ietf.org/html/rfc9110#section-15.5.11",
70+
"Gone"
71+
),
72+
73+
[411] =
74+
(
75+
"https://tools.ietf.org/html/rfc9110#section-15.5.12",
76+
"Length Required"
77+
),
78+
6179
[412] =
6280
(
6381
"https://tools.ietf.org/html/rfc9110#section-15.5.13",
6482
"Precondition Failed"
6583
),
6684

85+
[413] =
86+
(
87+
"https://tools.ietf.org/html/rfc9110#section-15.5.14",
88+
"Content Too Large"
89+
),
90+
91+
[414] =
92+
(
93+
"https://tools.ietf.org/html/rfc9110#section-15.5.15",
94+
"URI Too Long"
95+
),
96+
6797
[415] =
6898
(
6999
"https://tools.ietf.org/html/rfc9110#section-15.5.16",
70100
"Unsupported Media Type"
71101
),
72102

103+
[416] =
104+
(
105+
"https://tools.ietf.org/html/rfc9110#section-15.5.17",
106+
"Range Not Satisfiable"
107+
),
108+
109+
[417] =
110+
(
111+
"https://tools.ietf.org/html/rfc9110#section-15.5.18",
112+
"Expectation Failed"
113+
),
114+
115+
[421] =
116+
(
117+
"https://tools.ietf.org/html/rfc9110#section-15.5.20",
118+
"Misdirected Request"
119+
),
120+
73121
[422] =
74122
(
75123
"https://tools.ietf.org/html/rfc4918#section-11.2",
@@ -88,6 +136,12 @@ internal static class ProblemDetailsDefaults
88136
"An error occurred while processing your request."
89137
),
90138

139+
[501] =
140+
(
141+
"https://tools.ietf.org/html/rfc9110#section-15.6.2",
142+
"Not Implemented"
143+
),
144+
91145
[502] =
92146
(
93147
"https://tools.ietf.org/html/rfc9110#section-15.6.3",
@@ -105,6 +159,12 @@ internal static class ProblemDetailsDefaults
105159
"https://tools.ietf.org/html/rfc9110#section-15.6.5",
106160
"Gateway Timeout"
107161
),
162+
163+
[505] =
164+
(
165+
"https://tools.ietf.org/html/rfc9110#section-15.6.6",
166+
"HTTP Version Not Supported"
167+
),
108168
};
109169

110170
public static void Apply(ProblemDetails problemDetails, int? statusCode)

0 commit comments

Comments
 (0)