Swagger UI page does not show when using Swashbuckle.AspNetCore for .net core web api stateless service in Azure Service Fabric
See original GitHub issueOS: 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
- Create a service fabric application and choose ‘Stateless ASP.NET Core’ service template
- Select ‘Web API’ ASP.NET Code 2.0.
- This creates a service fab app project along with ‘Web1’ web api project.
- Notice that Web1 project’s target environment is set to .net framework 4.7 (even though we selected asp.net core 2.0).
- Run the app and a browser is launched with ‘localhost:port/api/values’ and the response ([“value1”, “value2”]) is shown. Good so far.
- Next add a nuget package Swashbuckle.AspNetCore Nuget Version: 1.0.0
- 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" });
});
- 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");
});
- Run the code. The endpoint (localhost:port/api/values) works as expected.
- The endpoint (http://localhost:port/swagger/v1/swagger.json) works as expected.
- The endpoint (http://localhost:port/swagger) causes 500 internal server error.
- The endpoint (http://localhost:port/swagger/ui) causes 404 resource not found error.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
I’ve fixed this using NSwag. I’ve removed “Swashbuckle.AspNetCore” and using “NSwag.AspNetCore” now. It works without any issue.