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
The polymorphism in C# with Newtonsoft.Json is unable to deserialize child classes due to the JsonConverter annotation present in the child class.
#17990
Open
npottiez opened this issue
Feb 28, 2024
· 2 comments
"Adding [JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] to the child C# class compels Newtonsoft to not look at the subtypes within the child class. To do it properly, one should move the line [JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] in {{#mappedModels.length}}.
like this ?
{{#mappedModels.length}}
[JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")]
{{/mappedModels.length}}
"Adding [JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] to the child C# class compels Newtonsoft to not look at the subtypes within the child class. To do it properly, one should move the line [JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")] in {{#mappedModels.length}}.
like this ?
{{#mappedModels.length}}
[JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")]
{{/mappedModels.length}}
https://github.com/OpenAPITools/openapi-generator/blame/275ed9296dea4a1a894cc5b3402b5b8f3a61e7d7/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache#L13
The text was updated successfully, but these errors were encountered: