Skip to content

Commit

Permalink
Make DefaultProblemDetailsFactory public (#55666)
Browse files Browse the repository at this point in the history
Co-authored-by: Safia Abdalla <safia@safia.rocks>
  • Loading branch information
GiovanniBraconi and captainsafia committed May 19, 2024
1 parent dad78b3 commit 94ad1d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@

namespace Microsoft.AspNetCore.Mvc.Infrastructure;

internal sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory
/// <summary>
/// The `DefaultProblemDetailsFactory` is a concrete implementation of the `ProblemDetailsFactory` abstract class.
/// It provides methods to create instances of `ProblemDetails` and `ValidationProblemDetails` with default settings.
/// This class uses the provided `ApiBehaviorOptions` for client error mapping and an optional custom configuration action to further customize the problem details.
/// </summary>
public sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory
{
private readonly ApiBehaviorOptions _options;
private readonly Action<ProblemDetailsContext>? _configure;

/// <summary>
/// Initializes a new instance of the <see cref="DefaultProblemDetailsFactory"/> class.
/// </summary>
/// <param name="options">The options for API behavior.</param>
/// <param name="problemDetailsOptions">The options for customizing problem details.</param>
public DefaultProblemDetailsFactory(
IOptions<ApiBehaviorOptions> options,
IOptions<ProblemDetailsOptions>? problemDetailsOptions = null)
Expand All @@ -23,6 +33,8 @@ internal sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory
_configure = problemDetailsOptions?.Value?.CustomizeProblemDetails;
}


/// <inheritdoc />
public override ProblemDetails CreateProblemDetails(
HttpContext httpContext,
int? statusCode = null,
Expand All @@ -47,6 +59,7 @@ internal sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory
return problemDetails;
}

/// <inheritdoc />
public override ValidationProblemDetails CreateValidationProblemDetails(
HttpContext httpContext,
ModelStateDictionary modelStateDictionary,
Expand Down
4 changes: 4 additions & 0 deletions src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ virtual Microsoft.AspNetCore.Mvc.ControllerBase.Problem(string? detail, string?
virtual Microsoft.AspNetCore.Mvc.ControllerBase.Problem(string? detail = null, string? instance = null, int? statusCode = null, string? title = null, string? type = null, System.Collections.Generic.IDictionary<string!, object?>? extensions = null) -> Microsoft.AspNetCore.Mvc.ObjectResult!
virtual Microsoft.AspNetCore.Mvc.ControllerBase.ValidationProblem(string? detail, string? instance, int? statusCode, string? title, string? type, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary? modelStateDictionary) -> Microsoft.AspNetCore.Mvc.ActionResult!
virtual Microsoft.AspNetCore.Mvc.ControllerBase.ValidationProblem(string? detail = null, string? instance = null, int? statusCode = null, string? title = null, string? type = null, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary? modelStateDictionary = null, System.Collections.Generic.IDictionary<string!, object?>? extensions = null) -> Microsoft.AspNetCore.Mvc.ActionResult!
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.DefaultProblemDetailsFactory(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.ApiBehaviorOptions!>! options, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Http.ProblemDetailsOptions!>? problemDetailsOptions = null) -> void
override Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.CreateProblemDetails(Microsoft.AspNetCore.Http.HttpContext! httpContext, int? statusCode = null, string? title = null, string? type = null, string? detail = null, string? instance = null) -> Microsoft.AspNetCore.Mvc.ProblemDetails!
override Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.CreateValidationProblemDetails(Microsoft.AspNetCore.Http.HttpContext! httpContext, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary! modelStateDictionary, int? statusCode = null, string? title = null, string? type = null, string? detail = null, string? instance = null) -> Microsoft.AspNetCore.Mvc.ValidationProblemDetails!

0 comments on commit 94ad1d4

Please sign in to comment.