我有一个需要使用最小API的实现。但不知何故,没有办法将其从swagger API资源管理器中排除。在MVC控制器方法中,我们可以使用[ApiExplorerSettings(IgnoreApi=true)]
隐藏端点,但这不是最小API的情况。
代码:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("api/v1/endpoint_a", () => { ... });
// Hide this from Swagger API explorer
app.MapGet("api/v1/endpoint_b", () => { ... });
字符串
将属性放在终结点中是有效的,但它不起作用。
代码:
app.MapGet("api/v1/endpoint_b", [ApiExplorerSettings(IgnoreApi=true)]() => { ... });
型
你知道我错过了什么吗?
2条答案
按热度按时间qxsslcnc1#
试试这个:
在你的端点后添加
ExcludeFromDescription()
方法,它对我很有效。字符串
jm2pwxwz2#
您可以使用IActionModelConvention来隐藏端点。阅读有关dev.to的文章。