Swashbuckle.MVC

 

The Swashbuckle package for documenting WebAPI is really awesome. I have used for documenting Exporter API for Word/Excel/PDF/ODS/ODT.

One problem though: It does not respect the layout of your site.

For example, if the original header is this

 

when  I click on API test(swagger)

 

. This is not what I want – since I want the same layout.

Enter NuGet package https://www.nuget.org/packages/Swashbuckle.MVC/ . What it does is

1. add a controller(SwashbuckleMVCController), and Index action inside the controller.

2. add a View(SwashbuckleMVC/Index.cshtml) to your application

3. add a module to your application . The module intercept /swagger/ui/index call and modify with a Filter the send data ( practically, it adds to the beginning and the end of the stream the bytes from the Index action that I mentioned at 1)

Cons: It adds another <html> inside the main <html> . I made an issue on Swashbuckle to mention that https://github.com/domaindrivendev/Swashbuckle/issues/658

 

The code is free on https://github.com/ignatandrei/Swashbuckle.MVC .

You can test it on http://exporter.azurewebsites.net/swagger/ui/index