mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 23:13:40 +08:00
进一步优化swagger分组
This commit is contained in:
parent
804ee3d9d8
commit
a84c8c57ad
@ -13,7 +13,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "AccessObjs")]
|
[ApiExplorerSettings(GroupName = "分配资源_AccessObjs")]
|
||||||
public class AccessObjsController : ControllerBase
|
public class AccessObjsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly RevelanceManagerApp _app;
|
private readonly RevelanceManagerApp _app;
|
||||||
|
@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Applications")]
|
[ApiExplorerSettings(GroupName = "应用管理_Applications")]
|
||||||
public class ApplicationsController : ControllerBase
|
public class ApplicationsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly AppManager _app;
|
private readonly AppManager _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "BuilderTableColumns")]
|
[ApiExplorerSettings(GroupName = "代码生成器_字段_BuilderTableColumns")]
|
||||||
public class BuilderTableColumnsController : ControllerBase
|
public class BuilderTableColumnsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly BuilderTableColumnApp _app;
|
private readonly BuilderTableColumnApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "BuilderTables")]
|
[ApiExplorerSettings(GroupName = "代码生成器_表_BuilderTables")]
|
||||||
public class BuilderTablesController : ControllerBase
|
public class BuilderTablesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly BuilderTableApp _app;
|
private readonly BuilderTableApp _app;
|
||||||
|
@ -13,7 +13,7 @@ using OpenAuth.App.Response;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "CategoryTypes")]
|
[ApiExplorerSettings(GroupName = "字典所属分类_CategoryTypes")]
|
||||||
public class CategoryTypesController : ControllerBase
|
public class CategoryTypesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly CategoryTypeApp _app;
|
private readonly CategoryTypeApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Categorys")]
|
[ApiExplorerSettings(GroupName = "分类字典_Categorys")]
|
||||||
public class CategorysController : ControllerBase
|
public class CategorysController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly CategoryApp _app;
|
private readonly CategoryApp _app;
|
||||||
|
@ -33,7 +33,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Check")]
|
[ApiExplorerSettings(GroupName = "登录验证_Check")]
|
||||||
public class CheckController : ControllerBase
|
public class CheckController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IAuth _authUtil;
|
private readonly IAuth _authUtil;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "DataPrivilegeRules")]
|
[ApiExplorerSettings(GroupName = "数据权限_DataPrivilegeRules")]
|
||||||
public class DataPrivilegeRulesController : ControllerBase
|
public class DataPrivilegeRulesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly DataPrivilegeRuleApp _app;
|
private readonly DataPrivilegeRuleApp _app;
|
||||||
|
@ -18,7 +18,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
|
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Files")]
|
[ApiExplorerSettings(GroupName = "文件管理_Files")]
|
||||||
public class FilesController :ControllerBase
|
public class FilesController :ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "FlowInstances")]
|
[ApiExplorerSettings(GroupName = "流程实例_FlowInstances")]
|
||||||
public class FlowInstancesController : ControllerBase
|
public class FlowInstancesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly FlowInstanceApp _app;
|
private readonly FlowInstanceApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "FlowSchemes")]
|
[ApiExplorerSettings(GroupName = "流程模版_FlowSchemes")]
|
||||||
public class FlowSchemesController : ControllerBase
|
public class FlowSchemesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly FlowSchemeApp _app;
|
private readonly FlowSchemeApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Forms")]
|
[ApiExplorerSettings(GroupName = "表单_Forms")]
|
||||||
public class FormsController : ControllerBase
|
public class FormsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly FormApp _app;
|
private readonly FormApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Modules")]
|
[ApiExplorerSettings(GroupName = "模块菜单_Modules")]
|
||||||
public class ModulesController : ControllerBase
|
public class ModulesController : ControllerBase
|
||||||
{
|
{
|
||||||
private ModuleManagerApp _app;
|
private ModuleManagerApp _app;
|
||||||
|
@ -16,7 +16,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "OpenJobs")]
|
[ApiExplorerSettings(GroupName = "定时任务_OpenJobs")]
|
||||||
public class OpenJobsController : ControllerBase
|
public class OpenJobsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly OpenJobApp _app;
|
private readonly OpenJobApp _app;
|
||||||
|
@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Orgs")]
|
[ApiExplorerSettings(GroupName = "组织机构_Orgs")]
|
||||||
public class OrgsController : ControllerBase
|
public class OrgsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly OrgManagerApp _app;
|
private readonly OrgManagerApp _app;
|
||||||
|
@ -17,7 +17,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Resources")]
|
[ApiExplorerSettings(GroupName = "资源管理_Resources")]
|
||||||
public class ResourcesController : ControllerBase
|
public class ResourcesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ResourceApp _app;
|
private readonly ResourceApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Roles")]
|
[ApiExplorerSettings(GroupName = "角色管理_Roles")]
|
||||||
public class RolesController : ControllerBase
|
public class RolesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly RoleApp _app;
|
private readonly RoleApp _app;
|
||||||
|
@ -11,7 +11,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "SysConf")]
|
[ApiExplorerSettings(GroupName = "系统配置_SysConf")]
|
||||||
public class SysConfController :ControllerBase
|
public class SysConfController :ControllerBase
|
||||||
{
|
{
|
||||||
private IOptions<AppSetting> _appConfiguration;
|
private IOptions<AppSetting> _appConfiguration;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "SysLogs")]
|
[ApiExplorerSettings(GroupName = "系统日志_SysLogs")]
|
||||||
public class SysLogsController : ControllerBase
|
public class SysLogsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly SysLogApp _app;
|
private readonly SysLogApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "SysMessages")]
|
[ApiExplorerSettings(GroupName = "消息中心_SysMessages")]
|
||||||
public class SysMessagesController : ControllerBase
|
public class SysMessagesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly SysMessageApp _app;
|
private readonly SysMessageApp _app;
|
||||||
|
@ -13,7 +13,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "Users")]
|
[ApiExplorerSettings(GroupName = "用户管理_Users")]
|
||||||
public class UsersController : ControllerBase
|
public class UsersController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly UserManagerApp _app;
|
private readonly UserManagerApp _app;
|
||||||
|
@ -15,7 +15,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "WmsInboundOrderDtbls")]
|
[ApiExplorerSettings(GroupName = "订单明细_WmsInboundOrderDtbls")]
|
||||||
public class WmsInboundOrderDtblsController : ControllerBase
|
public class WmsInboundOrderDtblsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly WmsInboundOrderDtblApp _app;
|
private readonly WmsInboundOrderDtblApp _app;
|
||||||
|
@ -14,7 +14,7 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiExplorerSettings(GroupName = "WmsInboundOrderTbls")]
|
[ApiExplorerSettings(GroupName = "订单_WmsInboundOrderTbls")]
|
||||||
public class WmsInboundOrderTblsController : ControllerBase
|
public class WmsInboundOrderTblsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly WmsInboundOrderTblApp _app;
|
private readonly WmsInboundOrderTblApp _app;
|
||||||
|
@ -42,10 +42,7 @@ namespace OpenAuth.WebApi
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
//在startup中需要强制创建log4net
|
//在startup中需要强制创建log4net
|
||||||
var loggerFactory = LoggerFactory.Create(builder =>
|
var loggerFactory = LoggerFactory.Create(builder => { builder.AddLog4Net(); });
|
||||||
{
|
|
||||||
builder.AddLog4Net();
|
|
||||||
});
|
|
||||||
ILogger logger = loggerFactory.CreateLogger<Startup>();
|
ILogger logger = loggerFactory.CreateLogger<Startup>();
|
||||||
|
|
||||||
var identityServer =
|
var identityServer =
|
||||||
@ -62,6 +59,7 @@ namespace OpenAuth.WebApi
|
|||||||
options.Audience = "openauthapi";
|
options.Audience = "openauthapi";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加MiniProfiler服务
|
// 添加MiniProfiler服务
|
||||||
services.AddMiniProfiler(options =>
|
services.AddMiniProfiler(options =>
|
||||||
{
|
{
|
||||||
@ -81,10 +79,12 @@ namespace OpenAuth.WebApi
|
|||||||
{
|
{
|
||||||
foreach (var controller in GetControllers())
|
foreach (var controller in GetControllers())
|
||||||
{
|
{
|
||||||
option.SwaggerDoc(controller.Name.Replace("Controller", ""), new OpenApiInfo
|
var groupname = GetSwaggerGroupName(controller);
|
||||||
|
|
||||||
|
option.SwaggerDoc(groupname, new OpenApiInfo
|
||||||
{
|
{
|
||||||
Version = "v1",
|
Version = "v1",
|
||||||
Title = controller.Name.Replace("Controller", ""),
|
Title = groupname,
|
||||||
Description = "by yubaolee"
|
Description = "by yubaolee"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -174,21 +174,10 @@ namespace OpenAuth.WebApi
|
|||||||
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Configuration["DataProtection"]));
|
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Configuration["DataProtection"]));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//设置定时启动的任务
|
//设置定时启动的任务
|
||||||
services.AddHostedService<QuartzService>();
|
services.AddHostedService<QuartzService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Type> GetControllers()
|
|
||||||
{
|
|
||||||
Assembly asm = Assembly.GetExecutingAssembly();
|
|
||||||
|
|
||||||
var controlleractionlist = asm.GetTypes()
|
|
||||||
.Where(type => typeof(ControllerBase).IsAssignableFrom(type))
|
|
||||||
.OrderBy(x => x.Name).ToList();
|
|
||||||
return controlleractionlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConfigureContainer(ContainerBuilder builder)
|
public void ConfigureContainer(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
AutofacExt.InitAutofac(builder);
|
AutofacExt.InitAutofac(builder);
|
||||||
@ -235,18 +224,21 @@ namespace OpenAuth.WebApi
|
|||||||
//配置ServiceProvider
|
//配置ServiceProvider
|
||||||
AutofacContainerModule.ConfigServiceProvider(app.ApplicationServices);
|
AutofacContainerModule.ConfigServiceProvider(app.ApplicationServices);
|
||||||
|
|
||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
|
|
||||||
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
|
||||||
// specifying the Swagger JSON endpoint.
|
// specifying the Swagger JSON endpoint.
|
||||||
app.UseSwaggerUI(c =>
|
app.UseSwaggerUI(c =>
|
||||||
{
|
{
|
||||||
c.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("OpenAuth.WebApi.index.html");
|
c.IndexStream = () =>
|
||||||
|
GetType().GetTypeInfo().Assembly.GetManifestResourceStream("OpenAuth.WebApi.index.html");
|
||||||
|
|
||||||
foreach (var controller in GetControllers())
|
foreach (var controller in GetControllers())
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint($"/swagger/{controller.Name.Replace("Controller", "")}/swagger.json",
|
var groupname = GetSwaggerGroupName(controller);
|
||||||
controller.Name.Replace("Controller", ""));
|
|
||||||
|
c.SwaggerEndpoint($"/swagger/{groupname}/swagger.json", groupname);
|
||||||
}
|
}
|
||||||
|
|
||||||
c.DocExpansion(DocExpansion.List); //默认展开列表
|
c.DocExpansion(DocExpansion.List); //默认展开列表
|
||||||
@ -254,5 +246,33 @@ namespace OpenAuth.WebApi
|
|||||||
c.OAuthAppName("开源版webapi认证"); // 描述
|
c.OAuthAppName("开源版webapi认证"); // 描述
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取控制器对应的swagger分组值
|
||||||
|
/// </summary>
|
||||||
|
private string GetSwaggerGroupName(Type controller)
|
||||||
|
{
|
||||||
|
var groupname = controller.Name.Replace("Controller", "");
|
||||||
|
var apisetting = controller.GetCustomAttribute(typeof(ApiExplorerSettingsAttribute));
|
||||||
|
if (apisetting != null)
|
||||||
|
{
|
||||||
|
groupname = ((ApiExplorerSettingsAttribute) apisetting).GroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有的控制器
|
||||||
|
/// </summary>
|
||||||
|
private List<Type> GetControllers()
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
var controlleractionlist = asm.GetTypes()
|
||||||
|
.Where(type => typeof(ControllerBase).IsAssignableFrom(type))
|
||||||
|
.OrderBy(x => x.Name).ToList();
|
||||||
|
return controlleractionlist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user