diff --git a/src/NJsonSchema/Generation/JsonSchemaGenerator.cs b/src/NJsonSchema/Generation/JsonSchemaGenerator.cs index d568cec75..526c96456 100644 --- a/src/NJsonSchema/Generation/JsonSchemaGenerator.cs +++ b/src/NJsonSchema/Generation/JsonSchemaGenerator.cs @@ -1205,14 +1205,12 @@ private object TryGetInheritanceDiscriminatorConverter(Type type) return null; } - private string TryGetInheritanceDiscriminatorName(dynamic jsonInheritanceConverter) + private string TryGetInheritanceDiscriminatorName(object jsonInheritanceConverter) { - if (ObjectExtensions.HasProperty(jsonInheritanceConverter, nameof(JsonInheritanceConverter.DiscriminatorName))) - { - return jsonInheritanceConverter.DiscriminatorName; - } - - return JsonInheritanceConverter.DefaultDiscriminatorName; + return ObjectExtensions.TryGetPropertyValue( + jsonInheritanceConverter, + nameof(JsonInheritanceConverter.DiscriminatorName), + JsonInheritanceConverter.DefaultDiscriminatorName); } private void LoadPropertyOrField(JsonProperty jsonProperty, ContextualAccessorInfo accessorInfo, Type parentType, JsonSchema parentSchema, JsonSchemaResolver schemaResolver)