Skip to content

Commit 7e81443

Browse files
committed
Remove overloads that were not api-approved
1 parent 319223e commit 7e81443

File tree

3 files changed

+64
-216
lines changed

3 files changed

+64
-216
lines changed

src/Http/Routing/src/Builder/OpenApiRouteHandlerBuilderExtensions.cs

Lines changed: 19 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,6 @@ public static TBuilder ExcludeFromDescription<TBuilder>(this TBuilder builder) w
3434
public static RouteHandlerBuilder ExcludeFromDescription(this RouteHandlerBuilder builder)
3535
=> ExcludeFromDescription<RouteHandlerBuilder>(builder);
3636

37-
/// <summary>
38-
/// Adds an <see cref="IProducesResponseTypeMetadata"/> to <see cref="EndpointBuilder.Metadata"/> for all endpoints
39-
/// produced by <paramref name="builder"/>.
40-
/// </summary>
41-
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
42-
/// <param name="responseType">The type of the response. Defaults to null.</param>
43-
/// <param name="statusCode">The response status code.</param>
44-
/// <param name="contentType">The response content type. Defaults to "application/json" if responseType is not null, otherwise defaults to null.</param>
45-
/// <param name="additionalContentTypes">Additional response content types the endpoint produces for the supplied status code.</param>
46-
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
47-
#pragma warning disable RS0026
48-
public static TBuilder Produces<TBuilder>(
49-
#pragma warning restore RS0026
50-
this TBuilder builder,
51-
Type? responseType = null,
52-
int statusCode = StatusCodes.Status200OK,
53-
string? contentType = null,
54-
params string[] additionalContentTypes) where TBuilder : IEndpointConventionBuilder
55-
{
56-
if (responseType is Type && string.IsNullOrEmpty(contentType))
57-
{
58-
contentType = "application/json";
59-
}
60-
61-
if (contentType is null)
62-
{
63-
return builder.WithMetadata(new ProducesResponseTypeMetadata(responseType ?? typeof(void), statusCode));
64-
}
65-
66-
return builder.WithMetadata(new ProducesResponseTypeMetadata(responseType ?? typeof(void), statusCode, contentType, additionalContentTypes));
67-
}
68-
6937
/// <summary>
7038
/// Adds an <see cref="IProducesResponseTypeMetadata"/> to <see cref="EndpointBuilder.Metadata"/> for all endpoints
7139
/// produced by <paramref name="builder"/>.
@@ -84,7 +52,7 @@ public static RouteHandlerBuilder Produces<TResponse>(
8452
string? contentType = null,
8553
params string[] additionalContentTypes)
8654
{
87-
return Produces(builder, typeof(TResponse), statusCode, contentType, additionalContentTypes);
55+
return Produces(builder, statusCode, typeof(TResponse), contentType, additionalContentTypes);
8856
}
8957

9058
/// <summary>
@@ -106,30 +74,17 @@ public static RouteHandlerBuilder Produces(
10674
string? contentType = null,
10775
params string[] additionalContentTypes)
10876
{
109-
return Produces(builder, responseType, statusCode, contentType, additionalContentTypes);
110-
}
77+
if (responseType is Type && string.IsNullOrEmpty(contentType))
78+
{
79+
contentType = "application/json";
80+
}
11181

112-
/// <summary>
113-
/// Adds an <see cref="IProducesResponseTypeMetadata"/> with a <see cref="ProblemDetails"/> type
114-
/// to <see cref="EndpointBuilder.Metadata"/> for all endpoints produced by <paramref name="builder"/>.
115-
/// </summary>
116-
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
117-
/// <param name="statusCode">The response status code.</param>
118-
/// <param name="contentType">The response content type. Defaults to "application/problem+json".</param>
119-
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
120-
#pragma warning disable RS0026
121-
public static TBuilder ProducesProblem<TBuilder>(
122-
#pragma warning restore RS0026
123-
this TBuilder builder,
124-
int statusCode,
125-
string? contentType = null) where TBuilder : IEndpointConventionBuilder
126-
{
127-
if (string.IsNullOrEmpty(contentType))
82+
if (contentType is null)
12883
{
129-
contentType = "application/problem+json";
84+
return builder.WithMetadata(new ProducesResponseTypeMetadata(responseType ?? typeof(void), statusCode));
13085
}
13186

132-
return Produces(builder, typeof(ProblemDetails), statusCode, contentType);
87+
return builder.WithMetadata(new ProducesResponseTypeMetadata(responseType ?? typeof(void), statusCode, contentType, additionalContentTypes));
13388
}
13489

13590
/// <summary>
@@ -141,45 +96,27 @@ public static TBuilder ProducesProblem<TBuilder>(
14196
/// <param name="contentType">The response content type. Defaults to "application/problem+json".</param>
14297
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
14398
public static RouteHandlerBuilder ProducesProblem(this RouteHandlerBuilder builder, int statusCode, string? contentType = null)
144-
=> ProducesProblem<RouteHandlerBuilder>(builder, statusCode, contentType);
99+
=> ProducesProblem(builder, statusCode, contentType);
145100

146101
/// <summary>
147102
/// Adds an <see cref="IProducesResponseTypeMetadata"/> with a <see cref="HttpValidationProblemDetails"/> type
148103
/// to <see cref="EndpointBuilder.Metadata"/> for all endpoints produced by <paramref name="builder"/>.
149104
/// </summary>
150-
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
105+
/// <param name="builder">The <see cref="RouteHandlerBuilder"/>.</param>
151106
/// <param name="statusCode">The response status code. Defaults to <see cref="StatusCodes.Status400BadRequest"/>.</param>
152107
/// <param name="contentType">The response content type. Defaults to "application/problem+json".</param>
153108
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
154-
#pragma warning disable RS0026
155-
public static TBuilder ProducesValidationProblem<TBuilder>(
156-
#pragma warning restore RS0026
157-
this TBuilder builder,
109+
public static RouteHandlerBuilder ProducesValidationProblem(
110+
this RouteHandlerBuilder builder,
158111
int statusCode = StatusCodes.Status400BadRequest,
159-
string? contentType = null) where TBuilder : IEndpointConventionBuilder
112+
string? contentType = null)
160113
{
161114
if (string.IsNullOrEmpty(contentType))
162115
{
163116
contentType = "application/problem+json";
164117
}
165118

166-
return Produces(builder, typeof(HttpValidationProblemDetails), statusCode, contentType);
167-
}
168-
169-
/// <summary>
170-
/// Adds an <see cref="IProducesResponseTypeMetadata"/> with a <see cref="HttpValidationProblemDetails"/> type
171-
/// to <see cref="EndpointBuilder.Metadata"/> for all endpoints produced by <paramref name="builder"/>.
172-
/// </summary>
173-
/// <param name="builder">The <see cref="RouteHandlerBuilder"/>.</param>
174-
/// <param name="statusCode">The response status code. Defaults to <see cref="StatusCodes.Status400BadRequest"/>.</param>
175-
/// <param name="contentType">The response content type. Defaults to "application/problem+json".</param>
176-
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
177-
public static RouteHandlerBuilder ProducesValidationProblem(
178-
this RouteHandlerBuilder builder,
179-
int statusCode = StatusCodes.Status400BadRequest,
180-
string? contentType = null)
181-
{
182-
return ProducesValidationProblem<RouteHandlerBuilder>(builder, statusCode, contentType);
119+
return Produces(builder, statusCode, typeof(HttpValidationProblemDetails), contentType);
183120
}
184121

185122
/// <summary>
@@ -212,45 +149,6 @@ public static TBuilder WithTags<TBuilder>(this TBuilder builder, params string[]
212149
public static RouteHandlerBuilder WithTags(this RouteHandlerBuilder builder, params string[] tags)
213150
=> WithTags<RouteHandlerBuilder>(builder, tags);
214151

215-
/// <summary>
216-
/// Adds <see cref="IAcceptsMetadata"/> to <see cref="EndpointBuilder.Metadata"/> for all endpoints
217-
/// produced by <paramref name="builder"/>.
218-
/// </summary>
219-
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
220-
/// <param name="requestType">The type of the request body.</param>
221-
/// <param name="isOptional">Sets a value that determines if the request body is optional.</param>
222-
/// <param name="contentType">The request content type that the endpoint accepts.</param>
223-
/// <param name="additionalContentTypes">The list of additional request content types that the endpoint accepts.</param>
224-
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
225-
public static TBuilder Accepts<TBuilder>(
226-
this TBuilder builder,
227-
Type requestType,
228-
bool isOptional,
229-
string contentType,
230-
params string[] additionalContentTypes) where TBuilder : IEndpointConventionBuilder
231-
{
232-
var contentTypes = GetAllContentTypes(contentType, additionalContentTypes);
233-
return builder.WithMetadata(new AcceptsMetadata(requestType, isOptional, contentTypes));
234-
}
235-
236-
/// <summary>
237-
/// Adds <see cref="IAcceptsMetadata"/> to <see cref="EndpointBuilder.Metadata"/> for all endpoints
238-
/// produced by <paramref name="builder"/>.
239-
/// </summary>
240-
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
241-
/// <param name="requestType">The type of the request body.</param>
242-
/// <param name="contentType">The request content type that the endpoint accepts.</param>
243-
/// <param name="additionalContentTypes">The list of additional request content types that the endpoint accepts.</param>
244-
/// <returns>A <see cref="RouteHandlerBuilder"/> that can be used to further customize the endpoint.</returns>
245-
public static TBuilder Accepts<TBuilder>(
246-
this TBuilder builder,
247-
Type requestType,
248-
string contentType,
249-
params string[] additionalContentTypes) where TBuilder : IEndpointConventionBuilder
250-
{
251-
return Accepts(builder, requestType, isOptional: false, contentType, additionalContentTypes);
252-
}
253-
254152
/// <summary>
255153
/// Adds <see cref="IAcceptsMetadata"/> to <see cref="EndpointBuilder.Metadata"/> for all endpoints
256154
/// produced by <paramref name="builder"/>.
@@ -265,7 +163,7 @@ public static RouteHandlerBuilder Accepts<TRequest>(
265163
string contentType,
266164
params string[] additionalContentTypes) where TRequest : notnull
267165
{
268-
return Accepts<RouteHandlerBuilder>(builder, typeof(TRequest), contentType, additionalContentTypes);
166+
return Accepts(builder, typeof(TRequest), contentType, additionalContentTypes);
269167
}
270168

271169
/// <summary>
@@ -284,7 +182,7 @@ public static RouteHandlerBuilder Accepts<TRequest>(
284182
string contentType,
285183
params string[] additionalContentTypes) where TRequest : notnull
286184
{
287-
return Accepts<RouteHandlerBuilder>(builder, typeof(TRequest), isOptional, contentType, additionalContentTypes);
185+
return Accepts(builder, typeof(TRequest), isOptional, contentType, additionalContentTypes);
288186
}
289187

290188
/// <summary>
@@ -302,7 +200,7 @@ public static RouteHandlerBuilder Accepts(
302200
string contentType,
303201
params string[] additionalContentTypes)
304202
{
305-
return Accepts<RouteHandlerBuilder>(builder, requestType, contentType, additionalContentTypes);
203+
return Accepts(builder, requestType, isOptional: false, contentType, additionalContentTypes);
306204
}
307205

308206
/// <summary>
@@ -322,7 +220,8 @@ public static RouteHandlerBuilder Accepts(
322220
string contentType,
323221
params string[] additionalContentTypes)
324222
{
325-
return Accepts<RouteHandlerBuilder>(builder, requestType, isOptional, contentType, additionalContentTypes);
223+
var contentTypes = GetAllContentTypes(contentType, additionalContentTypes);
224+
return builder.WithMetadata(new AcceptsMetadata(requestType, isOptional, contentTypes));
326225
}
327226

328227
/// <summary>

src/Http/Routing/src/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ static Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapPatch(this
1111
override Microsoft.AspNetCore.Routing.RouteValuesAddress.ToString() -> string?
1212
*REMOVED*~Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver.DefaultInlineConstraintResolver(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Routing.RouteOptions!>! routeOptions, System.IServiceProvider! serviceProvider) -> void
1313
Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver.DefaultInlineConstraintResolver(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Routing.RouteOptions!>! routeOptions, System.IServiceProvider! serviceProvider) -> void
14-
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.Accepts<TBuilder>(this TBuilder builder, System.Type! requestType, bool isOptional, string! contentType, params string![]! additionalContentTypes) -> TBuilder
15-
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.Accepts<TBuilder>(this TBuilder builder, System.Type! requestType, string! contentType, params string![]! additionalContentTypes) -> TBuilder
1614
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.ExcludeFromDescription<TBuilder>(this TBuilder builder) -> TBuilder
17-
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.Produces<TBuilder>(this TBuilder builder, System.Type? responseType = null, int statusCode = 200, string? contentType = null, params string![]! additionalContentTypes) -> TBuilder
18-
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.ProducesProblem<TBuilder>(this TBuilder builder, int statusCode, string? contentType = null) -> TBuilder
19-
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.ProducesValidationProblem<TBuilder>(this TBuilder builder, int statusCode = 400, string? contentType = null) -> TBuilder
2015
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.WithDescription<TBuilder>(this TBuilder builder, string! description) -> TBuilder
2116
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.WithSummary<TBuilder>(this TBuilder builder, string! summary) -> TBuilder
2217
static Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions.WithTags<TBuilder>(this TBuilder builder, params string![]! tags) -> TBuilder

0 commit comments

Comments
 (0)