Home > Enterprise >  Where is the GetCustomAttributes method of the ActionDescriptor with Swashbuckle in asp.net core 6.0
Where is the GetCustomAttributes method of the ActionDescriptor with Swashbuckle in asp.net core 6.0

Time:01-14

Old ASP.NET Web API 2:

apiDescription.ActionDescriptor.GetCustomAttributes<MyCustomAttribute>();

apiDescription is a parameter from the interface IOperationFilter method

public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)

ASP.NET Core 6 Web API (does not work):

public void Apply(OpenApiOperation operation, OperationFilterContext context)
    

context.ApiDescription.GetCustomAttributes<MyCustomAttribute>());

Where did they hide the GetCustomAttributes method?

CodePudding user response:

Try using OperationFilterContext.MethodInfo:

context.MethodInfo.GetCustomAttributes<MyCustomAttribute>();
  • Related