Fixing the json serializer

This commit is contained in:
Zoe Roux 2021-02-28 05:15:44 +01:00
parent faf453e64a
commit 7e8ab3b173
3 changed files with 10 additions and 10 deletions

View File

@ -302,8 +302,9 @@ namespace Kyoo.Controllers
(Show s, nameof(Show.Collections)) => CollectionRepository (Show s, nameof(Show.Collections)) => CollectionRepository
.GetAll(Utility.ResourceEquals<Collection>(obj)) .GetAll(Utility.ResourceEquals<Collection>(obj))
.Then(x => s.Collections = x), .Then(x => s.Collections = x),
// TODO Studio loading does not work.
(Show s, nameof(Show.Studio)) => StudioRepository (Show s, nameof(Show.Studio)) => StudioRepository
.Get(x => x.Shows.Any(Utility.ResourceEqualsFunc<Show>(obj))) .Get(x => x.Shows.Any(y => y.ID == obj.ID || y.Slug == obj.Slug))
.Then(x => s.Studio = x), .Then(x => s.Studio = x),
(Season s, nameof(Season.ExternalIDs)) => ProviderRepository (Season s, nameof(Season.ExternalIDs)) => ProviderRepository

View File

@ -11,14 +11,12 @@ namespace Kyoo.Controllers
{ {
JsonProperty property = base.CreateProperty(member, memberSerialization); JsonProperty property = base.CreateProperty(member, memberSerialization);
// TODO this get called only once and get cached. if (member?.GetCustomAttribute<LoadableRelationAttribute>() != null)
property.NullValueHandling = NullValueHandling.Ignore;
// if (member?.GetCustomAttributes<LoadableRelationAttribute>() != null) if (member?.GetCustomAttribute<SerializeIgnoreAttribute>() != null)
// property.NullValueHandling = NullValueHandling.Ignore; property.ShouldSerialize = _ => false;
// if (member?.GetCustomAttributes<SerializeIgnoreAttribute>() != null) if (member?.GetCustomAttribute<DeserializeIgnoreAttribute>() != null)
// property.ShouldSerialize = _ => false; property.ShouldDeserialize = _ => false;
// if (member?.GetCustomAttributes<DeserializeIgnoreAttribute>() != null)
// property.ShouldDeserialize = _ => false;
return property; return property;
} }
} }

View File

@ -24,7 +24,7 @@ namespace Kyoo.CommonApi
where.Remove(key); 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; context.HttpContext.Items["fields"] = fields;
if (context.ActionDescriptor is ControllerActionDescriptor descriptor) if (context.ActionDescriptor is ControllerActionDescriptor descriptor)
@ -68,6 +68,7 @@ namespace Kyoo.CommonApi
Type pageType = Utility.GetGenericDefinition(result.DeclaredType, typeof(Page<>)); Type pageType = Utility.GetGenericDefinition(result.DeclaredType, typeof(Page<>));
// TODO loading is case sensitive. Maybe convert them in the first check.
if (pageType != null) if (pageType != null)
{ {
foreach (IResource resource in ((dynamic)result.Value).Items) foreach (IResource resource in ((dynamic)result.Value).Items)