swagger 分组
This commit is contained in:
parent
fb83651055
commit
f1bf00f4b5
|
|
@ -12,6 +12,7 @@ using WGShare.Domain.FriendlyException;
|
|||
|
||||
namespace WGShare.API.Controllers
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "public")]
|
||||
[Route("auth")]
|
||||
public class AuthController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Yitter.IdGenerator;
|
|||
|
||||
namespace WGShare.API.Controllers.Backend
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "backend")]
|
||||
[Route("be/perm")]
|
||||
public class PremController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Yitter.IdGenerator;
|
|||
|
||||
namespace WGShare.API.Controllers.Backend
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "backend")]
|
||||
[Route("be/role")]
|
||||
public class RoleController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Yitter.IdGenerator;
|
|||
|
||||
namespace WGShare.API.Controllers.Backend
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "backend")]
|
||||
[Route("be/tenant")]
|
||||
public class TenantController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Yitter.IdGenerator;
|
|||
|
||||
namespace WGShare.API.Controllers.Backend
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "backend")]
|
||||
[Route("be/user")]
|
||||
public class UserController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace WGShare.API.Controllers.Frontend
|
|||
/// <summary>
|
||||
/// 首页接口
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "frontend")]
|
||||
[Route("home")]
|
||||
public class HomeController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ namespace WGShare.API.Controllers.Frontend
|
|||
/// <summary>
|
||||
/// 会议室接口
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "frontend")]
|
||||
[Route("room")]
|
||||
public class RoomController : BasicController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue