@@ -166,6 +166,22 @@ public static IResult Content(string? content, MediaTypeHeaderValue contentType)
166
166
/// <remarks>Callers should cache an instance of serializer settings to avoid
167
167
/// recreating cached data with each call.</remarks>
168
168
public static IResult Json ( object ? data , JsonSerializerOptions ? options = null , string ? contentType = null , int ? statusCode = null )
169
+ => Json < object > ( data , options , contentType , statusCode ) ;
170
+
171
+ /// <summary>
172
+ /// Creates a <see cref="IResult"/> that serializes the specified <paramref name="data"/> object to JSON.
173
+ /// </summary>
174
+ /// <param name="data">The object to write as JSON.</param>
175
+ /// <param name="options">The serializer options to use when serializing the value.</param>
176
+ /// <param name="contentType">The content-type to set on the response.</param>
177
+ /// <param name="statusCode">The status code to set on the response.</param>
178
+ /// <returns>The created <see cref="JsonHttpResult{TValue}"/> that serializes the specified <paramref name="data"/>
179
+ /// as JSON format for the response.</returns>
180
+ /// <remarks>Callers should cache an instance of serializer settings to avoid
181
+ /// recreating cached data with each call.</remarks>
182
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
183
+ public static IResult Json < TValue > ( TValue ? data , JsonSerializerOptions ? options = null , string ? contentType = null , int ? statusCode = null )
184
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
169
185
=> TypedResults . Json ( data , options , contentType , statusCode ) ;
170
186
171
187
/// <summary>
@@ -454,7 +470,17 @@ public static IResult StatusCode(int statusCode)
454
470
/// </summary>
455
471
/// <param name="value">The value to be included in the HTTP response body.</param>
456
472
/// <returns>The created <see cref="IResult"/> for the response.</returns>
473
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
457
474
public static IResult NotFound ( object ? value = null )
475
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
476
+ => NotFound < object > ( value ) ;
477
+
478
+ /// <summary>
479
+ /// Produces a <see cref="StatusCodes.Status404NotFound"/> response.
480
+ /// </summary>
481
+ /// <param name="value">The value to be included in the HTTP response body.</param>
482
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
483
+ public static IResult NotFound < TValue > ( TValue ? value )
458
484
=> value is null ? TypedResults . NotFound ( ) : TypedResults . NotFound ( value ) ;
459
485
460
486
/// <summary>
@@ -469,15 +495,35 @@ public static IResult Unauthorized()
469
495
/// </summary>
470
496
/// <param name="error">An error object to be included in the HTTP response body.</param>
471
497
/// <returns>The created <see cref="IResult"/> for the response.</returns>
498
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
472
499
public static IResult BadRequest ( object ? error = null )
500
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
501
+ => BadRequest < object > ( error ) ;
502
+
503
+ /// <summary>
504
+ /// Produces a <see cref="StatusCodes.Status400BadRequest"/> response.
505
+ /// </summary>
506
+ /// <param name="error">An error object to be included in the HTTP response body.</param>
507
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
508
+ public static IResult BadRequest < TValue > ( TValue ? error )
473
509
=> error is null ? TypedResults . BadRequest ( ) : TypedResults . BadRequest ( error ) ;
474
510
475
511
/// <summary>
476
512
/// Produces a <see cref="StatusCodes.Status409Conflict"/> response.
477
513
/// </summary>
478
514
/// <param name="error">An error object to be included in the HTTP response body.</param>
479
515
/// <returns>The created <see cref="IResult"/> for the response.</returns>
516
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
480
517
public static IResult Conflict ( object ? error = null )
518
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
519
+ => Conflict < object > ( error ) ;
520
+
521
+ /// <summary>
522
+ /// Produces a <see cref="StatusCodes.Status409Conflict"/> response.
523
+ /// </summary>
524
+ /// <param name="error">An error object to be included in the HTTP response body.</param>
525
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
526
+ public static IResult Conflict < TValue > ( TValue ? error )
481
527
=> error is null ? TypedResults . Conflict ( ) : TypedResults . Conflict ( error ) ;
482
528
483
529
/// <summary>
@@ -492,15 +538,35 @@ public static IResult NoContent()
492
538
/// </summary>
493
539
/// <param name="value">The value to be included in the HTTP response body.</param>
494
540
/// <returns>The created <see cref="IResult"/> for the response.</returns>
541
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
495
542
public static IResult Ok ( object ? value = null )
543
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
544
+ => Ok < object > ( value ) ;
545
+
546
+ /// <summary>
547
+ /// Produces a <see cref="StatusCodes.Status200OK"/> response.
548
+ /// </summary>
549
+ /// <param name="value">The value to be included in the HTTP response body.</param>
550
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
551
+ public static IResult Ok < TValue > ( TValue ? value )
496
552
=> value is null ? TypedResults . Ok ( ) : TypedResults . Ok ( value ) ;
497
553
498
554
/// <summary>
499
555
/// Produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response.
500
556
/// </summary>
501
557
/// <param name="error">An error object to be included in the HTTP response body.</param>
502
558
/// <returns>The created <see cref="IResult"/> for the response.</returns>
559
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
503
560
public static IResult UnprocessableEntity ( object ? error = null )
561
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
562
+ => UnprocessableEntity < object > ( error ) ;
563
+
564
+ /// <summary>
565
+ /// Produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response.
566
+ /// </summary>
567
+ /// <param name="error">An error object to be included in the HTTP response body.</param>
568
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
569
+ public static IResult UnprocessableEntity < TValue > ( TValue ? error )
504
570
=> error is null ? TypedResults . UnprocessableEntity ( ) : TypedResults . UnprocessableEntity ( error ) ;
505
571
506
572
/// <summary>
@@ -580,6 +646,15 @@ public static IResult ValidationProblem(
580
646
/// <param name="value">The value to be included in the HTTP response body.</param>
581
647
/// <returns>The created <see cref="IResult"/> for the response.</returns>
582
648
public static IResult Created ( string uri , object ? value )
649
+ => Created < object > ( uri , value ) ;
650
+
651
+ /// <summary>
652
+ /// Produces a <see cref="StatusCodes.Status201Created"/> response.
653
+ /// </summary>
654
+ /// <param name="uri">The URI at which the content has been created.</param>
655
+ /// <param name="value">The value to be included in the HTTP response body.</param>
656
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
657
+ public static IResult Created < TValue > ( string uri , TValue ? value )
583
658
=> value is null ? TypedResults . Created ( uri ) : TypedResults . Created ( uri , value ) ;
584
659
585
660
/// <summary>
@@ -589,6 +664,15 @@ public static IResult Created(string uri, object? value)
589
664
/// <param name="value">The value to be included in the HTTP response body.</param>
590
665
/// <returns>The created <see cref="IResult"/> for the response.</returns>
591
666
public static IResult Created ( Uri uri , object ? value )
667
+ => Created < object > ( uri , value ) ;
668
+
669
+ /// <summary>
670
+ /// Produces a <see cref="StatusCodes.Status201Created"/> response.
671
+ /// </summary>
672
+ /// <param name="uri">The URI at which the content has been created.</param>
673
+ /// <param name="value">The value to be included in the HTTP response body.</param>
674
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
675
+ public static IResult Created < TValue > ( Uri uri , TValue ? value )
592
676
=> value is null ? TypedResults . Created ( uri ) : TypedResults . Created ( uri , value ) ;
593
677
594
678
/// <summary>
@@ -599,6 +683,18 @@ public static IResult Created(Uri uri, object? value)
599
683
/// <param name="value">The value to be included in the HTTP response body.</param>
600
684
/// <returns>The created <see cref="IResult"/> for the response.</returns>
601
685
public static IResult CreatedAtRoute ( string ? routeName = null , object ? routeValues = null , object ? value = null )
686
+ => CreatedAtRoute < object > ( routeName , routeValues , value ) ;
687
+
688
+ /// <summary>
689
+ /// Produces a <see cref="StatusCodes.Status201Created"/> response.
690
+ /// </summary>
691
+ /// <param name="routeName">The name of the route to use for generating the URL.</param>
692
+ /// <param name="routeValues">The route data to use for generating the URL.</param>
693
+ /// <param name="value">The value to be included in the HTTP response body.</param>
694
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
695
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
696
+ public static IResult CreatedAtRoute < TValue > ( string ? routeName = null , object ? routeValues = null , TValue ? value = default )
697
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
602
698
=> value is null ? TypedResults . CreatedAtRoute ( routeName , routeValues ) : TypedResults . CreatedAtRoute ( value , routeName , routeValues ) ;
603
699
604
700
/// <summary>
@@ -608,6 +704,17 @@ public static IResult CreatedAtRoute(string? routeName = null, object? routeValu
608
704
/// <param name="value">The optional content value to format in the response body.</param>
609
705
/// <returns>The created <see cref="IResult"/> for the response.</returns>
610
706
public static IResult Accepted ( string ? uri = null , object ? value = null )
707
+ => Accepted < object > ( uri , value ) ;
708
+
709
+ /// <summary>
710
+ /// Produces a <see cref="StatusCodes.Status202Accepted"/> response.
711
+ /// </summary>
712
+ /// <param name="uri">The URI with the location at which the status of requested content can be monitored.</param>
713
+ /// <param name="value">The optional content value to format in the response body.</param>
714
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
715
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
716
+ public static IResult Accepted < TValue > ( string ? uri = null , TValue ? value = default )
717
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
611
718
=> value is null ? TypedResults . Accepted ( uri ) : TypedResults . Accepted ( uri , value ) ;
612
719
613
720
/// <summary>
@@ -617,7 +724,21 @@ public static IResult Accepted(string? uri = null, object? value = null)
617
724
/// <param name="routeValues">The route data to use for generating the URL.</param>
618
725
/// <param name="value">The optional content value to format in the response body.</param>
619
726
/// <returns>The created <see cref="IResult"/> for the response.</returns>
727
+ #pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
620
728
public static IResult AcceptedAtRoute ( string ? routeName = null , object ? routeValues = null , object ? value = null )
729
+ #pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
730
+ => AcceptedAtRoute < object > ( routeName , routeValues , value ) ;
731
+
732
+ /// <summary>
733
+ /// Produces a <see cref="StatusCodes.Status202Accepted"/> response.
734
+ /// </summary>
735
+ /// <param name="routeName">The name of the route to use for generating the URL.</param>
736
+ /// <param name="routeValues">The route data to use for generating the URL.</param>
737
+ /// <param name="value">The optional content value to format in the response body.</param>
738
+ /// <returns>The created <see cref="IResult"/> for the response.</returns>
739
+ #pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
740
+ public static IResult AcceptedAtRoute < TValue > ( string ? routeName = null , object ? routeValues = null , TValue ? value = default )
741
+ #pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
621
742
=> value is null ? TypedResults . AcceptedAtRoute ( routeName , routeValues ) : TypedResults . AcceptedAtRoute ( value , routeName , routeValues ) ;
622
743
623
744
/// <summary>
0 commit comments