فهرست منبع

Manually register models used in websocket messages.

crobibero 4 سال پیش
والد
کامیت
5ee6f49204
2فایلهای تغییر یافته به همراه32 افزوده شده و 0 حذف شده
  1. 1 0
      Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
  2. 31 0
      Jellyfin.Server/Filters/WebsocketModelFilter.cs

+ 1 - 0
Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs

@@ -260,6 +260,7 @@ namespace Jellyfin.Server.Extensions
                 c.AddSwaggerTypeMappings();
 
                 c.OperationFilter<FileResponseFilter>();
+                c.DocumentFilter<WebsocketModelFilter>();
             });
         }
 

+ 31 - 0
Jellyfin.Server/Filters/WebsocketModelFilter.cs

@@ -0,0 +1,31 @@
+using MediaBrowser.Common.Plugins;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Session;
+using MediaBrowser.Model.SyncPlay;
+using Microsoft.OpenApi.Models;
+using Swashbuckle.AspNetCore.SwaggerGen;
+
+namespace Jellyfin.Server.Filters
+{
+    /// <summary>
+    /// Add models used in websocket messaging.
+    /// </summary>
+    public class WebsocketModelFilter : IDocumentFilter
+    {
+        /// <inheritdoc />
+        public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
+        {
+            context.SchemaGenerator.GenerateSchema(typeof(LibraryUpdateInfo), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(IPlugin), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(PlayRequest), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(TimerEventInfo), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(SendCommand), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(GeneralCommandType), context.SchemaRepository);
+
+            context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate<string>), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate<PlayRequest>), context.SchemaRepository);
+            context.SchemaGenerator.GenerateSchema(typeof(GroupUpdate<long>), context.SchemaRepository);
+        }
+    }
+}