Closed fairking closed 5 years ago
A new swagger expansion?
I think guys I found a solution. I switched back to enums, so they are generated by codegen. Feel free to close the issue.
[ApiController]
public class UserService : ControllerBase
{
[Route("api/update_user")]
[Permissions(CorePermissions.users_manage, DemoPermissions.users_demo)]
public class UpdateUserService
{
// Code
}
}
public class PermissionsAttribute : Attribute
{
public PermissionsAttribute(params object[] perms)
{
Perms = perms;
}
public object[] Perms { get; set; }
}
// Generated in typescript by swagger-axios-codegen
[Swagger]
public enum CorePermissions
{
users_view,
users_manage,
}
// Generated in typescript by swagger-axios-codegen
[Swagger]
public enum DemoPermissions
{
companies_demo,
users_demo,
}
Hi guys,
Is the any way to tell codegen to generate constants?
My class looks like:
Currently codegen generates the following ts:
I use those constants as permissions. The reason I use
const
instead ofenum
is to be able to pass them into the attributes and because I will have many permission classes (cannon have many enums against one property):In the same time I would like to use those constants in vuejs:
I assume constants can be generated as static properties or as enums in typescript. The tricky thing is to pass the value instead of the property name. In my situation it wont be a case: