question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger UI page does not show when using Swashbuckle.AspNetCore for .net core web api stateless service in Azure Service Fabric

See original GitHub issue

OS: Windows 10 (Version 1703; OS Build 16281.1000) Visual Studio Version: 15.3.3 (VS 2017) Swashbuckle.AspNetCore Nuget Version: 1.0.0 Service Fabric Version: 5.7.198.9494 Service Fabric Version SDK: 2.7.198.9494

  1. Create a service fabric application and choose ‘Stateless ASP.NET Core’ service template
  2. Select ‘Web API’ ASP.NET Code 2.0.
  3. This creates a service fab app project along with ‘Web1’ web api project.
  4. Notice that Web1 project’s target environment is set to .net framework 4.7 (even though we selected asp.net core 2.0).
  5. Run the app and a browser is launched with ‘localhost:port/api/values’ and the response ([“value1”, “value2”]) is shown. Good so far.
  6. Next add a nuget package Swashbuckle.AspNetCore Nuget Version: 1.0.0
  7. In ConfigureServices method of Startup.cs file, change the code to:
            services.AddMvc();
            services.AddSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
            });
  1. In Configure method of Startup.cs file, change the code to:
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API");
            });
  1. Run the code. The endpoint (localhost:port/api/values) works as expected.
  2. The endpoint (http://localhost:port/swagger/v1/swagger.json) works as expected.
  3. The endpoint (http://localhost:port/swagger) causes 500 internal server error.
  4. The endpoint (http://localhost:port/swagger/ui) causes 404 resource not found error.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:8

github_iconTop GitHub Comments

37reactions
rudeGitcommented, Sep 13, 2017

I found that I needed to install nuget package Microsoft.AspNetCore.StaticFiles 2.0.0 (which will replace 1.0.0). Once I did that, the swagger page came up.

14reactions
iparimalcommented, Mar 13, 2018

I’ve fixed this using NSwag. I’ve removed “Swashbuckle.AspNetCore” and using “NSwag.AspNetCore” now. It works without any issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger is not Working Asp.net Core how to open ...
Swagger requires all controller methods to have ActionVerbs, except those with [ApiExplorerSettings(IgnoreApi = true)] attribute.
Read more >
Swagger UI page is blank on localhost IISExpress SSL URL
I am developing a v5.0.6 ASP.NET Core WebApi and included Swashbuckle.AspNetCore Swagger with SwaggerUI enabled. I am developing with Visual ...
Read more >
Swagger UI on Service Fabric with Stateless ASP.NET Core ...
AspNetCore.StaticFiles I was using a vanilla configuration in my code where I setup swagger endpoint: And where I setup Swagger UI…
Read more >
Swagger for Azure Service Fabric Stateless Web API application
As suggested in my comment install the core Swashbuckle NuGet package install-package Swashbuckle.Core. Then in the Startup.cs of your WebApi project add
Read more >
Modern API Design with ASP.NET Core 2
developer gain useful skills for developing APIs in ASP.NET Core 2 and is ... RPC-style web service is not wrong, but it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found