Skip to content

Commit

Permalink
Improve TryGetInheritanceDiscriminatorName
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Feb 18, 2022
1 parent eb20a66 commit d5b6ed7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/NJsonSchema/Generation/JsonSchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d5b6ed7

Please sign in to comment.