Reputation: 1741
I'm trying to install Swagger via the Nuget package (Swashbuckle) however I can't get it to work.
It's a vanilla VS 2013 Web Api 2 project. There is a single error on the JS console: Uncaught TypeError: Cannot read property 'tags' of null.
A 404 is received on the request for /swagger/ui/lib/underscore-min.map
I found a link that recommended disabling BrowserLink using vs:EnableBrowserLink in webconfig, but it didn't seem to have any effect.
Any ideas?
Upvotes: 4
Views: 2167
Reputation: 409
I installed Swashbuckle.Core, ensured that XML outputs were being created and with a little config it worked right away.
public static void Register(HttpConfiguration config)
{
...
config
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "My API Title");
c.IncludeXmlComments(GetXmlCommentsFileLocation());
})
.EnableSwaggerUi();
...
}
private static string GetXmlCommentsFileLocation()
{
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory + "\\bin";
var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
var commentsFileLocation = Path.Combine(baseDirectory, commentsFileName);
return commentsFileLocation;
}
Upvotes: 4