@@ -21,10 +21,12 @@ public sealed class ProducesResponseTypeMetadata : IProducesResponseTypeMetadata
2121 /// <param name="statusCode">The HTTP response status code.</param>
2222 /// <param name="type">The <see cref="Type"/> of object that is going to be written in the response.</param>
2323 /// <param name="contentTypes">Content types supported by the response.</param>
24- public ProducesResponseTypeMetadata ( int statusCode , Type ? type = null , string [ ] ? contentTypes = null )
24+ /// <param name="description">The description of the response.</param>
25+ public ProducesResponseTypeMetadata ( int statusCode , Type ? type = null , string [ ] ? contentTypes = null , string ? description = null )
2526 {
2627 StatusCode = statusCode ;
2728 Type = type ;
29+ Description = description ;
2830
2931 if ( contentTypes is null || contentTypes . Length == 0 )
3032 {
@@ -50,58 +52,22 @@ static void ValidateContentType(string type)
5052 }
5153 }
5254
55+ // 9.0 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
5356 /// <summary>
5457 /// Initializes an instance of <see cref="ProducesResponseTypeMetadata"/>.
5558 /// </summary>
5659 /// <param name="statusCode">The HTTP response status code.</param>
5760 /// <param name="type">The <see cref="Type"/> of object that is going to be written in the response.</param>
58- /// <param name="description">The descrption of the response.</param>
5961 /// <param name="contentTypes">Content types supported by the response.</param>
60- public ProducesResponseTypeMetadata ( int statusCode , Type ? type = null , string ? description = null , string [ ] ? contentTypes = null )
61- {
62- StatusCode = statusCode ;
63- Type = type ;
64- Description = description ;
65-
66- if ( contentTypes is null || contentTypes . Length == 0 )
67- {
68- ContentTypes = Enumerable . Empty < string > ( ) ;
69- }
70- else
71- {
72- for ( var i = 0 ; i < contentTypes . Length ; i ++ )
73- {
74- MediaTypeHeaderValue . Parse ( contentTypes [ i ] ) ;
75- ValidateContentType ( contentTypes [ i ] ) ;
76- }
77-
78- ContentTypes = contentTypes ;
79- }
80-
81- static void ValidateContentType ( string type )
82- {
83- if ( type . Contains ( '*' , StringComparison . OrdinalIgnoreCase ) )
84- {
85- throw new InvalidOperationException ( $ "Could not parse '{ type } '. Content types with wildcards are not supported.") ;
86- }
87- }
88- }
62+ public ProducesResponseTypeMetadata ( int statusCode , Type ? type = null , string [ ] ? contentTypes = null ) : this ( statusCode , type , contentTypes , description : null ) { }
8963
9064 // Only for internal use where validation is unnecessary.
91- private ProducesResponseTypeMetadata ( int statusCode , Type ? type , IEnumerable < string > contentTypes )
65+ private ProducesResponseTypeMetadata ( int statusCode , Type ? type , IEnumerable < string > contentTypes , string ? description = null )
9266 {
9367 Type = type ;
9468 StatusCode = statusCode ;
9569 ContentTypes = contentTypes ;
96- }
97-
98- // Only for internal use where validation is unnecessary.
99- private ProducesResponseTypeMetadata ( int statusCode , Type ? type , string ? description , IEnumerable < string > contentTypes )
100- {
101- Type = type ;
102- StatusCode = statusCode ;
10370 Description = description ;
104- ContentTypes = contentTypes ;
10571 }
10672
10773 /// <summary>
@@ -127,9 +93,8 @@ private ProducesResponseTypeMetadata(int statusCode, Type? type, string? descrip
12793 /// <inheritdoc/>
12894 public override string ToString ( )
12995 {
130- return DebuggerHelpers . GetDebugText ( nameof ( StatusCode ) , StatusCode , nameof ( ContentTypes ) , ContentTypes , nameof ( Type ) , Type , nameof ( Description ) , Description , includeNullValues : false , prefix : "Produces" ) ;
96+ return DebuggerHelpers . GetDebugText ( nameof ( StatusCode ) , StatusCode , nameof ( ContentTypes ) , ContentTypes , nameof ( Type ) , Type , includeNullValues : false , prefix : "Produces" ) ;
13197 }
13298
133- internal static ProducesResponseTypeMetadata CreateUnvalidated ( Type ? type , int statusCode , IEnumerable < string > contentTypes ) => new ( statusCode , type , contentTypes ) ;
134- internal static ProducesResponseTypeMetadata CreateUnvalidated ( Type ? type , int statusCode , string ? description , IEnumerable < string > contentTypes ) => new ( statusCode , type , description , contentTypes ) ;
99+ internal static ProducesResponseTypeMetadata CreateUnvalidated ( Type ? type , int statusCode , IEnumerable < string > contentTypes , string ? description ) => new ( statusCode , type , contentTypes , description ) ;
135100}
0 commit comments