# How to add OData parameters to your ASP.Net Core API

My team and I have worked with the [OData nuget package from Microsoft](https://www.nuget.org/packages/Microsoft.AspNetCore.OData/) to add some OData magic to a normal REST API based on ASP.Net Core 3.1 (that setup is a blog post for another day 😅).

But along the way we found, that there were no out-of-the box solution to get the OData parameters visible in our normal OpenApi spec (generated by  [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) ).

So today I learned (#TIL) that its quite easy to inject some custom properties into the OpenAPI model trough a IOperationFilter.

%[https://gist.github.com/jacobmohl/a7eb2f3b508b61a2bd04ef0fe6d6e1de]

To utilize the above code, you have to add the following to the AddSwaggerGen builder (in Startup.cs or similar).
```
services.AddSwaggerGen(c =>
{
...
    // Add support for OData-like REST endpoint with [EnableQuery]
    c.OperationFilter<ODataOperationFilter>();
...
});
``` 

This enables all the OData parameters on the API methods which have the [EnableQuery] attribute.

