< Summary - Jellyfin

Information
Class: Jellyfin.Server.Filters.FileRequestFilter
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Filters/FileRequestFilter.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 44
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/28/2025 - 12:11:11 AM Line coverage: 100% (17/17) Branch coverage: 100% (6/6) Total lines: 432/27/2026 - 12:13:29 AM Line coverage: 100% (18/18) Branch coverage: 100% (8/8) Total lines: 44 11/28/2025 - 12:11:11 AM Line coverage: 100% (17/17) Branch coverage: 100% (6/6) Total lines: 432/27/2026 - 12:13:29 AM Line coverage: 100% (18/18) Branch coverage: 100% (8/8) Total lines: 44

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Apply(...)100%44100%
GetRequestBody(...)100%44100%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Filters/FileRequestFilter.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using Jellyfin.Api.Attributes;
 3using Microsoft.OpenApi;
 4using Swashbuckle.AspNetCore.SwaggerGen;
 5
 6namespace Jellyfin.Server.Filters
 7{
 8    /// <inheritdoc />
 9    public class FileRequestFilter : IOperationFilter
 10    {
 11        /// <inheritdoc />
 12        public void Apply(OpenApiOperation operation, OperationFilterContext context)
 13        {
 942414            foreach (var attribute in context.ApiDescription.ActionDescriptor.EndpointMetadata)
 15            {
 432816                if (attribute is AcceptsFileAttribute acceptsFileAttribute)
 17                {
 618                    operation.RequestBody = GetRequestBody(acceptsFileAttribute.ContentTypes);
 619                    break;
 20                }
 21            }
 38722        }
 23
 24        private static OpenApiRequestBody GetRequestBody(IEnumerable<string> contentTypes)
 25        {
 626            var body = new OpenApiRequestBody();
 627            var mediaType = new OpenApiMediaType
 628            {
 629                Schema = new OpenApiSchema
 630                {
 631                    Type = JsonSchemaType.String,
 632                    Format = "binary"
 633                }
 634            };
 635            body.Content ??= new System.Collections.Generic.Dictionary<string, OpenApiMediaType>();
 2436            foreach (var contentType in contentTypes)
 37            {
 638                body.Content.Add(contentType, mediaType);
 39            }
 40
 641            return body;
 42        }
 43    }
 44}