From 7e8ab3b17351fb34797b74016bf2a35a9edc7185 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 28 Feb 2021 05:15:44 +0100 Subject: [PATCH] Fixing the json serializer --- .../Controllers/Implementations/LibraryManager.cs | 3 ++- Kyoo.CommonAPI/JsonSerializer.cs | 14 ++++++-------- Kyoo.CommonAPI/ResourceViewAttribute.cs | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs index ad1554a6..640ed956 100644 --- a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs +++ b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs @@ -302,8 +302,9 @@ namespace Kyoo.Controllers (Show s, nameof(Show.Collections)) => CollectionRepository .GetAll(Utility.ResourceEquals(obj)) .Then(x => s.Collections = x), + // TODO Studio loading does not work. (Show s, nameof(Show.Studio)) => StudioRepository - .Get(x => x.Shows.Any(Utility.ResourceEqualsFunc(obj))) + .Get(x => x.Shows.Any(y => y.ID == obj.ID || y.Slug == obj.Slug)) .Then(x => s.Studio = x), (Season s, nameof(Season.ExternalIDs)) => ProviderRepository diff --git a/Kyoo.CommonAPI/JsonSerializer.cs b/Kyoo.CommonAPI/JsonSerializer.cs index 78f49ed8..d0d30975 100644 --- a/Kyoo.CommonAPI/JsonSerializer.cs +++ b/Kyoo.CommonAPI/JsonSerializer.cs @@ -11,14 +11,12 @@ namespace Kyoo.Controllers { JsonProperty property = base.CreateProperty(member, memberSerialization); - // TODO this get called only once and get cached. - - // if (member?.GetCustomAttributes() != null) - // property.NullValueHandling = NullValueHandling.Ignore; - // if (member?.GetCustomAttributes() != null) - // property.ShouldSerialize = _ => false; - // if (member?.GetCustomAttributes() != null) - // property.ShouldDeserialize = _ => false; + if (member?.GetCustomAttribute() != null) + property.NullValueHandling = NullValueHandling.Ignore; + if (member?.GetCustomAttribute() != null) + property.ShouldSerialize = _ => false; + if (member?.GetCustomAttribute() != null) + property.ShouldDeserialize = _ => false; return property; } } diff --git a/Kyoo.CommonAPI/ResourceViewAttribute.cs b/Kyoo.CommonAPI/ResourceViewAttribute.cs index 9a2dab33..565c1e4b 100644 --- a/Kyoo.CommonAPI/ResourceViewAttribute.cs +++ b/Kyoo.CommonAPI/ResourceViewAttribute.cs @@ -24,7 +24,7 @@ namespace Kyoo.CommonApi where.Remove(key); } - string[] fields = context.HttpContext.Request.Query["fields"].ToArray(); + string[] fields = string.Join(',', context.HttpContext.Request.Query["fields"]).Split(','); context.HttpContext.Items["fields"] = fields; if (context.ActionDescriptor is ControllerActionDescriptor descriptor) @@ -68,6 +68,7 @@ namespace Kyoo.CommonApi Type pageType = Utility.GetGenericDefinition(result.DeclaredType, typeof(Page<>)); + // TODO loading is case sensitive. Maybe convert them in the first check. if (pageType != null) { foreach (IResource resource in ((dynamic)result.Value).Items)