c# – Swashbuckle – 回复回复的文字文件?
作者:互联网
Swashbuckle不会生成带有“UserCreateResponse”输出的swagger.json,你如何解决这个问题?
[HttpPost]
public async Task<IActionResult> Update([FromBody]UserCreate Request)
{
UserCreateResponse response = new UserCreateResponse();
//do something here
// returns UserCreateResponse with http status code 200
return Ok(response);
}
你不能这样做,因为它不会返回http状态代码,200,400,401等
[HttpPost]
public async Task<UserCreateResponse> Update([FromBody]UserCreate Request)
{
UserCreateResponse response = new UserCreateResponse();
//do something here
// returns UserCreateResponse
return response;
}
解决方法:
您可以使用以下属性指定响应类型:
[ProducesResponseType(typeof(UserCreateResponse), 200)]
标签:c,rest,asp-net-core,swagger,swashbuckle 来源: https://codeday.me/bug/20190717/1486859.html