RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.37k stars 529 forks source link

Using the generic type 'JsonInheritanceConverter<TBase>' requires 1 type argument #1686

Closed kemmis closed 5 months ago

kemmis commented 5 months ago

I'm using the JsonInheritanceConverter attribute on classes as described in the wiki here.

After upgrading from NJsonSchema 10.9.0 to 11.0.0 this syntax no longer works:

[JsonConverter(typeof(JsonInheritanceConverter), "discriminator")]
public class MyClass {}

And I get this error at build time: Error CS0305 Using the generic type 'JsonInheritanceConverter<TBase>' requires 1 type arguments

Adding <> to the type like this appears to resolve my build issues:

[JsonConverter(typeof(JsonInheritanceConverter<>), "discriminator")]
public class MyClass {}

Is this the correct way to use JsonInheritanceConverter with the JsonConvert attribute now?

RicoSuter commented 5 months ago

The class has been moved to https://www.nuget.org/packages/NJsonSchema.NewtonsoftJson

(You’re referencing the system.text.json one [default])

kemmis commented 5 months ago

Switching to that package and updating the to using NJsonSchema.NewtonsoftJson.Converter; fixed it. Thanks!