I am trying to move from Json.Net to system.Text.Json library in .Net core 3.1. I notice an odd behavior, that swagger doesn't show the attribute that have [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
on the request UI.
system.Text.Json
The request class :
public class AdvancedSearch
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? StatusID { get; set; }
public int? SessionCode { get; set; }
public int? KeywordVersionID { get; set; }
}
Json.Net The request class :
public class AdvancedSearch
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public int? StatusID { get; set; }
public int? SessionCode { get; set; }
public int? KeywordVersionID { get; set; }
}
newtonsoft works as it supposed to, serialize/deserialize while ignoring null values, but still showing them on swagger UI.
Is there a way to have System.Text.Json do the same ?