Home > OS >  How to hide OData Metadata Controller in Swagger?
How to hide OData Metadata Controller in Swagger?

Time:12-28

After updating my project to .NET6 and OData to 8.0.4, a new Metadata controller with these endpoints appeared:

enter image description here

I want to disable it somehow or remove it from my service.

Code for adding OData service:

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services
        .AddControllers(mvcOptions => mvcOptions.EnableEndpointRouting = false)
        .AddOData(opt => opt.AddRouteComponents("", GetEdmModel()).Select().Expand());
}

Versions:

  • .NET6
  • ASP.NET Core 6
  • OData 8.0.4

CodePudding user response:

There are several options to solve this:

  1. You can use enter image description here

  • Related