Hi @Falanga, Rod, DOH ,
Thanks for sharing your code and detailed explanation. Based on your Program.cs, the issue is that Swagger is only configured to run in the Development environment, so if your environment isn’t detected as Development, Swagger won’t appear when you debug the API.
Let’s go through a few points to check:
- Confirm your environment setting
In Visual Studio, Swagger only appears when
if (app.Environment.IsDevelopment())
is true. Check your launch profile under: Properties → launchSettings.json
Make sure it contains:
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
If it’s set to "Production" or missing, Swagger will not load.
- Remove duplicate Swagger configuration blocks
You have two identical blocks for:
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(...);
}
Remove one of them - only one is needed. Having it twice won’t break Swagger, but it’s redundant and can cause confusion.
- Test Swagger endpoint directly
After launching your Minimal API, try navigating manually to:
https://localhost:<port>/swagger
If you still don’t see the UI, check the console output to confirm the app is running in Development mode.
- Reference documentation
You can review this step-by-step guide on enabling Swagger in Minimal APIs: Add OpenAPI support to a minimal API
Your Swagger setup is correct - it’s just not being triggered because your environment likely isn’t set to Development after moving the project to a new solution. Once you fix that in launchSettings.json, Swagger should appear when you debug.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.