I am trying to implement Swagger in my WebApi. However, it is not working. The issue is that swagger.json loads forever. When I try to go to /swagger/v1/swagger.json
, it loads forever and my CPU usages spikes to 100%.
This is my configuration:
public class Startup
{
...
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "ToDo API"
});
});
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider services)
{
...
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
// Setup the endpoints.
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller}/{action}/{id?}");
endpoints.MapHub<HomeHub>("/homehub");
});
}
}
I of course already looked around on the internet, but could not find any solution. I do not get any errors, so what could be the issue?
Update:
I have tried generating the json file with the CLI, and same issue. It just loads and nothing happens. Besides taking 24gb of memory...