Skip to content

Commit 0b2da29

Browse files
Deprecate WithOpenApi extension methods with ASPDEPR002 diagnostic code (#62779)
Co-authored-by: captainsafia <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
1 parent 84c4547 commit 0b2da29

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class OpenApiEndpointConventionBuilderExtensions
2929
/// </remarks>
3030
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
3131
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
32+
[Obsolete("WithOpenApi is deprecated and will be removed in a future release. For more information, visit https://aka.ms/aspnet/deprecate/002.", DiagnosticId = "ASPDEPR002")]
3233
[RequiresDynamicCode(TrimWarningMessage)]
3334
[RequiresUnreferencedCode(TrimWarningMessage)]
3435
public static TBuilder WithOpenApi<TBuilder>(this TBuilder builder) where TBuilder : IEndpointConventionBuilder
@@ -48,6 +49,7 @@ public static TBuilder WithOpenApi<TBuilder>(this TBuilder builder) where TBuild
4849
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
4950
/// <param name="configureOperation">An <see cref="Func{T, TResult}"/> that returns a new OpenAPI annotation given a generated operation.</param>
5051
/// <returns>A <see cref="IEndpointConventionBuilder"/> that can be used to further customize the endpoint.</returns>
52+
[Obsolete("WithOpenApi is deprecated and will be removed in a future release. For more information, visit https://aka.ms/aspnet/deprecate/002.", DiagnosticId = "ASPDEPR002")]
5153
[RequiresDynamicCode(TrimWarningMessage)]
5254
[RequiresUnreferencedCode(TrimWarningMessage)]
5355
public static TBuilder WithOpenApi<TBuilder>(this TBuilder builder, Func<OpenApiOperation, OpenApiOperation> configureOperation)

src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
#pragma warning disable ASPDEPR002 // WithOpenApi is deprecated
5+
46
using Microsoft.AspNetCore.Builder;
57
using Microsoft.AspNetCore.Http;
68
using Microsoft.AspNetCore.Routing;

src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
#if (EnableOpenAPI)
129129
})
130130
.WithName("GetWeatherForecast")
131-
.WithOpenApi()
132131
.RequireAuthorization();
133132
#else
134133
})

0 commit comments

Comments
 (0)