http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pagesの記事を読みましたが、問題なく動作します。しかし、これらの応答が送信されるときに、考えられるすべての応答と条件を追加したいと思います。各WebAPIメソッドを分析し、応答のあるすべての場所を見つけ、なぜそれが発生し、それに関するドキュメントを自動的に作成するツールはありますか?
つまり、次のコードがあります。
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 } });
}
}
メソッドが返すことを説明するドキュメントが必要です。
- StatusCode = 200 およびメソッドが正常に完了し、要素が見つかった場合の要素のリスト
- StatusCode = 204 メソッドが正常に完了し、要素が見つからない場合
- 場所が見つからない場合は StatusCode = 400 (編集リクエストを取得するための条件)、メッセージと CustomStatusCode を含む詳細な応答