using System.Collections.Generic; using Swashbuckle.AspNetCore.SwaggerUI; namespace SimApi.Configurations; /// /// 文档组配置 /// public class SimApiDocGroupOption(string id, string name, string description = "", bool isDefault = false) { /// /// 文档标识 /// public string Id { get; set; } = id; /// /// 文档名称 /// public string Name { get; set; } = name; /// /// 文档描述 /// public string Description { get; set; } = description!; /// /// 是否为默认文档组: 未标注分组的接口全部归入此文档组 /// public bool IsDefault { get; set; } = isDefault; } /// /// 授权配置, Type支持 "SimApiAuth","ClientCredentials","Implicit","AuthorizationCode" /// public class SimApiAuthOption { public string[] Type { get; set; } = ["SimApiAuth"]; public string Description { get; set; } = "认证服务器颁发的AccessToken"; public string AuthorizationUrl { get; set; } = null!; public string TokenUrl { get; set; } = null!; public Dictionary Scopes { get; set; } = null!; } /// /// 文档配置 /// public class SimApiDocOptions { /// /// 文档组配置 /// public SimApiDocGroupOption[] ApiGroups { get; set; } = [ new("api", "Api", "Api接口文档", isDefault: true) ]; /// /// 授权配置 /// public SimApiAuthOption ApiAuth { get; set; } = new(); /// /// 接口文档页面访问前缀, 默认 "docs"。 /// 访问 /docs 即打开文档页面, JSON 地址为 /docs/{文档组Id}.json /// public string UrlPrefix { get; set; } = "docs"; /// /// 文档页面标题 /// public string DocumentTitle { get; set; } = "API接口文档"; /// /// 接口支持的调用方式 /// public SubmitMethod[] SupportedMethod { get; set; } = [SubmitMethod.Post]; }