Thanks for the details! Since you upgraded the app to .NET 10, the errors come from an OpenAPI package mismatch. The short answer to “what do I do with OpenAPI and Swashbuckle to keep my .NET 9 behavior?” is:
**Option A — Keep Swashbuckle on .NET 10:**
- Upgrade to Swashbuckle.AspNetCore v10 (compatible with .NET 10 & Microsoft.OpenApi v2). dotnet add package Swashbuckle.AspNetCore --version 10. dotnet add package Swashbuckle.AspNetCore.Annotations --version 10.
- Remove any explicit
Microsoft.OpenApireference from.csprojand rundotnet clean && dotnet restore. Swashbuckle v10 brings OpenAPI.NET v2 transitively; mixing versions causes your compile/runtime errors. [github.com]- Update your JWT security code to the v10 pattern (register a named scheme and reference it when adding
AddSecurityRequirement). [github.com]- Keep your UI as before (
UseSwagger+UseSwaggerUI). [nuget.org]
Option B — Use built‑in OpenAPI and add a UI:
- Add
Microsoft.AspNetCore.OpenApi, thenAddOpenApi()+MapOpenApi()(serves/openapi/v1.json). [learn.microsoft.com]- Add a UI: either Swagger UI (
Swashbuckle.AspNetCore.SwaggerUI) and point to/openapi/v1.json, or use Scalar (Scalar.AspNetCore) which maps withapp.MapScalarApiReference(). [learn.microsoft.com], [guides.scalar.com] Both options are fully supported in .NET 10. The built‑in OpenAPI path is the direction the templates moved in .NET 9 (OpenAPI 3.1, transformers, multiple docs, AoT‑friendly). [learn.microsoft.com] If you share your.csprojpackage list, I can confirm which path you’re currently on and provide the exact code edits.