Search code examples
c#swaggerazure-service-fabric

Unable to Load swagger API page, missing swagger-ui.css


I am trying to add swagger to my service, but I am having some problems. When I go to my page I get multiple calls to my webpage

  • /swagger/index.html -> Returns 200
  • /swagger/swagger-ui.css -> Returns 500
  • /swagger/swagger-ui-bundle.js -> Returns 500
  • /swagger/swagger-ui-standalone-preset.js -> Returns 500
  • /swagger/favicon-32x32.png -> Returns 500
  • /swagger/favicon-16x16.png -> Returns 500

If I go to localhost/api/myServiceName/swagger/v1/swagger.json, the file looks ok. I can see my endpoints and DTOs.

In my code I do the following:

ConfigureServices():
services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "MyService API", Version = "v1" }); });

Configure():
app.UseSwagger();
app.UseSwaggerUI(
c =>
{
    c.SwaggerEndpoint($"/api/MyService/swagger/v1/swagger.json",
        "MyService API V1");
});

My project references:

  • Swashbuckle.AspNetCore 3.0.0
  • Swashbuckle.AspNetCore.Swagger 3.0.0
  • Swashbuckle.AspNetCore.SwaggerGen 3.0.0
  • Swashbuckle.AspNetCore.SwaggerUI 3.0.0

I am pretty sure something is wrong with my configuration. Any idea on what the error is?


Solution

  • Add a reference to Microsoft.AspNetCore.StaticFiles

    https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/851