Skip to content
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

[Bug] NSwag 14.0.4 ignores JsonIgnoreAttribute #4834

Closed
Mrks83 opened this issue Mar 25, 2024 · 3 comments
Closed

[Bug] NSwag 14.0.4 ignores JsonIgnoreAttribute #4834

Mrks83 opened this issue Mar 25, 2024 · 3 comments

Comments

@Mrks83
Copy link

Mrks83 commented Mar 25, 2024

With NSwag 14.0.3 public properties with [JsonIgnore] were ignored. Now, they appear in the OpenApi document.
It looks like the serializer has changed from Newtonsoft Json to System.Text Json.

public class MyClass
{
    [Newtonsoft.Json.JsonIgnore]
    public object? Value
 
   ...
}
@Gismork
Copy link

Gismork commented Mar 25, 2024

I had the exact same issue when I updated from NSwag 14.0.3 to 14.0.04. I didn't understand why I had a "new" property in my client.

Using JsonIgnore attribute from System.Text.Json.Serialization fix that.

Thanks !

@RicoSuter
Copy link
Owner

I think this PR here broke this:
#4733

@isteyak
Copy link

isteyak commented Apr 10, 2024

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?

lahma pushed a commit to lahma/NSwag that referenced this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants