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>();