【发布时间】:2018-04-27 11:09:46
【问题描述】:
我有 asp.net core web api。我的一个控制器返回 CreatedAtRouteResult。如何为此方法添加 swagger 属性。
[HttpPost]
[SwaggerResponse(400, typeof(NotFoundResult))]
[SwaggerResponse(201, typeof(CreatedAtRouteResult))]
public async Task<IActionResult> Create([FromBody] SubscriptionDTO dto)
{
var issuedTo = (await _tokenService.Get()).IssuedTo;
SubscriptionDresult = await _subscriptionService.CreateAsync(dto, issuedTo.Id);
return result == null ? (IActionResult)NotFound(): CreatedAtRoute(new {id = result.Id}, result);
}
谁能解释一下如何设置这种类型的 swagger 响应属性?
【问题讨论】:
标签: asp.net-core attributes swagger asp.net-core-webapi