From 3bfdbd0e787d5155e1fce38b31013e76a74a39d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 16:00:34 +0000 Subject: [PATCH 1/3] Initial plan From 2efc529779c747abf7e0acd27332d905d2a21aa5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 16:19:11 +0000 Subject: [PATCH 2/3] Add Obsolete attributes with ASPDEPR002 to WithOpenApi methods Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com> --- .../Extensions/OpenApiEndpointConventionBuilderExtensions.cs | 2 ++ .../Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs | 2 ++ .../WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs b/src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs index ac4b49ca8306..0f3ed82a2a3e 100644 --- a/src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs +++ b/src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs @@ -29,6 +29,7 @@ public static class OpenApiEndpointConventionBuilderExtensions /// /// The . /// A that can be used to further customize the endpoint. + [Obsolete("WithOpenApi is deprecated and will be removed in a future release. For more information, visit https://aka.ms/aspnet/deprecate/002.", DiagnosticId = "ASPDEPR002")] [RequiresDynamicCode(TrimWarningMessage)] [RequiresUnreferencedCode(TrimWarningMessage)] public static TBuilder WithOpenApi(this TBuilder builder) where TBuilder : IEndpointConventionBuilder @@ -48,6 +49,7 @@ public static TBuilder WithOpenApi(this TBuilder builder) where TBuild /// The . /// An that returns a new OpenAPI annotation given a generated operation. /// A that can be used to further customize the endpoint. + [Obsolete("WithOpenApi is deprecated and will be removed in a future release. For more information, visit https://aka.ms/aspnet/deprecate/002.", DiagnosticId = "ASPDEPR002")] [RequiresDynamicCode(TrimWarningMessage)] [RequiresUnreferencedCode(TrimWarningMessage)] public static TBuilder WithOpenApi(this TBuilder builder, Func configureOperation) diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs index 7a518238d616..8c14337a69ed 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiRouteHandlerBuilderExtensionTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#pragma warning disable ASPDEPR002 // WithOpenApi is deprecated + using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs index 4e502393522f..07b6facfc66c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs @@ -1,6 +1,7 @@ #if (GenerateApi) using System.Net.Http; #endif +#pragma warning disable ASPDEPR002 // WithOpenApi is deprecated using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; #if (GenerateGraph) From f0200ea773d19ce75106c66bac91c2d87cff6ffe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 17 Jul 2025 16:31:21 +0000 Subject: [PATCH 3/3] Remove WithOpenApi call from project template as requested in review Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com> --- .../WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs index 07b6facfc66c..415dc9b38f31 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.MinimalAPIs.OrgOrIndividualB2CAuth.cs @@ -1,7 +1,6 @@ #if (GenerateApi) using System.Net.Http; #endif -#pragma warning disable ASPDEPR002 // WithOpenApi is deprecated using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; #if (GenerateGraph) @@ -129,7 +128,6 @@ #if (EnableOpenAPI) }) .WithName("GetWeatherForecast") -.WithOpenApi() .RequireAuthorization(); #else })