< 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: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

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

File(s)

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

#LineLine coverage
 1using System.Collections.Generic;
 2using Jellyfin.Api.Attributes;
 3using Microsoft.OpenApi.Models;
 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        {
 926014            foreach (var attribute in context.ApiDescription.ActionDescriptor.EndpointMetadata)
 15            {
 425216                if (attribute is AcceptsFileAttribute acceptsFileAttribute)
 17                {
 618                    operation.RequestBody = GetRequestBody(acceptsFileAttribute.ContentTypes);
 619                    break;
 20                }
 21            }
 38122        }
 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 = "string",
 632                    Format = "binary"
 633                }
 634            };
 2435            foreach (var contentType in contentTypes)
 36            {
 637                body.Content.Add(contentType, mediaType);
 38            }
 39
 640            return body;
 41        }
 42    }
 43}