Swagger Integration

OtterApi ships with OtterApiSwaggerDocumentFilter, a Swashbuckle document filter that automatically adds all auto-generated routes to your Swagger / OpenAPI specification. One line of configuration is all that is needed.

Setup

Program.cs
builder.Services.AddSwaggerGen(options =>
{
    options.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
    options.DocumentFilter<OtterApiSwaggerDocumentFilter>();  // ← add this
});

What is auto-generated

The filter generates the full OpenAPI spec for every registered entity. This includes:

💡
The filter reads the entity configuration directly from IOtterApiRegistry, so it stays in sync with your entity registrations automatically — no manual Swagger annotations needed.

Complete example with Swagger UI

Program.cs
builder.Services.AddSwaggerGen(opt =>
{
    opt.SwaggerDoc("v1", new OpenApiInfo { Title = "Shop API", Version = "v1" });
    opt.DocumentFilter<OtterApiSwaggerDocumentFilter>();
});

var app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthentication();
app.UseAuthorization();
app.UseOtterApi();
app.MapControllers();
app.Run();