Swagger / Swashbuckle not working on Visual Studio 2013 Web API 2 project

I am trying to install Swagger through the Nuget package (Swashbuckle), but I cannot get it to work.

This is a Vanilla VS 2013 Web Api 2 project. There is only one error on the JS console: Uncaught TypeError: Unable to read null property tags.

A 404 is accepted on request for / swagger / ui / lib / underscore -min.map

I found a link that recommended disabling BrowserLink with vs: EnableBrowserLink in webconfig, but this showed no effect.

Any ideas?

+4
source share
1 answer

Swashbuckle.Core, XML- , .

    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;
    }
+4

All Articles