Swagger UI on '.net Core hosted' Blazor WASM solution Web API project
When you launch your Blazor app, manually go to /swagger/index.html and you will see the standard Swagger UI.
If you want the SwaggerUI to show up when you run your app, instead of the Blazor Client, edit your launchSettings.json and set the "launchUrl" value of your startup profile to /swagger/index.html
If you would like to add a link to it in your MainLayout.razor, and make sure the link only displays in the Development Environment.
EDIT: You need to make sure Swagger is set up on the server in your program.cs file. (Assuming Asp.NET Core 6, if using 5, there should be similar initialization code in your Startup.cs file)
var builder = WebApplication.CreateBuilder(args);
...
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "MyBlazor", Version = "v1" });
});
...
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
app.UseSwagger();
app.UseSwaggerUI(c =>
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyBlazor v1"));
}