嗨,我有如下所示的web api实现。我们在一个方法上使用多个路由。
[SwaggerOperation("Update Records By Id")]
[Route("/construction/field-record")]
[Route("/construction/fieldRecord")]
public async Task<IActionResult> UpdateRecord([FromBody] UpdateRecordRequest request)
两个问题,
如何将两个路由中只有一个标记为已弃用?
如何在sawagger ui上更新指示路由已“弃用”的swagger?
-谢谢
最佳答案
作为解决办法,你可以这样做
[SwaggerOperation("Update Records By Id")]
[Route("/construction/field-record")]
public async Task<IActionResult> UpdateRecord([FromBody] UpdateRecordRequest request)
{
// code
}
[SwaggerOperation("Update Records By Id (Deprecated. Use '/construction/field-record')")]
[Route("/construction/fieldRecord")]
[Obsolete("Deprecated. Use 'UpdateRecord'")]
public async Task<IActionResult> UpdateRecordDeprecated([FromBody] UpdateRecordRequest request)
{
return UpdateRecord(request);
}