elsa-workflows / elsa-workflows/elsa-core
Including Elsa.Extensions in Program.cs causes Swagger to break
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
Swagger breaks when using Elsa 3.5.1 in .NET 8. Swagger displays "Failed to Load API definition" with the error "Fetch error: response status is 404 undefined". This appears to happen as soon as you add `using Elsa.Extensions` to your Program.cs file.
## Steps to Reproduce
To help us identify the issue more quickly, please follow these guidelines:
1. **Detailed Steps**: Install Elsa 3.5.1 to a project. Add `using Elsa.Extensions` to your Program.cs file. Launch your app and visit `/swagger`. The error will be displayed.
2. **Code Snippets**:
Program.cs:
```
using Elsa.Extensions;
using MyApp.Workflows;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddElsa(elsa =>
{
elsa.AddWorkflow();
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
```
4. **Reproduction Rate**: Every time
## Expected Behavior
Swagger should load with all endpoints.
## Actual Behavior
Swagger instead displays "Failed to Load API definition" with the error "Fetch error: response status is 404 undefined"
## Screenshots
## Environment
- **Elsa Package Version**: 3.5.1
- **Operating System**: Windows 11 Enterprise
## Troubleshooting Attempts
I tried uninstalling the Elsa.Http package, but the issue still occurs. I also tried working from a completely fresh project based on the Web API Template in Visual Studio, and the issue still occurs. I also removed `builder.Services.AddElsa()` from Program.cs, and the issue still occurs (That is, `using Elsa.Extensions` is the only Elsa code in Program.cs).
Contributor guide
Assessment
This issue has not been assessed yet.