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.

No API descriptions with Swashbuckle 5.0 and OWIN

See original GitHub issue

I’ve read the documentation on Swashbuckle 5.0 and the only thing we have to do is to enable Swagger and SwaggerUI via Swashbuckle.Core. The /swagger/ui/index shows up but with no descriptions…

Here is my Startup.cs :

public partial class Startup
  {
    public void Configuration(IAppBuilder app)
    {
      ConfigureAuth(app);
      ConfigureWebApi(app);
      RegisterSwagger(app);
    }
  }

Here is my Startup.SwaggerConfig.cs :

public partial class Startup
    {
      public static void RegisterSwagger(IAppBuilder app)
      {
          GlobalConfiguration.Configuration 
            .EnableSwagger(c =>
                  {
                      c.SingleApiVersion("v1", "MyAPI");
                      c.IncludeXmlComments(GetXmlCommentsPath());
                  })
              .EnableSwaggerUi();
      }

      protected static string GetXmlCommentsPath()
      {
        return System.String.Format(@"{0}\bin\MyAPI.XML", System.AppDomain.CurrentDomain.BaseDirectory);
      }
    }

Did I miss something? I’ve make some research on that issue and it seems that with Swashbuckle 4.0 there was an Swashbuckle.Bootstrapper.Init(config); Is it replaced with something else?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
corneliu-serediuccommented, May 28, 2015

Ok, I have managed to configure Swagger inside OWIN Startup class:

public void Configuration(IAppBuilder app)
    {
        HttpConfiguration config = new HttpConfiguration();

        // Swagger
        SwaggerConfig.Register(config);

        // Authentication token
        ConfigureOAuth(app);

        // SignalR configuration
        ConfigureSignalR(app);

        // Register routes
        WebApiConfig.Register(config);

        // Allow cross-domain requests
        app.UseCors(CorsOptions.AllowAll);

        app.UseWebApi(config);
    }

And in SwaggerConfig,cs:

using Swashbuckle.Application;
using System.Web.Http;

namespace Name.API 
{
     public class SwaggerConfig
     {
          public static void Register(HttpConfiguration config)
          {
                config.EnableSwagger(c =>
                {
                    c.SingleApiVersion("v1", "Name.API");   
                })
            .EnableSwaggerUi(c =>
                {
                });
         }
     }
}
5reactions
galvesribeirocommented, Oct 14, 2015

Thanks @corneliu-serediuc this handled my problem. The actual nuget package uses [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), “Register”)] which only works when the project isn`t based on OWIN. If you comment this attribute out, and call the Register from the Startup.cs the methods get discovered just fine… Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No API descriptions with Swashbuckle 5.0 and OWIN #196
I've read the documentation on Swashbuckle 5.0 and the only thing we have to do is to enable Swagger and SwaggerUI via Swashbuckle.Core....
Read more >
Swashbuckle 5 can't find my ApiControllers
I'm not sure if the XML docs working/not-working has anything to do with it though, as I get absolutely no controllers on the...
Read more >
Swashbuckle.WebApi
When you host Web API 2 on top of OWIN/SystemWeb, Swashbuckle cannot correctly resolve VirtualPathRoot by default. You must either explicitly set ...
Read more >
How to Setup Swagger in Web API ASP.NET ...
Since we are using Owin Configuration there is now a simple command that needs to be called SwaggerConfig.Register(config); . This will call the ......
Read more >
ASP.NET Web API Documentation using Swagger
Short tutorial which shows how to add ASP.NET Web API documentation using Swagger and Swashbuckle.
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