Skip to content

Instantly share code, notes, and snippets.

@rgudkov-uss
rgudkov-uss / ODataOperationFilter.cs
Last active May 11, 2022 10:31
Filter to include odata parameters into Swagger UI (checked on AspNetCore 6.0). This is a modification of @jacobmohl code from https://gist.github.com/jacobmohl/a7eb2f3b508b61a2bd04ef0fe6d6e1de
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
public class ODataOperationFilter : IOperationFilter
{
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
if (operation.Parameters == null) operation.Parameters = new List<OpenApiParameter>();