12

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?

1

1 Answer 1

15

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

Sign up to request clarification or add additional context in comments.

3 Comments

I had tried that without any luck, however based on the date of the post not sure if its still relevant for webapi2
actually its still relevant to Web API 2 also. BTW, did you uncomment the line of code in HelpPageConfig.cs to enable documentation from the xml file?
I don't get why the xml file has to move to app_data and not bin? I have my xml files in bin and I'm not able to view documentation comments in the server. However local dev works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.