@@ -12,24 +12,24 @@ internal sealed class ResponseBodyContentGenerator
1212{
1313 private readonly string _contentVariableName ;
1414 internal string ClassName { get ; }
15- private readonly MediaTypeHeaderValue _contentType ;
15+ internal MediaTypeHeaderValue ContentType { get ; }
1616 private readonly TypeDeclaration _typeDeclaration ;
1717 private readonly bool _isContentTypeRange ;
1818 private readonly bool _isSequentialMediaType ;
1919
2020 public ResponseBodyContentGenerator ( KeyValuePair < string , IOpenApiMediaType > contentMediaType , TypeDeclaration typeDeclaration )
2121 {
22- _contentType = MediaTypeHeaderValue . Parse ( contentMediaType . Key ) ;
22+ ContentType = MediaTypeHeaderValue . Parse ( contentMediaType . Key ) ;
2323 _typeDeclaration = typeDeclaration ;
2424 _isSequentialMediaType = contentMediaType . Value . ItemSchema != null ;
25- _isContentTypeRange = _contentType . MediaType . EndsWith ( "*" ) ;
26- _contentVariableName = _contentType . MediaType switch
25+ _isContentTypeRange = ContentType . MediaType . EndsWith ( "*" ) ;
26+ _contentVariableName = ContentType . MediaType switch
2727 {
2828 "*/*" => "any" ,
2929 not null when _isContentTypeRange =>
30- $ "any{ _contentType . MediaType . TrimEnd ( '*' ) . TrimEnd ( '/' ) . ToLower ( ) . ToPascalCase ( ) } ",
30+ $ "any{ ContentType . MediaType . TrimEnd ( '*' ) . TrimEnd ( '/' ) . ToLower ( ) . ToPascalCase ( ) } ",
3131 null => throw new InvalidOperationException ( "Content type is null" ) ,
32- _ => _contentType . MediaType . ToLower ( ) . ToCamelCase ( )
32+ _ => ContentType . MediaType . ToLower ( ) . ToCamelCase ( )
3333 } ;
3434
3535 ClassName = _contentVariableName . ToPascalCase ( ) ;
@@ -40,7 +40,7 @@ public string GenerateResponseClass(string responseClassName, string contentType
4040 _isSequentialMediaType ?
4141$$ """
4242/// <summary>
43- /// Response for content {{ _contentType }}
43+ /// Response for content {{ ContentType }}
4444/// </summary>
4545internal sealed class {{ ClassName }} : {{ responseClassName }}
4646{
@@ -51,12 +51,12 @@ internal sealed class {{ClassName}} : {{responseClassName}}
5151 private readonly WebApiConfiguration _configuration;
5252
5353 /// <summary>
54- /// Construct response for content {{ _contentType }}
54+ /// Construct response for content {{ ContentType }}
5555 /// </summary>
5656 /// <param name="request">Request</param>{{ ( _isContentTypeRange ?
5757$ """
5858
59- /// <param name="contentType">Content type must match range { _contentType . MediaType } </param>
59+ /// <param name="contentType">Content type must match range { ContentType . MediaType } </param>
6060""" : "" ) }}
6161 public {{ ClassName }} (Request request{{ ( _isContentTypeRange ? ", string contentType" : "" ) }} )
6262 {{{(_isContentTypeRange ?
@@ -68,7 +68,7 @@ internal sealed class {{ClassName}} : {{responseClassName}}
6868 _content = new(request.HttpContext.Response.BodyWriter);
6969 _operation = request.HttpContext.RequestServices.GetRequiredService<Operation>();
7070 _configuration = request.HttpContext.RequestServices.GetRequiredService<WebApiConfiguration>();
71- {{contentTypeFieldName}} = {{(_isContentTypeRange ? "contentType" : $"\"{_contentType .MediaType}\"")}};
71+ {{contentTypeFieldName}} = {{(_isContentTypeRange ? "contentType" : $"\"{ContentType .MediaType}\"")}};
7272 }
7373
7474 /// <summary>
@@ -85,7 +85,7 @@ internal void WriteItem({{_typeDeclaration.FullyQualifiedDotnetTypeName()}} item
8585 _currentItem = null;
8686 }
8787
88- internal static ContentMediaType<{{responseClassName}}> ContentMediaType { get; } = new(MediaTypeHeaderValue.Parse("{{_contentType }}"));
88+ internal static ContentMediaType<{{responseClassName}}> ContentMediaType { get; } = new(MediaTypeHeaderValue.Parse("{{ContentType }}"));
8989 /// <inheritdoc/>
9090 internal override void WriteTo(HttpResponse httpResponse)
9191 {
@@ -127,19 +127,19 @@ _currentItem is null
127127
128128$$ """
129129/// <summary>
130- /// Response for content {{ _contentType }}
130+ /// Response for content {{ ContentType }}
131131/// </summary>
132132internal sealed class {{ ClassName }} : {{ responseClassName }}
133133{
134134 private {{ _typeDeclaration . FullyQualifiedDotnetTypeName ( ) }} _content;
135135
136136 /// <summary>
137- /// Construct response for content {{ _contentType }}
137+ /// Construct response for content {{ ContentType }}
138138 /// </summary>
139139 /// <param name="{{ _contentVariableName }} ">Content</param>{{ ( _isContentTypeRange ?
140140$ """
141141
142- /// <param name="contentType">Content type must match range { _contentType . MediaType } </param>
142+ /// <param name="contentType">Content type must match range { ContentType . MediaType } </param>
143143""" : "" ) }}
144144 public {{ ClassName }} ({{ _typeDeclaration . FullyQualifiedDotnetTypeName ( ) }} {{ _contentVariableName }} {{ ( _isContentTypeRange ? ", string contentType" : "" ) }} )
145145 {{{(_isContentTypeRange ?
@@ -148,10 +148,10 @@ internal sealed class {{ClassName}} : {{responseClassName}}
148148 EnsureExpectedContentType( MediaTypeHeaderValue . Parse ( contentType ) , ContentMediaType ) ;
149149""" : "")}}
150150 _content = {{_contentVariableName}};
151- {{contentTypeFieldName}} = {{(_isContentTypeRange ? "contentType" : $"\"{_contentType .MediaType}\"")}};
151+ {{contentTypeFieldName}} = {{(_isContentTypeRange ? "contentType" : $"\"{ContentType .MediaType}\"")}};
152152 }
153153
154- internal static ContentMediaType<{{responseClassName}}> ContentMediaType { get; } = new(MediaTypeHeaderValue.Parse("{{_contentType }}"));
154+ internal static ContentMediaType<{{responseClassName}}> ContentMediaType { get; } = new(MediaTypeHeaderValue.Parse("{{ContentType }}"));
155155 /// <inheritdoc/>
156156 internal override void WriteTo(HttpResponse httpResponse)
157157 {
0 commit comments