【发布时间】:2020-02-14 09:50:49
【问题描述】:
根据我对Swagger Specification 的理解,可以将参数标记为过时:
不推荐使用的参数
使用
deprecated: true将参数标记为已弃用。- in: query name: format required: true schema: type: string enum: [json, xml, yaml] deprecated: true description: Deprecated, use the appropriate `Accept` header instead.```
如何让 Swashbuckle 为参数生成此参数?
为什么?
我有一个类似于以下的控制器方法:
[HttpGet]
public async Task<IActionResult> Execute(bool? someName)
{
}
我想更改查询字符串参数名称,同时暂时保持向后兼容,所以 我想做类似的事情:
[HttpGet]
public async Task<IActionResult> Execute([Obsolete("Use someNewName instead.")] bool? someName, bool? someNewName)
{
someNewName = someNewName ?? someName;
}
但是,Obsolete 不能应用于参数。我预计Swashbuckle.AspNetCore.Annotations 可能是一个可以找到这种功能的地方,但它似乎没有。
【问题讨论】:
-
您是否尝试将方法标记为过时,而不是参数?
标签: c# swashbuckle webapi