Forum Discussion

SteveCollins's avatar
SteveCollins
New Contributor
4 years ago

How to add custom properties to Path from OperationFilter?

Hi there, I've been tasked with updating and extending the swagger.json file produced by C# .NET Core API.  The specification calls to add information from a Controller Attribute called a "TypeFilter" (which is an MVC object (I'm learning it's purpose yet)) to the swagger.json file.  I need to add the Name property of the TypeFilter to Path information so that it shows up in swagger.json.

 

I've been able to identify the TypeFilter object in an OperationFilter but then I'm stuck.  It's not clear from the documentation or Google how to assign a property to the Path. 

 

This is my code

 

 

This my code when it hits a Breakpoint when TryCast to the TypeFilter type is success:

 

 

The TypeFilter Name is "JsonResourceResultsHandler".  This information is to be extended to the Path for the Controller.  Maybe it could be called "x-TypeFilter"

 

The API is .NET Core 3.1

 

The Swashbuckle versions from .csproj:

<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.4.1" />

 

Please any help would be greatly appreciated.  Thank you

No RepliesBe the first to reply