Skip to content

Releases: mberrishdev/HubDocs

v0.0.6

17 Nov 21:14

Choose a tag to compare

🎯 Breaking Changes

  • Removed MapHubAndRegister() extension method - Use standard app.MapHub() instead
  • Removed HubRouteRegistry static registry - Routes are now read from registered endpoints
  • [HubDocs] attribute no longer requires route parameter - Routes come from MapHub() registration

✨ New Features

Attribute-Based Opt-In Discovery

  • [HubDocs] attribute is now a simple marker with no parameters
  • Just decorate your hub classes to include them in documentation
  • Provides explicit control over which hubs are publicly documented

Endpoint Inspection

  • Routes are automatically discovered from registered SignalR endpoints
  • No need to maintain separate hub registrations
  • Works seamlessly with existing MapHub() calls

🔄 Migration Guide

Before (v0.0.5)

// Old approach - custom registration method
app.MapHubAndRegister("/hubs/chat");
app.AddHubDocs();

After (v0.0.6)

// New approach - standard SignalR registration + attribute
[HubDocs] // Mark for documentation
public class ChatHub : Hub { }

// Register normally with MapHub
app.MapHub("/hubs/chat");
app.AddHubDocs();

🎨 Benefits

  • ✅ Standard SignalR patterns - Use native MapHub() registration
  • ✅ Explicit opt-in - Only attributed hubs appear in documentation
  • ✅ No duplicate registration - Single source of truth for routes
  • ✅ Cleaner API - Simpler attribute with no parameters
  • ✅ Better separation of concerns - Hub registration separate from documentation

📝 Full Example

using HubDocs;
using Microsoft.AspNetCore.SignalR;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();

var app = builder.Build();

// Register your hubs
app.MapHub("/hubs/chat");
app.MapHub("/hubs/notifications");

// Add HubDocs - discovers hubs with [HubDocs] attribute
app.AddHubDocs();

app.Run();

// Mark hubs for documentation
[HubDocs]
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.ReceiveMessage(user, message);
}
}

[HubDocs]
public class NotificationHub : Hub
{
public async Task SendNotification(string title, string message)
{
await Clients.All.SendAsync("ReceiveNotification", title, message);
}
}

🔧 Technical Details

  • Routes are extracted from EndpointDataSource via reflection
  • Only hubs with [HubDocs] attribute that are also registered via MapHub() appear in the UI
  • Maintains full support for strongly-typed client interfaces (Hub)

smaller one, same to use commit message

⏺ Release v0.0.6

Breaking Changes

  • Removed MapHubAndRegister() - use standard MapHub() instead
  • [HubDocs] attribute no longer takes route parameter

Changes

  • [HubDocs] is now a simple marker attribute with no parameters
  • Routes automatically discovered from registered SignalR endpoints
  • Hubs must be both attributed with [HubDocs] AND registered via MapHub()

Migration

Before:
app.MapHubAndRegister("/hubs/chat");

After:
[HubDocs]
public class ChatHub : Hub { }

app.MapHub("/hubs/chat");