2017-01-28 6 views
5

応答メッセージモデルには原始的ではありません。オブジェクトは、私がアクションを飾っ

しかし、Repsonseメッセージの下では、NotFoundの場合、「オブジェクトはプリミティブではありません」というメッセージが表示されます。カスタム例外はExceptionから派生し、ISerializableを実装し、[Serializable][DataContract()]

メッセージの代わりに実際のデータタイプを表示するにはどうすればよいですか?

また、このような属性を持つすべてのアクションを飾ると、通常WebApiを使用するとパフォーマンスが低下しますか?

答えて

-1

どのようなものについて:

[SwaggerResponse(HttpStatusCode.OK, "List of customers", typeof(IEnumerable<int>))] 
    [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(BadRequestErrorMessageResult))] 
    [SwaggerResponse(HttpStatusCode.NotFound, Type = typeof(NotFoundResult))] 
    public IHttpActionResult GetById(int id) 
    { 
     if (id > 0) 
      return Ok(new int[] { 1, 2 }); 
     else if (id == 0) 
      return NotFound(); 
     else 
      return BadRequest("id must be greater than 0"); 
    } 

http://swashbuckletest.azurewebsites.net/swagger/ui/index#!/IHttpActionResult/IHttpActionResult_GetById

関連する問題