0条评论
还没有人评论过~
参数是一个对象,想隐藏某个属性不再swaager里面显示,该怎么实现?
如下面这个类,我想隐藏Paging这个属性,在接口文档里面不显示该属性,
public class QueryModel
{
/// <summary>
/// 分页信息
/// </summary>
public QueryPagingModel Page { get; set; } = new QueryPagingModel();
/// <summary>
/// 转换为Paging对象
/// </summary>
/// <returns></returns>
public Paging Paging
{
get
{
if (Page == null)
return null;
var paging = new Paging(Page.Index, Page.Size);
if (Page.Sort != null && Page.Sort.Any())
{
foreach (var sort in Page.Sort)
{
paging.OrderBy.Add(new Sort(sort.Field, sort.Type));
}
}
return paging;
}
}
实现Swagger 的 IOperationFilter 接口, 然后添加到 OperationFilter 里面就行了
参考 How to configure Swashbuckle to ignore property on model