diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-27 13:27:57 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-02-27 13:27:57 +0100 |
| commit | bd6bf6ee3c33c8f322740de019f78dee998cca0f (patch) | |
| tree | 14639a570bd4e59ed3e99432b04e0f8bafa6f985 /Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs | |
| parent | 2d0d497961a7ca990384bd180f381824d5591cb8 (diff) | |
| parent | bdfb6edfa3bb0ed1b4876edb3c1cf8f42b7486de (diff) | |
Merge remote-tracking branch 'upstream/master' into perf-rebased
Diffstat (limited to 'Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs')
| -rw-r--r-- | Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs b/Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs index 3e0b69d017..0c1f4197ce 100644 --- a/Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs +++ b/Jellyfin.Server/Filters/FlagsEnumSchemaFilter.cs @@ -1,5 +1,5 @@ using System; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; namespace Jellyfin.Server.Filters; @@ -15,7 +15,7 @@ namespace Jellyfin.Server.Filters; public class FlagsEnumSchemaFilter : ISchemaFilter { /// <inheritdoc /> - public void Apply(OpenApiSchema schema, SchemaFilterContext context) + public void Apply(IOpenApiSchema schema, SchemaFilterContext context) { var type = context.Type.IsEnum ? context.Type : Nullable.GetUnderlyingType(context.Type); if (type is null || !type.IsEnum) @@ -29,11 +29,16 @@ public class FlagsEnumSchemaFilter : ISchemaFilter return; } + if (schema is not OpenApiSchema concreteSchema) + { + return; + } + if (context.MemberInfo is null) { // Processing the enum definition itself - ensure it's type "string" not "integer" - schema.Type = "string"; - schema.Format = null; + concreteSchema.Type = JsonSchemaType.String; + concreteSchema.Format = null; } else { @@ -43,11 +48,11 @@ public class FlagsEnumSchemaFilter : ISchemaFilter // Flags enums should be represented as arrays referencing the enum schema // since multiple values can be combined - schema.Type = "array"; - schema.Format = null; - schema.Enum = null; - schema.AllOf = null; - schema.Items = enumSchema; + concreteSchema.Type = JsonSchemaType.Array; + concreteSchema.Format = null; + concreteSchema.Enum = null; + concreteSchema.AllOf = null; + concreteSchema.Items = enumSchema; } } } |
