-1

Unable to use 'swagger.net' in visual studio 2015 while creating .NET web api. Why? I encountered an error while creating a web api based on .NET. I've installed swagger and related packages.

Error on: SwaggerActionFilter(), XmlCommentDocumentationProvider

My function is :

public static void PostStart() 
{
    var config = GlobalConfiguration.Configuration;

    config.Filters.Add(new SwaggerActionFilter());

    try
    {
        config.Services.Replace(typeof(IDocumentationProvider),
            new XmlCommentDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/DigiCob.XML")));
    }
    catch (FileNotFoundException)
    {
        throw new Exception("Please enable \"XML documentation file\" in project properties with default (bin\\DigiCob.XML) value or edit value in App_Start\\SwaggerNet.cs");
    }
}

enter image description here

juanferrer
  • 1,192
  • 1
  • 16
  • 29
  • who edited my post before monitoring???... –  Jul 20 '17 at 10:12
  • Your post was edited to cut out your swearing, because it's pointless. Nevertheless, did you add the reference to the DLL at Visual Studio's Project References? – Ian H. Jul 20 '17 at 10:14
  • Pretty fine... Ok bro... Could you please guide me to do so... –  Jul 20 '17 at 10:21
  • 2
    In your Visual Studio Project there should be an item `References`. Right-click it and go to `Add Reference...`. Then, in the window that pops up, go to the tab `Browse` and navigate to the DLL that you want to add, then click on the checkbox next to it to add it to your references. – Ian H. Jul 20 '17 at 10:25
  • I'm a new born baby in .net, so could you point me which DLL, my intention was just to document ma API with Swagger, i did it the same few times before, but then this error. –  Jul 20 '17 at 10:31
  • Shouldn't you have a file `swagger.dll` or something like that? – Ian H. Jul 20 '17 at 10:36
  • Couldn't resolve Ian, I think its not exactly what the problem need... –  Jul 20 '17 at 10:45

1 Answers1

1

The .NET implementation of the Swagger specification is called Swashbuckle.

Install the Swashbuckle nuget package and you should be fine.

Dimitar Tsonev
  • 3,711
  • 5
  • 40
  • 70
  • I've done this bro, don't know what to install next, i think the only way to get out of this is by recreating the whole project. –  Jul 20 '17 at 11:01
  • Did you added the proper using statements ? – Dimitar Tsonev Jul 20 '17 at 11:12
  • Yes bro, I'm pretty sure on that, error is to avoid unnecessary using statements, i couldn't use 'using Swagger.net '. –  Jul 20 '17 at 11:20
  • 1
    There's no such namespace "Swagger.net" in the Swashbuckle package. Are you using different nuget package ? – Dimitar Tsonev Jul 20 '17 at 11:36
  • 1
    Ok, I think that you're using this implementation of swagger - https://github.com/giacomelli/DG-Swagger.Net/tree/master/Swagger.Net. You should start using https://github.com/domaindrivendev/Swashbuckle – Dimitar Tsonev Jul 20 '17 at 11:37
  • Thanks ma friends...\ –  Jul 20 '17 at 11:41