-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I searched for issues related to this topic but could not find any discussion with the keywords I used. Hence I open this new discussion.
Description
More and more ASP.net core APIs tend to be async only and do not provide sync overloads anymore. The filters in Swashbuckle like the IOperationFilter
are sync which makes it hard to call over to certian ASP.net core APIs to obtain data you might need for generating the Swagger document you want to have.
It would be great if Swashbuckle could provide async variants for all filters so we can await calls over to the ASP.net core infrastructure.
Concrete use case/example:
We want to extend our API documentation with RBAC information. To load certain aspects of the authorization rules defined in the API APIs like the IAuthorizationPolicyProvider
need to be used. Here an example how ASP.net core is building the overall policy for an endpoint in the related AuthorizationMiddleware:
The same code cannot be placed inside an IOperationFilter to build the policy for an endpoint because only async overloads exist.
Current Workaround
Use some mechanisms like described here to call async code from sync code.