Is there a way to do this?
I have swashbuckle generating content for my other APIs but I don't believe it works for SignalR.
The SignalR Hubs API enables you to make remote procedure calls (RPCs) from a server to connected clients and from clients to the server. In server code, you define methods that can be called by clients, and you call methods that run on the client.
Objective: Use SignalR for notification between Web API, and TypeScript/JavaScript based Web App, where Web API and the Web App is hosted in different domain. Enabling SignalR and CORS on Web API: Create a standard Web API project, and install the following NuGet packages: Microsoft.
What is a SignalR hub. The SignalR Hubs API enables you to call methods on connected clients from the server. In the server code, you define methods that are called by client. In the client code, you define methods that are called from the server.
Now let’s install SignalR NuGet package to the ASP.NET Web API project. You can use either NuGet Package Manager and Package Manager Console. Here we are using Package Manager Console by running Install-Package Microsoft.AspNet.SignalR. Now open up the Startup.cs in the Web API project and bootstrap SignalR as follows.
This documentation isn't for the latest version of SignalR. Take a look at ASP.NET Core SignalR. This document provides an introduction to programming the server side of the ASP.NET SignalR Hubs API for SignalR version 2, with code samples demonstrating common options.
Now open up the Startup.cs in the Web API project and bootstrap SignalR as follows. Now let’s create a folder inside Web API project named “ Hubs ” and add a SignalR Hub Class. Let's name it as “ NotificationHub ”. The created file will contain a Hello () method, and let's just leave it as it is.
This document provides an introduction to programming the server side of the ASP.NET SignalR Hubs API for SignalR version 2, with code samples demonstrating common options. The SignalR Hubs API enables you to make remote procedure calls (RPCs) from a server to connected clients and from clients to the server.
Here's a Nuget package which can help you.
Nuget link: https://www.nuget.org/packages/SignalRSwaggerGen/
Github link: https://github.com/Dorin-Mocan/SignalRSwaggerGen/wiki
First you need to decorate your SignalR hubs with attributes from SignalRSwaggerGen.Attributes namespace:
[SignalRHub] public class SomeHub : Hub { }
Then you add SignalRSwaggerGen to Swagger generator:
services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Some API v1", Version = "v1" }); // here some other configurations maybe... options.AddSignalRSwaggerGen(); });
For more information please refer to Github documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With