3

Consider the following exmaple:

[ActionName("SomeTestAction")]
[ResponseType(typeof(SomeObject))]

public IHttpActionResult SomeTestAction(string id)
{

  SomeObject o = SomeMethod(id);

  if (o == null)
  {
      var message = string.Format("Nothing found for id = {0}", id);
      HttpError err = new HttpError(message);
      return Content(HttpStatusCode.NotFound, err);
  }
  else
  {
      return Content(HttpStatusCode.OK, o);
  }

}

This method can have two different ResponseType -s based on the outcome of a database query for example. Is there a way to specify this behavior in HelpPages of WebAPI, so that the user knows what the error response looks like?

astralmaster
  • 2,344
  • 11
  • 50
  • 84

1 Answers1

0

As stated here and for my experience I don't think it is possible because the generated docs are static.

You have to choose whether you want to return an anonymous object (multiple types resolved in run-time) or to explicit have a return type and to favor the documentation details.

Nandolcs
  • 393
  • 4
  • 11