I am trying to generate my Swagger documentation as per the Microsoft Docs here
Using other answers here and here has not yielded any progress on the issue...
I'm configuring the swagger gen like so:
serviceCollection.AddSwaggerGen(setupAction =>
{
setupAction.SwaggerDoc(
"Open API Specification for Haros v1",
new OpenApiInfo()
{
Title = "Haros API",
Version = "v1",
Description = "Haros API Description",
Contact = new OpenApiContact()
{
Email = "myname@domain",
Name = "My Name"
},
License = new OpenApiLicense()
{
Name = "MIT License"
}
});
setupAction.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT",
Description = "Attach your bearer token in this format to consume the API: Bearer {token}",
});
setupAction.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer",
},
}, new List<string>()
},
});
});
And adding the middleware like so:
app.UseSwagger();
app.UseSwaggerUI(setupAction =>
{
setupAction.SwaggerEndpoint("/swagger/v1/swagger.json", "Haros API v1");
setupAction.RoutePrefix = string.Empty;
});
Both endpoints (https://localhost:5001/swagger/index.html and https://localhost:5001/swagger/v1/swagger.json) are returning 404.
I've added the option to GenerateDocumentationFile to my project and decorated my API controller endpoint with the /// comments.
What I did notice is that if I comment out the RoutePrefix I manage to load this:

I have followed the Microsoft docs link as close as possible, and I don't see anything I potentially missed. Does anyone see what I'm doing wrong or missed?
(additional info: using .NET 5 and loading via Kestrel)