Swagger annotation for permissions?

Is there a way to document the permissions required for a request? If I have annotations like

[Authenticate]
[RequiredRole("Admin")]
[RequiredPermission("CanAccess")]
public object Delete(DeleteAppUser deleteUserRequest)
{
   // ....
}

in my class of service or alternatively for my RequestDTOs

[Authenticate]
[RequiredRole("Admin")]
[Route("/appusers/{AppUserId}", "DELETE", Summary = "Delete an application user identified by its ID.")]
public class DeleteAppUser : IReturn<AppUserDto>
{
    // ....
}

Can I make this somehow accessible in the swagger-ui documentation for users of my API automatically or do I need to write it in Notes, for example:

[Route("/appusers/{AppUserId}", "DELETE", Summary = "Delete an application user identified by its ID.", Notes="Requires an authenticated session and membership in the Admin role.")]
+4
source share
1 answer

No user interfaces Swaggers has no idea about roles or permissions. This information is displayed on the ServiceStack / metadata page , but to display it in the Swagger user interface, you need to add it to the text description of the API.

+2
source

Source: https://habr.com/ru/post/1658975/


All Articles