Updates ProblemDetails references to current RFCs

Points the 500 problem type at RFC 9110 section 15.6.1, points 429 at RFC 6585 section 4, documents ProblemDetailsDto as RFC 9457, and aligns the 429 OpenAPI examples with the runtime detail codes.

Adds an assertion for the middleware problem type so it cannot regress silently.
This commit is contained in:
BinaryAlley committed 2026-11-20 10:38:15 +02:00
1 parent 7f188ce71e
commit f735c135a8
10 files changed
+13 -12

No files matched your search

@@ -96,7 +96,7 @@ public static class PresentationApiLayerServices
var problem = new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
type = "https://tools.ietf.org/html/rfc6585#section-4",
title = "TooManyRequests",
status = StatusCodes.Status429TooManyRequests,
detail = "TooManyRequests",
@@ -66,7 +66,7 @@ public class ExceptionHandlingMiddleware
{
ProblemDetails problemDetails = new()
{
Type = "https://tools.ietf.org/html/rfc7231#section-6.6.1",
Type = "https://tools.ietf.org/html/rfc9110#section-15.6.1",
Title = "InternalServerError",
Status = StatusCodes.Status500InternalServerError,
Detail = "An unexpected error occurred while processing the request.",
@@ -83,10 +83,10 @@ public class LoginEndpointSummary : Summary<LoginEndpoint, LoginRequest>
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
type = "https://tools.ietf.org/html/rfc6585#section-4",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
detail = "TooManyRequests",
retryAfter = "900"
}
);
@@ -85,10 +85,10 @@ public class RecoverPasswordEndpointSummary : Summary<RecoverPasswordEndpoint, R
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
type = "https://tools.ietf.org/html/rfc6585#section-4",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
detail = "TooManyRequests",
retryAfter = "900"
}
);
@@ -93,10 +93,10 @@ public class RegisterEndpointSummary : Summary<RegisterEndpoint, RegistrationReq
Response(429, "The request failed due to a more than 10 requests to this endpoint in less than 15 minutes.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc7231#section-6.5.29",
type = "https://tools.ietf.org/html/rfc6585#section-4",
title = "TooManyRequests",
status = 429,
detail = "Too many attempts. Please try again later.",
detail = "TooManyRequests",
retryAfter = "900"
}
);
@@ -8,7 +8,7 @@ using System.Text.Json.Serialization;
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object that follows the RFC 7807 standard for problem details in HTTP APIs.
/// Data transfer object that follows the RFC 9457 standard for problem details in HTTP APIs.
/// </summary>
[DebuggerDisplay("{Title} ({Status})")]
public class ProblemDetailsDto
@@ -167,7 +167,7 @@ public class LoginEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions);
Assert.NotNull(problemDetails);
Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32());
Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString());
Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString());
Assert.Equal("TooManyRequests", problemDetails["title"].GetString());
Assert.Equal("TooManyRequests", problemDetails["detail"].GetString());
Assert.Equal("900", problemDetails["retryAfter"].GetString());
@@ -77,7 +77,7 @@ public class RecoverPasswordEndpointTests : IClassFixture<LuminaApiFactory>, IDi
Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions);
Assert.NotNull(problemDetails);
Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32());
Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString());
Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString());
Assert.Equal("TooManyRequests", problemDetails["title"].GetString());
Assert.Equal("TooManyRequests", problemDetails["detail"].GetString());
Assert.Equal("900", problemDetails["retryAfter"].GetString());
@@ -95,7 +95,7 @@ public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposabl
Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions);
Assert.NotNull(problemDetails);
Assert.Equal(StatusCodes.Status429TooManyRequests, problemDetails!["status"].GetInt32());
Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.29", problemDetails["type"].GetString());
Assert.Equal("https://tools.ietf.org/html/rfc6585#section-4", problemDetails["type"].GetString());
Assert.Equal("TooManyRequests", problemDetails["title"].GetString());
Assert.Equal("TooManyRequests", problemDetails["detail"].GetString());
Assert.Equal("900", problemDetails["retryAfter"].GetString());
@@ -58,6 +58,7 @@ public class ExceptionHandlingMiddlewareTests
string responseBody = await reader.ReadToEndAsync();
ProblemDetails problemDetails = JsonSerializer.Deserialize<ProblemDetails>(responseBody, _jsonOptions)!;
Assert.Equal(StatusCodes.Status500InternalServerError, problemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.6.1", problemDetails.Type);
Assert.Equal("InternalServerError", problemDetails.Title);
Assert.Equal("An unexpected error occurred while processing the request.", problemDetails.Detail);
Assert.False(string.IsNullOrEmpty(problemDetails.Extensions["traceId"]?.ToString()));