3

I'm using MVC4 WebAPI and have some questions;

  1. How can we define the "content" of the Parameters page [Additional Information] ??
    By default this one states "Define this parameter in the request body" ??

  2. How can we define the sample data on the Parameters page [Sample] ??
    For example let's assume one string value should be either "COME" or "GO", how can I get that stated on the help page instead of getting their defaults "string" values?

  3. Where is the right place to put some constraints like the Headers values expected or the possible Responses/Errors that the API will produce so that it will appear on the Help Page ?

wonea
  • 4,783
  • 17
  • 86
  • 139
SF Developer
  • 5,244
  • 14
  • 60
  • 106

1 Answers1

2

1) You can specify a comment for the parameter by specifying it in the XML tags. Example:

/// <summary>
///     Put your comments about / description of this API call.
/// </summary>
/// <param name="myParameter">
///     Put your comments about / description of this parameter here.
/// </param>
[Route("")]
public HttpResponseMessage Get(int my Parameter)
{
    // Code for your action
}

If your parameter is a complex type and you want documentation about the properties of that complex type, this is not currently supported in the released version. However, it works in the nightly build version, found here: https://aspnetwebstack.codeplex.com/wikipage?title=Use%20Nightly%20Builds

2) You can specify your own sample data by following the instructions found here: http://blogs.msdn.com/b/yaohuang1/archive/2012/10/13/asp-net-web-api-help-page-part-2-providing-custom-samples-on-the-help-page.aspx

3) I think that depends on whether this is global, per controller, or per action. If it's global you can just put it below the title on the Index.cshtml page in the HelpPage area and state that it applies to all api calls. If it's per controller or per action, I would put it in the XML summary of that controller or action.

mayabelle
  • 9,804
  • 9
  • 36
  • 59
  • 1
    I've been looking everywhere for an answer to (3), and your suggestion is the only one I can find on the web. Its not an ideal solution, but at this point, I'll take it! – David Chiew Nov 06 '15 at 05:08