-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsonignore attributes is not showing in latest nswag 14.0.7 version generated code #4852
Comments
We are encountering the exact same issue. For us, we have this model class - public class SystemData
{
[JsonPropertyName("createdAt")]
public DateTimeOffset CreatedAt { get; set; }
} Prior to nswag v14.0.7 (we were using 13.8.2), we saw the below in the generated contract.g.cs, which is what we wanted: [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class SystemData
{
[System.Text.Json.Serialization.JsonPropertyName("createdAt")]
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)]
public System.DateTimeOffset? CreatedAt { get; set; } = default!;
} After we bumped up to v14.0.7, we see the below instead. Note that the [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class SystemData
{
[System.Text.Json.Serialization.JsonPropertyName("createdAt")]
public System.DateTimeOffset? CreatedAt { get; set; } = default!;
} Could this be a regression? |
still finding way to fix it |
unfortunately jsonignore attributes for property has been removed from njsonschema 11.0.0 version. |
@franklixuefei
4.Ran Nswag as normal - nswag run NSwagConfig.nswag Took reference from [https://github.com/RicoSuter/NJsonSchema/issues/1564] |
Moved to NJsonSchema.Annotations |
|
is there any update? i have the same problem where after update to 14.x the attribute isnt generated |
@ffwdq above one is work around using template, that worked for me |
I'musing openApiToCSharpClient (nswag 14.0.7 version)
prior to that i was using (nswag 13.20.0 version)
before my client code was showing jsonignore attributes like :
[System.Text.Json.Serialization.JsonPropertyName("href")]
[System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.Uri Href { get; set; }
Now its not showing
[System.Text.Json.Serialization.JsonPropertyName("href")]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
public System.Uri Href { get; set; }
what do i need to do in-order to fix it?
The text was updated successfully, but these errors were encountered: