.Net Core 3.1 删除 Swagger UI 上的架构 [英] .Net Core 3.1 Remove Schema on Swagger UI

查看:17
本文介绍了.Net Core 3.1 删除 Swagger UI 上的架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 .Net 3.1 Web Api,我想删除这部分架构";在 Swagger 用户界面上.
怎么做?

I have .Net 3.1 Web Api, I would like to remove this sections "Schemas" on Swagger UI.
How to do it?

推荐答案

不需要模式过滤器.经过几天的努力,我发现:

No need for a schema filter. After busting on it for days I have found out:

所有需要做的都在

app.UseSwaggerUI(options =>
{
    options.DefaultModelsExpandDepth(-1);
});

注意:它是 DefaultModels(复数)而不是 DefaultModel(单数).区别在于 DefaultModels 是模型示例部分的模型的默认扩展深度,而 DefaultModels 是模型的扩展深度.

Note: It is DefaultModels (plural) not DefaultModel (singular). Difference is DefaultModels is the default expansion depth for the model on the model-example section, whereas DefaultModels is the expansion depth for models.

这篇关于.Net Core 3.1 删除 Swagger UI 上的架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆