Files
simapi-net/Configurations/SimApiDocOptions.cs
T

70 lines
1.7 KiB
C#
Raw Normal View History

2024-03-23 07:29:43 +08:00
using System.Collections.Generic;
using Swashbuckle.AspNetCore.SwaggerUI;
2024-04-16 06:57:56 +08:00
namespace SimApi.Configurations;
2024-03-23 07:29:43 +08:00
/// <summary>
/// 文档组配置
/// </summary>
2025-11-01 18:40:51 +08:00
public class SimApiDocGroupOption(string id, string name, string description = "")
2024-03-23 07:29:43 +08:00
{
/// <summary>
/// 文档标识
/// </summary>
2025-11-01 18:40:51 +08:00
public string Id { get; set; } = id;
2024-03-23 07:29:43 +08:00
/// <summary>
/// 文档名称
/// </summary>
2025-11-01 18:40:51 +08:00
public string Name { get; set; } = name;
2024-03-23 07:29:43 +08:00
/// <summary>
/// 文档描述
/// </summary>
2025-11-01 18:40:51 +08:00
public string Description { get; set; } = description!;
2024-03-23 07:29:43 +08:00
}
/// <summary>
/// 授权配置, Type支持 "SimApiAuth","ClientCredentials","Implicit","AuthorizationCode"
/// </summary>
public class SimApiAuthOption
{
2025-11-01 18:40:51 +08:00
public string[] Type { get; set; } = ["SimApiAuth"];
2024-03-23 07:29:43 +08:00
public string Description { get; set; } = "认证服务器颁发的AccessToken";
2024-08-03 19:19:42 +08:00
public string AuthorizationUrl { get; set; } = null!;
2024-03-23 07:29:43 +08:00
2024-08-03 19:19:42 +08:00
public string TokenUrl { get; set; } = null!;
2024-03-23 07:29:43 +08:00
2024-08-03 19:19:42 +08:00
public Dictionary<string, string> Scopes { get; set; } = null!;
2024-03-23 07:29:43 +08:00
}
/// <summary>
/// 文档配置
/// </summary>
public class SimApiDocOptions
{
/// <summary>
/// 文档组配置
/// </summary>
2025-11-01 18:40:51 +08:00
public SimApiDocGroupOption[] ApiGroups { get; set; } =
[
new("api", "Api", "Api接口文档")
];
2024-03-23 07:29:43 +08:00
/// <summary>
/// 授权配置
/// </summary>
2025-11-01 18:40:51 +08:00
public SimApiAuthOption ApiAuth { get; set; } = new();
2024-03-23 07:29:43 +08:00
/// <summary>
/// 文档页面标题
/// </summary>
public string DocumentTitle { get; set; } = "API接口文档";
/// <summary>
/// 接口支持的调用方式
/// </summary>
2025-11-01 18:40:51 +08:00
public SubmitMethod[] SupportedMethod { get; set; } = [SubmitMethod.Post];
}