How to document OData endpoints (swagger, swashbuckle, other)?


Solution 1

Yes, try Swashbuckle.OData. It adds Swashbuckle support for ODataControllers.

See it in action here:

Solution 2

Yes, we are trying to support it like yaml -> Swagger, yaml -> csdl ..

But it will need time to implementation, you can see a prototype and track there

Solution 3

I actually got something working for this using the IDocumentFilter function within Swashbuckle. I answered a similar question on the GitHub repo for Swashbuckle. Check out my response here (it's either at bottom or toward bottom):

I've posted an example of a working IDocumentFilter implementation that you could leverage to get your OData endpoint set up in the Swagger ui.

Solution 4

The easiest way to do that I found is to convert OData definition to Open API spec using

Then import the spec document into swagger is very easy.

Solution 5

Asp NET and Asp NET Core Api Versioning

You can use Api Versioning (as it extends ApiExplorer with Odata information) for both WebApi and AspNetCore.

There are samples available for both:

This sample how it integrates well with Swashbuckle/Swagger ui.


Related videos on Youtube

Author by


Updated on September 24, 2022


  • free4ride
    free4ride 2 months

    What is the best way of documenting OData endpoints? Is there a way to use Swashbuckle for it?

  • hyankov
    hyankov over 3 years
    Site is down, unfortunately
  • andrewmo
    andrewmo over 3 years
    Swashbuckle.OData no longer works with the latest version of Microsoft.Odata.Core. Apparently Microsoft changed the dependencies in Microsoft.AspNet.OData from System.Web.OData and Swashbuckle.OData hasn't been updated to use the latest OData packages.