8

I have a post action receiving a FromBody-parameter of type Person. In the HelpPage I get information about the Person paramater. Is it possible to list information about the properties in Person instead and use documentation from XML documentation file to get descriptions for each property?

public class PersonController : ApiController
{
    /// <summary>
    /// Add a person
    /// </summary>
    /// <param name="person">Person to add</param>
    /// <returns></returns>
    [HttpPost]
    public HttpResponseMessage Add([FromBody] Person person)
    {
        // ...

        return Request.CreateResponse(HttpStatusCode.Created);
    }
}

/// <summary>
/// A person
/// </summary>
public class Person
{
    /// <summary>
    /// The name of the person
    /// </summary>
    public String Name { get; set; }

    /// <summary>
    /// The age of the person
    /// </summary>
    public Int32 Age { get; set; }
}
3
  • Currently this is not supported out of the box. There is a related work item which asks for help page generation for data annotation attributes used on a model. Your scenario should work afters its fixed: aspnetwebstack.codeplex.com/workitem/877 Commented Mar 28, 2013 at 14:05
  • Thanks! Make a reply here and I'll mark it as an answer! Commented Mar 28, 2013 at 14:10
  • Did you ever get this working with /// comments? The work item linked to by @KiranChalla seems to have implemented annotation support, but as of Oct '15 the docs still aren't being displayed on the help page. Commented Oct 22, 2015 at 8:04

1 Answer 1

6

Currently this is not supported out of the box. There is a related work item which asks for help page generation for data annotation attributes used on a model. Your scenario should work afters its fixed: http://aspnetwebstack.codeplex.com/workitem/877

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

1 Comment

The latest version (I'm using ASP.NET Web API 2.2 alongside MVC5) now includes generated help files that show the data annotations used. See strathweb.com/2014/01/… for details.

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.