Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate API documentation for SignalR

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.

like image 797
LivingOnACloud Avatar asked Mar 09 '15 17:03

LivingOnACloud


People also ask

Is SignalR an API?

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.

Can SignalR be used in Web API?

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.

How does SignalR hub work?

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.

How to install SignalR in ASP NET Web API?

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.

Is there a SignalR documentation for the latest version of SignalR?

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.

How to create notificationhub in SignalR using web API?

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.

What is SignalR hubs API server side programming?

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.


1 Answers

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.

like image 123
dorin.mocan Avatar answered Oct 04 '22 14:10

dorin.mocan