如何使用 Swashbuckle 从关于 WebAPI 的 Swagger 文档中省略方法

编程入门 行业动态 更新时间:2024-10-24 10:19:32
本文介绍了如何使用 Swashbuckle 从关于 WebAPI 的 Swagger 文档中省略方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 C# ASP.NET WebAPI 应用程序,其中 API 文档是使用 Swashbuckle 自动生成的.我希望能够从文档中省略某些方法,但我似乎无法弄清楚如何告诉 Swagger 不要将它们包含在 Swagger UI 输出中.

I have a C# ASP.NET WebAPI application with API documentation being automatically generated using Swashbuckle. I want to be able to omit certain methods from the documentation but I can't seem to work out how to tell Swagger not to include them in the Swagger UI output.

我觉得这与添加模型或模式过滤器有关,但不清楚该怎么做,文档似乎只提供了如何修改方法输出的示例,而不是将其从输出中完全删除.

I sense it is something to do with adding a model or schema filter but it isn't obvious what to do and the documentation only seems to provide examples of how to modify the output for a method, not remove it completely from the output.

推荐答案

您可以将以下属性添加到 Controllers 和 Actions 以将它们从生成的文档中排除:[ApiExplorerSettings(IgnoreApi = true)]

You can add the following attribute to Controllers and Actions to exclude them from the generated documentation: [ApiExplorerSettings(IgnoreApi = true)]

更多推荐

如何使用 Swashbuckle 从关于 WebAPI 的 Swagger 文档中省略方法

本文发布于:2023-11-03 14:55:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555407.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   文档   方法   WebAPI   Swashbuckle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!