Merge pull request #4248 from crobibero/ws-document-filter

Manually register models used in websocket messages.
This commit is contained in:
Anthony Lavado 2020-10-09 20:11:57 -04:00 committed by GitHub
commit dd43af23a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

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

View File

@ -0,0 +1,30 @@
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(PlaystateRequest), 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<object>), context.SchemaRepository);
}
}
}