Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling documentation within WebApi2 help page

I have a simple webapi2 project.

The only information I can seem to find myself refers to the older webapi1

From my controller if I have

   /// <summary>
    /// Gets a list of not very interesting information
    /// </summary>
    /// <returns>The list</returns>
   [ResponseType(typeof(ExampleModel))]
    public IHttpActionResult Get()
    {
        var data = new List<ExampleModel>()
        {
            new ExampleModel()
            {
                Date = DateTime.Now,
                Name = "Tom"
            },
            new ExampleModel()
            {
                Date = DateTime.Now.AddDays(-20),
                Name = "Bob"
            }
        };

why is no information appearing when I try browse to the help page. I am told No documentation available.

Is there a magic switch somewhere that will turn on automated population of this data?

like image 708
Diver Dan Avatar asked Jan 07 '14 03:01

Diver Dan


People also ask

What is the one step you must take to enable XML comments to appear in the default Web API?

The XmlDocumentationProvider is looking for the xml file(having your xml code comments) which gets generated when you compile your project. You can enable generating this by going to your project Properties -> Build -> Output. Here select the checkbox for XML Documentation file.


1 Answers

if you referring to displaying the xml comments, then you can find my answer here:

ASP.NET Web API Help Page documentation using Xml comments on controllers

Be sure to uncomment this code in Areas/HelpPage/App_Start/HelpPageConfig.cs

// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

Also make sure the xml file goes in App_Data not bin where it defaults to in project properties

like image 88
Kiran Avatar answered Oct 02 '22 13:10

Kiran