af1152b001
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
// <copyright file="FileRequestFilter.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace Jellyfin.Server.Filters
|
|
{
|
|
using System.Collections.Generic;
|
|
using Jellyfin.Api.Attributes;
|
|
using Microsoft.OpenApi.Models;
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
|
|
/// <inheritdoc />
|
|
public class FileRequestFilter : IOperationFilter
|
|
{
|
|
/// <inheritdoc />
|
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
|
{
|
|
foreach (var attribute in context.ApiDescription.ActionDescriptor.EndpointMetadata)
|
|
{
|
|
if (attribute is AcceptsFileAttribute acceptsFileAttribute)
|
|
{
|
|
operation.RequestBody = GetRequestBody(acceptsFileAttribute.ContentTypes);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static OpenApiRequestBody GetRequestBody(IEnumerable<string> contentTypes)
|
|
{
|
|
var body = new OpenApiRequestBody();
|
|
var mediaType = new OpenApiMediaType
|
|
{
|
|
Schema = new OpenApiSchema
|
|
{
|
|
Type = "string",
|
|
Format = "binary"
|
|
}
|
|
};
|
|
foreach (var contentType in contentTypes)
|
|
{
|
|
body.Content.Add(contentType, mediaType);
|
|
}
|
|
|
|
return body;
|
|
}
|
|
}
|
|
}
|