I have read an article http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages and it works fine. But I would prefer to add all possible responses and conditions, when these responses will be sent. Any tool to analyze each WebAPI method, found all places with responses, why it can be happened and create a documentation about it automatically?
I.e. I have the following code:
public HttpResponseMessage GetEditorialRequests()
{
SetUser();
try
{
var r_list = _service.RequestList(user.Id);
if (r_list.Count > 0)
{
var list = mapper.Map<List<SmartphonePhotographerRequestElementApiModel>>(r_list);
return Request.CreateResponse<List<SmartphonePhotographerRequestElementApiModel>>(HttpStatusCode.OK, list);
}
else
return Request.CreateResponse(HttpStatusCode.NoContent);
}
catch (PixlocateBusinessLogic.NoSmartphonePhotographerLocationException)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, new HttpError("User does not have any locations") { { "CustomStatusCode", 466 } });
}
}
I would like to have documentation, which describes that method returns:
- StatusCode = 200 and list of elements when method is completed successfully and elements are found
- StatusCode = 204 when method is completed successfully and no elements found
- StatusCode = 400 when location is not found (condition for getting editorial requests) and detail response with message and CustomStatusCode