Search code examples
xmlvisual-studioswagger

XML comments file could not be found - Swagger


This is certainly one of those that drives you nuts. As the title indicates all I'm simply trying to do is display comments pulled from an xml file using swagger.

I appear to have taken all steps according to the swagger documentation but to no avail. Hopefully you kind folk can point me in the right direction.

Steps Taken: enter image description here

Ensured file exists:

enter image description here

Configured SwaggerConfig.cs

enter image description here

I've tried changing the path too: @"bin/....xml"

Nothing seems to work.

**The Error "Could not find file": **

enter image description here

Can anyone point me in the right direction please?

Regards,


Solution

  • Ok, So I managed to get it to work by pointing to the root directory.

    I still have no idea why it cannot detect the xml file in the bin directory. Again this worked by adding an xml file within the root.

    Code Changes:

    var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
                            //var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
                            var commentsFileName = "Comments" + ".XML";
                            var commentsFile = Path.Combine(baseDirectory, commentsFileName);
    
                            c.IncludeXmlComments(commentsFile);