mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 12:14:21 -04:00
Add ability to mark query parameter as obsolete.
This commit is contained in:
parent
215554bb41
commit
59ff2c5b4b
12
Jellyfin.Api/Attributes/ParameterObsoleteAttribute.cs
Normal file
12
Jellyfin.Api/Attributes/ParameterObsoleteAttribute.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Jellyfin.Api.Attributes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attribute to mark a parameter as obsolete.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public class ParameterObsoleteAttribute : Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -83,6 +83,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
|
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
|
||||||
|
/// Query parameters are obsolete.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="itemId">The item id.</param>
|
/// <param name="itemId">The item id.</param>
|
||||||
/// <param name="userId">The user id.</param>
|
/// <param name="userId">The user id.</param>
|
||||||
@ -106,20 +107,20 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PlaybackInfoResponse>> GetPostedPlaybackInfo(
|
public async Task<ActionResult<PlaybackInfoResponse>> GetPostedPlaybackInfo(
|
||||||
[FromRoute, Required] Guid itemId,
|
[FromRoute, Required] Guid itemId,
|
||||||
[FromQuery] Guid? userId,
|
[FromQuery, ParameterObsolete] Guid? userId,
|
||||||
[FromQuery] int? maxStreamingBitrate,
|
[FromQuery, ParameterObsolete] int? maxStreamingBitrate,
|
||||||
[FromQuery] long? startTimeTicks,
|
[FromQuery, ParameterObsolete] long? startTimeTicks,
|
||||||
[FromQuery] int? audioStreamIndex,
|
[FromQuery, ParameterObsolete] int? audioStreamIndex,
|
||||||
[FromQuery] int? subtitleStreamIndex,
|
[FromQuery, ParameterObsolete] int? subtitleStreamIndex,
|
||||||
[FromQuery] int? maxAudioChannels,
|
[FromQuery, ParameterObsolete] int? maxAudioChannels,
|
||||||
[FromQuery] string? mediaSourceId,
|
[FromQuery, ParameterObsolete] string? mediaSourceId,
|
||||||
[FromQuery] string? liveStreamId,
|
[FromQuery, ParameterObsolete] string? liveStreamId,
|
||||||
[FromQuery] bool? autoOpenLiveStream,
|
[FromQuery, ParameterObsolete] bool? autoOpenLiveStream,
|
||||||
[FromQuery] bool? enableDirectPlay,
|
[FromQuery, ParameterObsolete] bool? enableDirectPlay,
|
||||||
[FromQuery] bool? enableDirectStream,
|
[FromQuery, ParameterObsolete] bool? enableDirectStream,
|
||||||
[FromQuery] bool? enableTranscoding,
|
[FromQuery, ParameterObsolete] bool? enableTranscoding,
|
||||||
[FromQuery] bool? allowVideoStreamCopy,
|
[FromQuery, ParameterObsolete] bool? allowVideoStreamCopy,
|
||||||
[FromQuery] bool? allowAudioStreamCopy,
|
[FromQuery, ParameterObsolete] bool? allowAudioStreamCopy,
|
||||||
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] PlaybackInfoDto? playbackInfoDto)
|
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] PlaybackInfoDto? playbackInfoDto)
|
||||||
{
|
{
|
||||||
var authInfo = _authContext.GetAuthorizationInfo(Request);
|
var authInfo = _authContext.GetAuthorizationInfo(Request);
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Api.Attributes;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Extensions;
|
using Jellyfin.Api.Extensions;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
@ -57,6 +58,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
|
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
|
||||||
|
/// Query parameters are obsolete.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="name">The playlist name.</param>
|
/// <param name="name">The playlist name.</param>
|
||||||
/// <param name="ids">The item ids.</param>
|
/// <param name="ids">The item ids.</param>
|
||||||
@ -70,10 +72,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PlaylistCreationResult>> CreatePlaylist(
|
public async Task<ActionResult<PlaylistCreationResult>> CreatePlaylist(
|
||||||
[FromQuery] string? name,
|
[FromQuery, ParameterObsolete] string? name,
|
||||||
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] IReadOnlyList<Guid> ids,
|
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder)), ParameterObsolete] IReadOnlyList<Guid> ids,
|
||||||
[FromQuery] Guid? userId,
|
[FromQuery, ParameterObsolete] Guid? userId,
|
||||||
[FromQuery] string? mediaType,
|
[FromQuery, ParameterObsolete] string? mediaType,
|
||||||
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] CreatePlaylistDto? createPlaylistRequest)
|
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] CreatePlaylistDto? createPlaylistRequest)
|
||||||
{
|
{
|
||||||
if (ids.Count == 0)
|
if (ids.Count == 0)
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Text;
|
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
using Jellyfin.Api.Auth;
|
using Jellyfin.Api.Auth;
|
||||||
using Jellyfin.Api.Auth.DefaultAuthorizationPolicy;
|
using Jellyfin.Api.Auth.DefaultAuthorizationPolicy;
|
||||||
@ -25,7 +22,6 @@ using Jellyfin.Api.Controllers;
|
|||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Networking.Configuration;
|
using Jellyfin.Networking.Configuration;
|
||||||
using Jellyfin.Networking.Manager;
|
|
||||||
using Jellyfin.Server.Configuration;
|
using Jellyfin.Server.Configuration;
|
||||||
using Jellyfin.Server.Filters;
|
using Jellyfin.Server.Filters;
|
||||||
using Jellyfin.Server.Formatters;
|
using Jellyfin.Server.Formatters;
|
||||||
@ -317,6 +313,7 @@ namespace Jellyfin.Server.Extensions
|
|||||||
|
|
||||||
c.OperationFilter<SecurityRequirementsOperationFilter>();
|
c.OperationFilter<SecurityRequirementsOperationFilter>();
|
||||||
c.OperationFilter<FileResponseFilter>();
|
c.OperationFilter<FileResponseFilter>();
|
||||||
|
c.OperationFilter<ParameterObsoleteFilter>();
|
||||||
c.DocumentFilter<WebsocketModelFilter>();
|
c.DocumentFilter<WebsocketModelFilter>();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
37
Jellyfin.Server/Filters/ParameterObsoleteFilter.cs
Normal file
37
Jellyfin.Server/Filters/ParameterObsoleteFilter.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Jellyfin.Api.Attributes;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Filters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mark parameter as deprecated if it has the <see cref="ParameterObsoleteAttribute"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class ParameterObsoleteFilter : IOperationFilter
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
|
{
|
||||||
|
foreach (var parameterDescription in context.ApiDescription.ParameterDescriptions)
|
||||||
|
{
|
||||||
|
if (parameterDescription
|
||||||
|
.CustomAttributes()
|
||||||
|
.OfType<ParameterObsoleteAttribute>()
|
||||||
|
.Any())
|
||||||
|
{
|
||||||
|
foreach (var parameter in operation.Parameters)
|
||||||
|
{
|
||||||
|
if (parameter.Name.Equals(parameterDescription.Name, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
parameter.Deprecated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user