【问题标题】:Swagger UI hide AspNetCore.Mvc.ProblemDetails schema .net 5 and 6Swagger UI 隐藏 AspNetCore.Mvc.ProblemDetails 架构 .net 5 和 6
【发布时间】:2021-10-12 13:51:10
【问题描述】:

如何在 .net 5 和 .net 6 中隐藏 ProblemDetails Schema(见下文)。

【问题讨论】:

    标签: c# asp.net swagger .net-5


    【解决方案1】:

    解决这个问题的方法是SuppressMapClientErrorsStartup.cs中加上ConfigureApiBehaviorOptions,如下图:

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers().ConfigureApiBehaviorOptions(x => { x.SuppressMapClientErrors = true; });
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 2014-01-25
      • 2014-11-26
      • 1970-01-01
      • 2015-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多