Skip to content

Commit

Permalink
Allign JsonPropertyRequiredCode with IsNullable which was implemented…
Browse files Browse the repository at this point in the history
… in 87bd7a4 (#1622)

Currently the JsonPropertyRequiredCode does not reflect the previous fix, resulting in generating nullable properties with Required.DisallowNull and NullValueHandling.Ingore for optional properties.

Co-authored-by: AzureAD\KristianHauge <kh@peaksystems.dk>
  • Loading branch information
KristianHauge and khpeak committed Sep 26, 2023
1 parent 2633a99 commit e4f8001
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NJsonSchema.CodeGeneration.CSharp/Models/PropertyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public string JsonPropertyRequiredCode
{
if (_settings.RequiredPropertiesMustBeDefined && _property.IsRequired)
{
if (!_property.IsNullable(_settings.SchemaType))
if (!IsNullable)
{
return "Newtonsoft.Json.Required.Always";
}
Expand All @@ -94,7 +94,7 @@ public string JsonPropertyRequiredCode
}
else
{
if (!_property.IsNullable(_settings.SchemaType))
if (!IsNullable)
{
return "Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore";
}
Expand Down

0 comments on commit e4f8001

Please sign in to comment.