Forum Discussion

gpl's avatar
gpl
New Contributor
4 years ago

AspNetCore 3.1 swagger ui only displays Loading

Hello,

I'm working on a project, that started with aspnet core 1.1. It was upgraded to 2.2 and latest on to 3.1. During the upgrade of 1.1 to 2.2 the swagger was working without any problems. But the upgrade from 2.2 to 3.1 has broken something and I commented out the swagger.
I'm now trying to re-enable swagger but when I point to the swagger endpoint I only see a "Loading" spinner.

Within a newly created project without only basic controller I'm able to see the swagger documentation.

 

My current state looks like this:

 

public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            // services.AddMvcCore().AddApiExplorer();
            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

// Authentication and Authorization is added
services.AddCors(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "my API", Version = "v1" }); }); }
public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env)
        {
             ....
             app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "my API");
            });
           app.UseRouting();
            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader());
            app.UseForwardedHeaders();

            app.UseAuthentication();
            app.UseAuthorization();
            
            app.UseEndpoints(p => p.MapControllerRoute(name: "default", pattern: "{controller}/{action=Index}/{id?}"));

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });
}

Output looks like this:

 

I hope someone has some ideas or could suggest something


Kind regards