diff --git a/src/TickerQ.Dashboard/DashboardOptionsBuilder.cs b/src/TickerQ.Dashboard/DashboardOptionsBuilder.cs index 612a6459..46639c95 100644 --- a/src/TickerQ.Dashboard/DashboardOptionsBuilder.cs +++ b/src/TickerQ.Dashboard/DashboardOptionsBuilder.cs @@ -12,6 +12,7 @@ public class DashboardOptionsBuilder internal string BasePath { get; set; } = "/tickerq/dashboard"; internal Action CorsPolicyBuilder { get; set; } internal string BackendDomain { get; set; } + internal string GroupName { get; set; } // Clean authentication system internal AuthConfig Auth { get; set; } = new(); @@ -35,6 +36,10 @@ public void SetBasePath(string basePath) public void SetBackendDomain(string backendDomain) => BackendDomain = backendDomain; + + /// Set OpenAPI group name for dashboard endpoints + public void SetGroupName(string groupName) + => GroupName = groupName; /// Configure no authentication (public dashboard) public DashboardOptionsBuilder WithNoAuth() @@ -101,4 +106,4 @@ internal void Validate() { Auth.Validate(); } -} \ No newline at end of file +} diff --git a/src/TickerQ.Dashboard/Endpoints/DashboardEndpoints.cs b/src/TickerQ.Dashboard/Endpoints/DashboardEndpoints.cs index 7d98c60a..18c30a4d 100644 --- a/src/TickerQ.Dashboard/Endpoints/DashboardEndpoints.cs +++ b/src/TickerQ.Dashboard/Endpoints/DashboardEndpoints.cs @@ -26,21 +26,22 @@ public static void MapDashboardEndpoints(this IEndpoin where TCronTicker : CronTickerEntity, new() { // New authentication endpoints - endpoints.MapGet("/api/auth/info", GetAuthInfo) + WithGroupNameIfSet(endpoints.MapGet("/api/auth/info", GetAuthInfo) .WithName("GetAuthInfo") .WithSummary("Get authentication configuration") .WithTags("TickerQ Dashboard") .RequireCors("TickerQ_Dashboard_CORS") - .AllowAnonymous(); + .AllowAnonymous(), config); - endpoints.MapPost("/api/auth/validate", ValidateAuth) + WithGroupNameIfSet(endpoints.MapPost("/api/auth/validate", ValidateAuth) .WithName("ValidateAuth") .WithSummary("Validate authentication credentials") .WithTags("TickerQ Dashboard") .RequireCors("TickerQ_Dashboard_CORS") - .AllowAnonymous(); + .AllowAnonymous(), config); var apiGroup = endpoints.MapGroup("/api").WithTags("TickerQ Dashboard").RequireCors("TickerQ_Dashboard_CORS"); + WithGroupNameIfSet(apiGroup, config); // Apply authentication if configured if (config.Auth.Mode == AuthMode.Host) @@ -202,6 +203,16 @@ public static void MapDashboardEndpoints(this IEndpoin } #region Endpoint Handlers + + private static IEndpointConventionBuilder WithGroupNameIfSet(IEndpointConventionBuilder builder, DashboardOptionsBuilder config) + { + if (!string.IsNullOrWhiteSpace(config.GroupName)) + { + builder.WithGroupName(config.GroupName); + } + + return builder; + } private static IResult GetAuthInfo(IAuthService authService, DashboardOptionsBuilder dashboardOptions) { diff --git a/src/TickerQ.Dashboard/README.md b/src/TickerQ.Dashboard/README.md index a2b02eea..80d57ca9 100644 --- a/src/TickerQ.Dashboard/README.md +++ b/src/TickerQ.Dashboard/README.md @@ -59,6 +59,17 @@ services.AddTickerQ(config => }); ``` +### Dedicated OpenAPI Group +```csharp +services.AddTickerQ(config => +{ + config.AddDashboard(dashboard => + { + dashboard.SetGroupName("tickerq"); + }); +}); +``` + ## 🔧 Fluent API Methods - `WithBasicAuth(username, password)` - Enable username/password authentication @@ -67,6 +78,7 @@ services.AddTickerQ(config => - `SetBasePath(path)` - Set dashboard URL path - `SetBackendDomain(domain)` - Set backend API domain - `SetCorsPolicy(policy)` - Configure CORS +- `SetGroupName(name)` - Set OpenAPI group name for dashboard endpoints ## 🔒 How It Works