2016-10-26 46 views
3

有什麼方法可以記錄請求所需的權限嗎?如果我有註解像swagger - 註解權限?

[Authenticate] 
[RequiredRole("Admin")] 
[RequiredPermission("CanAccess")] 
public object Delete(DeleteAppUser deleteUserRequest) 
{ 
    // .... 
} 
在我的服務類

或者用於我RequestDTOs

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

我可以做出這樣招搖的UI文檔中莫名其妙地支持我的API的用戶自動或做我有把它寫在註釋中,例如:

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

回答

2

沒有Swaggers UI沒有角色或權限的概念。此信息顯示在ServiceStack的/metadata pages上,但要將其顯示在Swagger的用戶界面中,您需要將其添加到API的文本描述中。