Home > Software design >  Removing OData schema from swagger. Asp.net Core Web Api 5.0
Removing OData schema from swagger. Asp.net Core Web Api 5.0

Time:12-03

How can I remove extra scheme objects that are being generated by OData from swagger asp.net core web api 5.0

CodePudding user response:

I ran into the same situation and built the functionality into a framework I wrote. The answer is that you need to create an IDocumentFilter. Here's a sample based on .net 6:

https://github.com/ikemtz/NRSRx/blob/master/src/IkeMtz.NRSRx.Core.OData/ODataCommonDocumentFilter.cs

In your startup.cs do the following:

   .AddSwaggerGen(swaggerGenOptions =>
        {
          swaggerGenOptions.DocumentFilter<ODataCommonDocumentFilter>();
        });
  • Related