diff --git a/WGShare.API/Controllers/AuthController.cs b/WGShare.API/Controllers/AuthController.cs
index cf10d26..147ff70 100644
--- a/WGShare.API/Controllers/AuthController.cs
+++ b/WGShare.API/Controllers/AuthController.cs
@@ -12,6 +12,7 @@ using WGShare.Domain.FriendlyException;
namespace WGShare.API.Controllers
{
+ [ApiExplorerSettings(GroupName = "public")]
[Route("auth")]
public class AuthController : BasicController
{
diff --git a/WGShare.API/Controllers/Backend/PremController.cs b/WGShare.API/Controllers/Backend/PremController.cs
index 55cea1d..ceec4a1 100644
--- a/WGShare.API/Controllers/Backend/PremController.cs
+++ b/WGShare.API/Controllers/Backend/PremController.cs
@@ -11,6 +11,7 @@ using Yitter.IdGenerator;
namespace WGShare.API.Controllers.Backend
{
+ [ApiExplorerSettings(GroupName = "backend")]
[Route("be/perm")]
public class PremController : BasicController
{
diff --git a/WGShare.API/Controllers/Backend/RoleController.cs b/WGShare.API/Controllers/Backend/RoleController.cs
index 24eea8a..cdaf972 100644
--- a/WGShare.API/Controllers/Backend/RoleController.cs
+++ b/WGShare.API/Controllers/Backend/RoleController.cs
@@ -8,6 +8,7 @@ using Yitter.IdGenerator;
namespace WGShare.API.Controllers.Backend
{
+ [ApiExplorerSettings(GroupName = "backend")]
[Route("be/role")]
public class RoleController : BasicController
{
diff --git a/WGShare.API/Controllers/Backend/TenantController.cs b/WGShare.API/Controllers/Backend/TenantController.cs
index d70dcd4..71638e6 100644
--- a/WGShare.API/Controllers/Backend/TenantController.cs
+++ b/WGShare.API/Controllers/Backend/TenantController.cs
@@ -11,6 +11,7 @@ using Yitter.IdGenerator;
namespace WGShare.API.Controllers.Backend
{
+ [ApiExplorerSettings(GroupName = "backend")]
[Route("be/tenant")]
public class TenantController : BasicController
{
diff --git a/WGShare.API/Controllers/Backend/UserController.cs b/WGShare.API/Controllers/Backend/UserController.cs
index 60a12ad..ed62b55 100644
--- a/WGShare.API/Controllers/Backend/UserController.cs
+++ b/WGShare.API/Controllers/Backend/UserController.cs
@@ -11,6 +11,7 @@ using Yitter.IdGenerator;
namespace WGShare.API.Controllers.Backend
{
+ [ApiExplorerSettings(GroupName = "backend")]
[Route("be/user")]
public class UserController : BasicController
{
diff --git a/WGShare.API/Controllers/Frontend/HomeController.cs b/WGShare.API/Controllers/Frontend/HomeController.cs
index 7078f5b..0dac080 100644
--- a/WGShare.API/Controllers/Frontend/HomeController.cs
+++ b/WGShare.API/Controllers/Frontend/HomeController.cs
@@ -13,6 +13,7 @@ namespace WGShare.API.Controllers.Frontend
///
/// 首页接口
///
+ [ApiExplorerSettings(GroupName = "frontend")]
[Route("home")]
public class HomeController : BasicController
{
diff --git a/WGShare.API/Controllers/Frontend/RoomController.cs b/WGShare.API/Controllers/Frontend/RoomController.cs
index 19d9116..0767730 100644
--- a/WGShare.API/Controllers/Frontend/RoomController.cs
+++ b/WGShare.API/Controllers/Frontend/RoomController.cs
@@ -19,6 +19,7 @@ namespace WGShare.API.Controllers.Frontend
///
/// 会议室接口
///
+ [ApiExplorerSettings(GroupName = "frontend")]
[Route("room")]
public class RoomController : BasicController
{
diff --git a/WGShare.API/Program.cs b/WGShare.API/Program.cs
index eca2d6a..39f714f 100644
--- a/WGShare.API/Program.cs
+++ b/WGShare.API/Program.cs
@@ -1,3 +1,4 @@
+using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
@@ -36,7 +37,40 @@ namespace WGShare.API
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
- builder.Services.AddSwaggerGen();
+ builder.Services.AddSwaggerGen(w =>
+ {
+ w.SwaggerDoc("frontend", new OpenApiInfo { Title = "ǰ", Version = "frontend" });
+ w.SwaggerDoc("backend", new OpenApiInfo { Title = "", Version = "backend" });
+ w.SwaggerDoc("public", new OpenApiInfo { Title = "ӿ", Version = "public" });
+ w.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
+ {
+ Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
+ Name = "Authorization",
+ In = ParameterLocation.Header,
+ Type = SecuritySchemeType.ApiKey,
+ Scheme = "Bearer"
+ });
+
+ w.AddSecurityRequirement(new OpenApiSecurityRequirement
+ {
+ {
+ new OpenApiSecurityScheme
+ {
+ Reference = new OpenApiReference
+ {
+ Type = ReferenceType.SecurityScheme,
+ Id = "Bearer"
+ }
+ },
+ new string[] {}
+ }
+ });
+
+ //string xmlPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SwaggerGroup.xml");
+ //w.IncludeXmlComments(xmlPath, true);
+ }
+ );
+
builder.Services.AddSingleton(new JwtHelper(configuration));
builder.Services.AddAuth(configuration["Jwt:Issuer"],
configuration["Jwt:Audience"],
@@ -64,7 +98,13 @@ namespace WGShare.API
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
- app.UseSwaggerUI();
+ app.UseSwaggerUI(options =>
+ {
+ options.SwaggerEndpoint($"/swagger/frontend/swagger.json", "ǰ");
+ options.SwaggerEndpoint($"/swagger/backend/swagger.json", "");
+ options.SwaggerEndpoint($"/swagger/public/swagger.json", "ӿ");
+
+ });
app.UseCustomCors();
}