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

'JsonIgnoreCondition.WhenWritingNull' is not valid on value-type member #4037

Closed
craigktreasure opened this issue Jun 6, 2022 · 2 comments
Closed

Comments

@craigktreasure
Copy link

NSwag.ApiDescription.Client: 13.16.1

Generating a client with the following OpenApiProjectReference options:

/generateClientInterfaces:true /jsonLibrary:SystemTextJson /generateOptionalParameters:true /disposeHttpClient:false /injectHttpClient:true /useBaseUrl:false /classStyle:Poco /generateJsonMethods:true

Consider the following type:

public class MyClass
{
    public Guid Id { get; set; }
}

Classes with Guid typed properties are now annotated with a [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)] attribute, which is causing the following serialization error to be thrown when calling ToJson() on the object:

System.InvalidOperationException : The ignore condition 'JsonIgnoreCondition.WhenWritingNull' is not valid on value-type member 'Id' on type 'MyClass'. Consider using 'JsonIgnoreCondition.WhenWritingDefault'.

The issue first appeared in 13.16.0 and was last working in version 13.15.10.

@FaizulHussain
Copy link

FaizulHussain commented Jun 8, 2022

I'm also facing similar problem :(

System.InvalidOperationException : The ignore condition 'JsonIgnoreCondition.WhenWritingNull' is not valid on value-type member '...' on type '...'. Consider using 'JsonIgnoreCondition.WhenWritingDefault'.

@sdecoodt
Copy link

sdecoodt commented Jun 9, 2022

This is a duplicate of #4012, there is even a PR linked there

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

3 participants