Adjust the handling of [JsonIgnore] to recurse and apply to inherited properties.
This commit is contained in:
Родитель
238a039c25
Коммит
938e827e82
|
@ -139,7 +139,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions
|
|||
var allProperties = type.IsInterface
|
||||
? new[] { type }.Concat(type.GetInterfaces()).SelectMany(i => i.GetProperties())
|
||||
: type.GetProperties();
|
||||
var properties = allProperties.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>());
|
||||
var properties = allProperties.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>(true));
|
||||
|
||||
var retVal = new Dictionary<string, OpenApiSchema>();
|
||||
foreach (var property in properties)
|
||||
|
|
|
@ -634,7 +634,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions
|
|||
public static bool HasRecursiveProperty(this Type type)
|
||||
{
|
||||
var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>());
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>(true));
|
||||
|
||||
var hasRecursiveType = properties.Select(p => p.PropertyType)
|
||||
.Any(p => p == type);
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors
|
|||
// Processes properties.
|
||||
var properties = type.Value
|
||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>())
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>(true))
|
||||
.ToDictionary(p => p.GetJsonPropertyName(namingStrategy), p => p);
|
||||
|
||||
this.ProcessProperties(instance, name, properties, namingStrategy);
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors
|
|||
// Processes non-recursive properties
|
||||
var properties = type.Value
|
||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>())
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>(true))
|
||||
.Where(p => p.PropertyType != type.Value)
|
||||
.ToDictionary(p => p.GetJsonPropertyName(namingStrategy), p => p);
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Visitors
|
|||
// Processes recursive properties
|
||||
var recursiveProperties = type.Value
|
||||
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>())
|
||||
.Where(p => !p.ExistsCustomAttribute<JsonIgnoreAttribute>(true))
|
||||
.Where(p => p.PropertyType == type.Value)
|
||||
.ToDictionary(p => p.GetJsonPropertyName(namingStrategy), p => p);
|
||||
var recursiveSchemas = recursiveProperties.ToDictionary(p => p.Key,
|
||||
|
|
Загрузка…
Ссылка в новой задаче