简体   繁体   中英

Where is the GetCustomAttributes method of the ActionDescriptor with Swashbuckle in asp.net core 6.0?

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?

Try using OperationFilterContext.MethodInfo :

context.MethodInfo.GetCustomAttributes<MyCustomAttribute>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM