diff --git a/Directory.Build.props b/Directory.Build.props index cd3fd33..975f9b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 1.0.5.35 + 1.0.5.36 9.1.1 diff --git a/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.Configure.cs b/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.Configure.cs index b3b98fb..66ebb8a 100644 --- a/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.Configure.cs +++ b/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.Configure.cs @@ -159,18 +159,22 @@ public partial class IoTHttpApiHostModule var configuration = context.Services.GetConfiguration(); var groupNames = EnumExtensions.GetEnumTypeValueNameList(); + var excludeSwaggerGroups = configuration.GetSection("ExcludeSwaggerGroup").Get>() ?? new List(); groupNames.ForEach(group => { - options.SwaggerDoc(group.Key, - new OpenApiInfo { Title = group.Value, Version = "v1"}); + if (!excludeSwaggerGroups.Where(e => e == group.Key).Any()) + { + options.SwaggerDoc(group.Key, + new OpenApiInfo { Title = group.Value, Version = "v1" }); + } }); options.DocInclusionPredicate((docName, description) => { return description.GroupName == docName; }); - options.EnableAnnotations(); // 启用注解 + //options.EnableAnnotations(); // 启用注解 options.DocumentFilter(); options.SchemaFilter(); // 加载所有xml注释,这里会导致swagger加载有点缓慢 diff --git a/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.cs b/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.cs index 0a81fc9..50db6fd 100644 --- a/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.cs +++ b/host/JiShe.IoT.HttpApi.Host/IoTHttpApiHostModule.cs @@ -73,11 +73,15 @@ namespace JiShe.IoT app.UseAbpSwaggerUI(options => { var groupNames = EnumExtensions.GetEnumTypeValueNameList(); - + var excludeSwaggerGroups = configuration.GetSection("ExcludeSwaggerGroup").Get>() ?? new List(); groupNames.ForEach(attr => { - options.SwaggerEndpoint($"/swagger/{attr.Key}/swagger.json", attr.Value); + if (!excludeSwaggerGroups.Where(e => e == attr.Key).Any()) + { + options.SwaggerEndpoint($"/swagger/{attr.Key}/swagger.json", attr.Value); + } }); + //options.SwaggerEndpoint("/swagger/AbpPro/swagger.json", "AbpPro API"); options.DocExpansion(DocExpansion.None); diff --git a/host/JiShe.IoT.HttpApi.Host/appsettings.json b/host/JiShe.IoT.HttpApi.Host/appsettings.json index f8bb961..97c3f7f 100644 --- a/host/JiShe.IoT.HttpApi.Host/appsettings.json +++ b/host/JiShe.IoT.HttpApi.Host/appsettings.json @@ -32,5 +32,11 @@ "App": { "SelfUrl": "http://localhost:44315", "CorsOrigins": "https://*.IoT.com,http://localhost:4200,http://localhost:3100" - } + }, + "ExcludeSwaggerGroup": [ + "FileManagement", + "NotificationManagement", + "CodeManagement", + "TemplateManagement" + ] // 排除Swagger分组 } \ No newline at end of file