diff --git a/Kyoo.CommonAPI/CrudApi.cs b/Kyoo.CommonAPI/CrudApi.cs index d029659e..a15c0e33 100644 --- a/Kyoo.CommonAPI/CrudApi.cs +++ b/Kyoo.CommonAPI/CrudApi.cs @@ -40,11 +40,11 @@ namespace Kyoo.CommonApi [JsonDetailed] public virtual async Task> Get(string slug) { - T ressource = await _repository.Get(slug); - if (ressource == null) + T resource = await _repository.Get(slug); + if (resource == null) return NotFound(); - - return ressource; + + return resource; } [HttpGet] diff --git a/Kyoo.CommonAPI/JsonSerializer.cs b/Kyoo.CommonAPI/JsonSerializer.cs index 029b9cb9..829475c3 100644 --- a/Kyoo.CommonAPI/JsonSerializer.cs +++ b/Kyoo.CommonAPI/JsonSerializer.cs @@ -32,20 +32,26 @@ namespace Kyoo.Controllers private bool IsIgnored(Type type, string propertyName) { - if (_ignored.ContainsKey(type) && _ignored[type].Contains(propertyName)) - return true; - if (type.BaseType == null) - return false; - return _ignored.ContainsKey(type.BaseType) && _ignored[type.BaseType].Contains(propertyName); + while (type != null) + { + if (_ignored.ContainsKey(type) && _ignored[type].Contains(propertyName)) + return true; + type = type.BaseType; + } + + return false; } private bool IsSerializationForced(Type type, string propertyName) { - if (_forceSerialize.ContainsKey(type) && _forceSerialize[type].Contains(propertyName)) - return true; - if (type.BaseType == null) - return false; - return _forceSerialize.ContainsKey(type.BaseType) && _forceSerialize[type.BaseType].Contains(propertyName); + while (type != null) + { + if (_forceSerialize.ContainsKey(type) && _forceSerialize[type].Contains(propertyName)) + return true; + type = type.BaseType; + } + + return false; } protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) @@ -75,7 +81,7 @@ namespace Kyoo.Controllers result.Formatters.Add(new NewtonsoftJsonOutputFormatter( new JsonSerializerSettings { - ContractResolver = new JsonPropertySelector(null, new Dictionary>() + ContractResolver = new JsonPropertySelector(null, new Dictionary> { {typeof(Show), new HashSet {"genres", "studio"}}, {typeof(Episode), new HashSet {"tracks"}},