Skip to content

Commit 7700ccc

Browse files
committed
Remove code from OpenApiRouteHandlerBUilderExtensions based on Safiaś comment
Also removed new constructors based on Safiaś comment
1 parent 443babd commit 7700ccc

17 files changed

+22
-185
lines changed

src/Http/Http.Abstractions/src/Metadata/IProducesResponseTypeMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface IProducesResponseTypeMetadata
2121
/// <summary>
2222
/// Gets the description of the response.
2323
/// </summary>
24-
string? Description { get; }
24+
string? Description { get; set; }
2525

2626
/// <summary>
2727
/// Gets the content types supported by the metadata.

src/Http/Http.Abstractions/src/Metadata/ProducesResponseTypeMetadata.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ 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-
/// <param name="description">The description of the response.</param>
25-
public ProducesResponseTypeMetadata(int statusCode, Type? type = null, string[]? contentTypes = null, string? description = null)
24+
public ProducesResponseTypeMetadata(int statusCode, Type? type = null, string[]? contentTypes = null)
2625
{
2726
StatusCode = statusCode;
2827
Type = type;
29-
Description = description;
3028

3129
if (contentTypes is null || contentTypes.Length == 0)
3230
{
@@ -52,22 +50,12 @@ static void ValidateContentType(string type)
5250
}
5351
}
5452

55-
// 9.0 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
56-
/// <summary>
57-
/// Initializes an instance of <see cref="ProducesResponseTypeMetadata"/>.
58-
/// </summary>
59-
/// <param name="statusCode">The HTTP response status code.</param>
60-
/// <param name="type">The <see cref="Type"/> of object that is going to be written in the response.</param>
61-
/// <param name="contentTypes">Content types supported by the response.</param>
62-
public ProducesResponseTypeMetadata(int statusCode, Type? type = null, string[]? contentTypes = null) : this(statusCode, type, contentTypes, description: null) { }
63-
6453
// Only for internal use where validation is unnecessary.
65-
private ProducesResponseTypeMetadata(int statusCode, Type? type, IEnumerable<string> contentTypes, string? description = null)
54+
private ProducesResponseTypeMetadata(int statusCode, Type? type, IEnumerable<string> contentTypes)
6655
{
6756
Type = type;
6857
StatusCode = statusCode;
6958
ContentTypes = contentTypes;
70-
Description = description;
7159
}
7260

7361
/// <summary>
@@ -83,7 +71,7 @@ private ProducesResponseTypeMetadata(int statusCode, Type? type, IEnumerable<str
8371
/// <summary>
8472
/// Gets or sets the description of the response.
8573
/// </summary>
86-
public string? Description { get; private set; }
74+
public string? Description { get; set; }
8775

8876
/// <summary>
8977
/// Gets or sets the content types associated with the response.
@@ -96,5 +84,5 @@ public override string ToString()
9684
return DebuggerHelpers.GetDebugText(nameof(StatusCode), StatusCode, nameof(ContentTypes), ContentTypes, nameof(Type), Type, includeNullValues: false, prefix: "Produces");
9785
}
9886

99-
internal static ProducesResponseTypeMetadata CreateUnvalidated(Type? type, int statusCode, IEnumerable<string> contentTypes, string? description) => new(statusCode, type, contentTypes, description);
87+
internal static ProducesResponseTypeMetadata CreateUnvalidated(Type? type, int statusCode, IEnumerable<string> contentTypes) => new(statusCode, type, contentTypes);
10088
}

src/Http/Http.Abstractions/src/PublicAPI.Shipped.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ Microsoft.AspNetCore.Http.ProblemDetailsContext.ProblemDetails.set -> void
413413
Microsoft.AspNetCore.Http.ProblemDetailsContext.ProblemDetailsContext() -> void
414414
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata
415415
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.ContentTypes.get -> System.Collections.Generic.IEnumerable<string!>!
416-
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.ProducesResponseTypeMetadata(int statusCode, System.Type? type = null, string![]? contentTypes = null) -> void
417416
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.StatusCode.get -> int
418417
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.Type.get -> System.Type?
419418
Microsoft.AspNetCore.Http.QueryString

src/Http/Http.Abstractions/src/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.IsOptional.get -> b
1212
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.Name.get -> string!
1313
Microsoft.AspNetCore.Http.Metadata.IParameterBindingMetadata.ParameterInfo.get -> System.Reflection.ParameterInfo!
1414
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.Description.get -> string?
15+
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.Description.set -> void
1516
Microsoft.AspNetCore.Http.Metadata.IProducesResponseTypeMetadata.Description.get -> string?
16-
*REMOVED*Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.ProducesResponseTypeMetadata(int statusCode, System.Type? type = null, string![]? contentTypes = null) -> void
17-
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.ProducesResponseTypeMetadata(int statusCode, System.Type? type = null, string![]? contentTypes = null, string? description = null) -> void
17+
Microsoft.AspNetCore.Http.Metadata.IProducesResponseTypeMetadata.Description.set -> void
18+
Microsoft.AspNetCore.Http.ProducesResponseTypeMetadata.ProducesResponseTypeMetadata(int statusCode, System.Type? type = null, string![]? contentTypes = null) -> void

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,15 +1039,15 @@ private static void PopulateBuiltInResponseTypeMetadata(Type returnType, Endpoin
10391039

10401040
if (returnType == typeof(string))
10411041
{
1042-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(type: typeof(string), statusCode: 200, PlaintextContentType, description: null));
1042+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(type: typeof(string), statusCode: 200, PlaintextContentType));
10431043
}
10441044
else if (returnType == typeof(void))
10451045
{
1046-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(returnType, statusCode: 200, PlaintextContentType), description: null);
1046+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(returnType, statusCode: 200, PlaintextContentType));
10471047
}
10481048
else
10491049
{
1050-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(returnType, statusCode: 200, DefaultAcceptsAndProducesContentType), description: null);
1050+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(returnType, statusCode: 200, DefaultAcceptsAndProducesContentType));
10511051
}
10521052
}
10531053

src/Http/Http.Results/src/AcceptedAtRouteOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ static void IEndpointMetadataProvider.PopulateMetadata(MethodInfo method, Endpoi
122122
ArgumentNullException.ThrowIfNull(method);
123123
ArgumentNullException.ThrowIfNull(builder);
124124

125-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status202Accepted, ContentTypeConstants.ApplicationJsonContentTypes, description: null));
125+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status202Accepted, ContentTypeConstants.ApplicationJsonContentTypes));
126126
}
127127
}

src/Http/Http.Results/src/AcceptedOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ static void IEndpointMetadataProvider.PopulateMetadata(MethodInfo method, Endpoi
100100
ArgumentNullException.ThrowIfNull(method);
101101
ArgumentNullException.ThrowIfNull(builder);
102102

103-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status202Accepted, ContentTypeConstants.ApplicationJsonContentTypes, description: null));
103+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status202Accepted, ContentTypeConstants.ApplicationJsonContentTypes));
104104
}
105105
}

src/Http/Http.Results/src/BadRequestOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ static void IEndpointMetadataProvider.PopulateMetadata(MethodInfo method, Endpoi
6565
ArgumentNullException.ThrowIfNull(method);
6666
ArgumentNullException.ThrowIfNull(builder);
6767

68-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status400BadRequest, ContentTypeConstants.ApplicationJsonContentTypes, description: null));
68+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status400BadRequest, ContentTypeConstants.ApplicationJsonContentTypes));
6969
}
7070
}

src/Http/Http.Results/src/ConflictOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ static void IEndpointMetadataProvider.PopulateMetadata(MethodInfo method, Endpoi
6565
ArgumentNullException.ThrowIfNull(method);
6666
ArgumentNullException.ThrowIfNull(builder);
6767

68-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status409Conflict, ContentTypeConstants.ApplicationJsonContentTypes, description: null));
68+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status409Conflict, ContentTypeConstants.ApplicationJsonContentTypes));
6969
}
7070
}

src/Http/Http.Results/src/CreatedAtRouteOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ static void IEndpointMetadataProvider.PopulateMetadata(MethodInfo method, Endpoi
125125
ArgumentNullException.ThrowIfNull(method);
126126
ArgumentNullException.ThrowIfNull(builder);
127127

128-
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status201Created, ContentTypeConstants.ApplicationJsonContentTypes, description: null));
128+
builder.Metadata.Add(ProducesResponseTypeMetadata.CreateUnvalidated(typeof(TValue), StatusCodes.Status201Created, ContentTypeConstants.ApplicationJsonContentTypes));
129129
}
130130
}

0 commit comments

Comments
 (0)