1
votes

I am developing an Azure Service Fabric Service, in which I have used Swashbuckle.AspNetCore to build API List. I am using the following code in my Startup.cs file

In ConfigureServices(IServiceCollection services)

services.AddSwaggerGen(c =>
                 {
                      c.SwaggerDoc("Backend", new Info { Title = "My Backend", Version = "v1.0" });
                 });`

And in Configure(IApplicationBuilder app, IHostingEnvironment env)

` app.UseSwagger(c => c.PreSerializeFilters
     .Add((swagger, httpReq) => swagger.Host = httpReq.Host.Value));

  app.UseSwaggerUI(c => c.SwaggerEndpoint("/MyApp.Fabric/MyApp.Backend/swagger/Backend/swagger.json",
        "Backend"));`

Here, because I am developing SF service, I have used reverse proxy with swagger endpoint configuration. Now the same thing is working with my other services except one. I have the same code and same version of Swashbuckle.AspNetCore nuget used in all of my services that is 3.0.0

When I try to access the SwaggerUI for this service, I am getting the following error

enter image description here

Can anyone please help me on this ? I have been trying but could not get any suitable solution..

1
This is clearly an access issue, make sure you can manually access that endpoint you have configured - Helder Sepulveda
No, I can not access this endpoint manually. - starklord
According to the error information, it indicate that can't load api definition. You could refer to this document blog to config swagger in the service fabric project. - Tom Sun - MSFT
IF the swagger configuration is the same as your other services, and those are OK, this smells like something in Azure, maybe a routing issue on the proxy? - Helder Sepulveda

1 Answers

0
votes

On my case, when I dig the problem in more depth, I found in my APIs, there are some objects used which don't have any namespaces assigned. And somehow the runtime could not resolve the definitions for those objects which leads to a failure to load API definitions.

@Tom Sun, if you could post your comment as an answer, I will be able to mark it as answer. Thank you.