从SwaggerUI删除OData查询

时间:2019-05-15 20:07:02

标签: c# asp.net-web-api swagger swagger-ui swashbuckle

我不想在swagger ui中显示ODataQueryOptions,如何删除它?

我已经尝试为此创建一个新的OperationFilter,但是没有得到任何结果...

public class RemoverODataQueriesOperationFilter : IOperationFilter
{
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
    {
        foreach (var item in apiDescription.ParameterDescriptions)
        {
            var odataQuery = operation.parameters.SingleOrDefault(x => x.name == item.Name);

            if (odataQuery != null)
                operation.parameters.Remove(odataQuery);
        }
    }
}

0 个答案:

没有答案