Skip to content

Commit 8b00a77

Browse files
Sync changes from main to net8 - Applied recent commits, updated versions & framework, preserved .csproj files (#594)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e47990d commit 8b00a77

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

src/TickerQ.Dashboard/DashboardOptionsBuilder.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class DashboardOptionsBuilder
1212
internal string BasePath { get; set; } = "/tickerq/dashboard";
1313
internal Action<CorsPolicyBuilder> CorsPolicyBuilder { get; set; }
1414
internal string BackendDomain { get; set; }
15+
internal string GroupName { get; set; }
1516

1617
// Clean authentication system
1718
internal AuthConfig Auth { get; set; } = new();
@@ -35,6 +36,10 @@ public void SetBasePath(string basePath)
3536

3637
public void SetBackendDomain(string backendDomain)
3738
=> BackendDomain = backendDomain;
39+
40+
/// <summary>Set OpenAPI group name for dashboard endpoints</summary>
41+
public void SetGroupName(string groupName)
42+
=> GroupName = groupName;
3843

3944
/// <summary>Configure no authentication (public dashboard)</summary>
4045
public DashboardOptionsBuilder WithNoAuth()
@@ -101,4 +106,4 @@ internal void Validate()
101106
{
102107
Auth.Validate();
103108
}
104-
}
109+
}

src/TickerQ.Dashboard/Endpoints/DashboardEndpoints.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ public static void MapDashboardEndpoints<TTimeTicker, TCronTicker>(this IEndpoin
2626
where TCronTicker : CronTickerEntity, new()
2727
{
2828
// New authentication endpoints
29-
endpoints.MapGet("/api/auth/info", GetAuthInfo)
29+
WithGroupNameIfSet(endpoints.MapGet("/api/auth/info", GetAuthInfo)
3030
.WithName("GetAuthInfo")
3131
.WithSummary("Get authentication configuration")
3232
.WithTags("TickerQ Dashboard")
3333
.RequireCors("TickerQ_Dashboard_CORS")
34-
.AllowAnonymous();
34+
.AllowAnonymous(), config);
3535

36-
endpoints.MapPost("/api/auth/validate", ValidateAuth)
36+
WithGroupNameIfSet(endpoints.MapPost("/api/auth/validate", ValidateAuth)
3737
.WithName("ValidateAuth")
3838
.WithSummary("Validate authentication credentials")
3939
.WithTags("TickerQ Dashboard")
4040
.RequireCors("TickerQ_Dashboard_CORS")
41-
.AllowAnonymous();
41+
.AllowAnonymous(), config);
4242

4343
var apiGroup = endpoints.MapGroup("/api").WithTags("TickerQ Dashboard").RequireCors("TickerQ_Dashboard_CORS");
44+
WithGroupNameIfSet(apiGroup, config);
4445

4546
// Apply authentication if configured
4647
if (config.Auth.Mode == AuthMode.Host)
@@ -202,6 +203,16 @@ public static void MapDashboardEndpoints<TTimeTicker, TCronTicker>(this IEndpoin
202203

203204
}
204205
#region Endpoint Handlers
206+
207+
private static IEndpointConventionBuilder WithGroupNameIfSet(IEndpointConventionBuilder builder, DashboardOptionsBuilder config)
208+
{
209+
if (!string.IsNullOrWhiteSpace(config.GroupName))
210+
{
211+
builder.WithGroupName(config.GroupName);
212+
}
213+
214+
return builder;
215+
}
205216

206217
private static IResult GetAuthInfo(IAuthService authService, DashboardOptionsBuilder dashboardOptions)
207218
{

src/TickerQ.Dashboard/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ services.AddTickerQ<MyTimeTicker, MyCronTicker>(config =>
5959
});
6060
```
6161

62+
### Dedicated OpenAPI Group
63+
```csharp
64+
services.AddTickerQ<MyTimeTicker, MyCronTicker>(config =>
65+
{
66+
config.AddDashboard(dashboard =>
67+
{
68+
dashboard.SetGroupName("tickerq");
69+
});
70+
});
71+
```
72+
6273
## 🔧 Fluent API Methods
6374

6475
- `WithBasicAuth(username, password)` - Enable username/password authentication
@@ -67,6 +78,7 @@ services.AddTickerQ<MyTimeTicker, MyCronTicker>(config =>
6778
- `SetBasePath(path)` - Set dashboard URL path
6879
- `SetBackendDomain(domain)` - Set backend API domain
6980
- `SetCorsPolicy(policy)` - Configure CORS
81+
- `SetGroupName(name)` - Set OpenAPI group name for dashboard endpoints
7082

7183
## 🔒 How It Works
7284

0 commit comments

Comments
 (0)