You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using the nswag C# Client generation of v13.2 the model properties had been annotated with [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] . And with that the client did not serialize null values, which we appreciated.
After upgrading to v14.1 these annotations were lost in the generated client.cs.
I tried to add the DefaultIgnoreCondition in the OpenApiDocumentGenerator, but that did not change the generated cs-file. Worth mentioning is that the change to PropertyNamingPolicy within the OpenApiDocumentGenerator helped however and added the annotation [System.Text.Json.Serialization.JsonPropertyName("fieldName")] to the generated Client.cs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
when using the nswag C# Client generation of v13.2 the model properties had been annotated with
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
. And with that the client did not serialize null values, which we appreciated.After upgrading to v14.1 these annotations were lost in the generated client.cs.
I tried to add the DefaultIgnoreCondition in the OpenApiDocumentGenerator, but that did not change the generated cs-file. Worth mentioning is that the change to PropertyNamingPolicy within the OpenApiDocumentGenerator helped however and added the annotation
[System.Text.Json.Serialization.JsonPropertyName("fieldName")]
to the generated Client.cs.I also had a look into nswag.json, if a property recommends itself allowing to change the null-serialization behavior. But I found none.
Does anybody have the same issue or even a solution to omit serialization of fields having a null value?
Thanks
Max
Beta Was this translation helpful? Give feedback.
All reactions