@@ -755,12 +755,35 @@ public static StatusCodeHttpResult StatusCode(int statusCode)
755
755
/// <param name="extensions">The value for <see cref="ProblemDetails.Extensions" />.</param>
756
756
/// <returns>The created <see cref="ProblemHttpResult"/> for the response.</returns>
757
757
public static ProblemHttpResult Problem (
758
+ string ? detail ,
759
+ string ? instance ,
760
+ int ? statusCode ,
761
+ string ? title ,
762
+ string ? type ,
763
+ IDictionary < string , object ? > ? extensions )
764
+ {
765
+ return Problem ( detail , instance , statusCode , title , type , ( IEnumerable < KeyValuePair < string , object ? > > ? ) extensions ) ;
766
+ }
767
+
768
+ /// <summary>
769
+ /// Produces a <see cref="ProblemDetails"/> response.
770
+ /// </summary>
771
+ /// <param name="statusCode">The value for <see cref="ProblemDetails.Status" />.</param>
772
+ /// <param name="detail">The value for <see cref="ProblemDetails.Detail" />.</param>
773
+ /// <param name="instance">The value for <see cref="ProblemDetails.Instance" />.</param>
774
+ /// <param name="title">The value for <see cref="ProblemDetails.Title" />.</param>
775
+ /// <param name="type">The value for <see cref="ProblemDetails.Type" />.</param>
776
+ /// <param name="extensions">The value for <see cref="ProblemDetails.Extensions" />.</param>
777
+ /// <returns>The created <see cref="ProblemHttpResult"/> for the response.</returns>
778
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
779
+ public static ProblemHttpResult Problem (
780
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
758
781
string ? detail = null ,
759
782
string ? instance = null ,
760
783
int ? statusCode = null ,
761
784
string ? title = null ,
762
785
string ? type = null ,
763
- IDictionary < string , object ? > ? extensions = null )
786
+ IEnumerable < KeyValuePair < string , object ? > > ? extensions = null )
764
787
{
765
788
var problemDetails = new ProblemDetails
766
789
{
@@ -776,17 +799,6 @@ public static ProblemHttpResult Problem(
776
799
return new ( problemDetails ) ;
777
800
}
778
801
779
- private static void CopyExtensions ( IDictionary < string , object ? > ? extensions , ProblemDetails problemDetails )
780
- {
781
- if ( extensions is not null )
782
- {
783
- foreach ( var extension in extensions )
784
- {
785
- problemDetails . Extensions . Add ( extension ) ;
786
- }
787
- }
788
- }
789
-
790
802
/// <summary>
791
803
/// Produces a <see cref="ProblemDetails"/> response.
792
804
/// </summary>
@@ -811,11 +823,34 @@ public static ProblemHttpResult Problem(ProblemDetails problemDetails)
811
823
/// <returns>The created <see cref="HttpResults.ValidationProblem"/> for the response.</returns>
812
824
public static ValidationProblem ValidationProblem (
813
825
IDictionary < string , string [ ] > errors ,
826
+ string ? detail ,
827
+ string ? instance ,
828
+ string ? title ,
829
+ string ? type ,
830
+ IDictionary < string , object ? > ? extensions )
831
+ {
832
+ return ValidationProblem ( errors , detail , instance , title , type , ( IEnumerable < KeyValuePair < string , object ? > > ? ) extensions ) ;
833
+ }
834
+
835
+ /// <summary>
836
+ /// Produces a <see cref="StatusCodes.Status400BadRequest"/> response with an <see cref="HttpValidationProblemDetails"/> value.
837
+ /// </summary>
838
+ /// <param name="errors">One or more validation errors.</param>
839
+ /// <param name="detail">The value for <see cref="ProblemDetails.Detail" />.</param>
840
+ /// <param name="instance">The value for <see cref="ProblemDetails.Instance" />.</param>
841
+ /// <param name="title">The value for <see cref="ProblemDetails.Title" />. Defaults to "One or more validation errors occurred."</param>
842
+ /// <param name="type">The value for <see cref="ProblemDetails.Type" />.</param>
843
+ /// <param name="extensions">The value for <see cref="ProblemDetails.Extensions" />.</param>
844
+ /// <returns>The created <see cref="HttpResults.ValidationProblem"/> for the response.</returns>
845
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
846
+ public static ValidationProblem ValidationProblem (
847
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads
848
+ IEnumerable < KeyValuePair < string , string [ ] > > errors ,
814
849
string ? detail = null ,
815
850
string ? instance = null ,
816
851
string ? title = null ,
817
852
string ? type = null ,
818
- IDictionary < string , object ? > ? extensions = null )
853
+ IEnumerable < KeyValuePair < string , object ? > > ? extensions = null )
819
854
{
820
855
ArgumentNullException . ThrowIfNull ( errors ) ;
821
856
@@ -833,6 +868,17 @@ public static ValidationProblem ValidationProblem(
833
868
return new ( problemDetails ) ;
834
869
}
835
870
871
+ private static void CopyExtensions ( IEnumerable < KeyValuePair < string , object ? > > ? extensions , ProblemDetails problemDetails )
872
+ {
873
+ if ( extensions is not null )
874
+ {
875
+ foreach ( var extension in extensions )
876
+ {
877
+ problemDetails . Extensions . Add ( extension ) ;
878
+ }
879
+ }
880
+ }
881
+
836
882
/// <summary>
837
883
/// Produces a <see cref="StatusCodes.Status201Created"/> response.
838
884
/// </summary>
0 commit comments