NJsonSchema v. 11 breaks JsonSchemaGeneratorSettings

491 Views Asked by At

In NJsonSchema 10.9 I used to create my schema generator in C# like this:

private static JsonSchemaGenerator MakeGenerator()
{
    JsonSchemaGeneratorSettings settings = new()
    {
        DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull,
        AllowReferencesWithProperties = true,
        FlattenInheritanceHierarchy = true
    };
    return new( settings );
}

As of version 11, JsonSchemaGeneratorSettings is an abstract class. The only implementation I can find is SystemTextSchemaGeneratorSettings, which doesn't do what I want. Implementing JsonSchemaGeneratorSettings requires an IReflectionService, but the DefaultReflectionService class has also disappeared.

Does anyone know what I have to do to get the same behavior I had in 10.9?

1

There are 1 best solutions below

1
user23248604 On BEST ANSWER

I used NJsonSchema.NewtonsoftJson.Generation.NewtonsoftJsonSchemaGeneratorSettings from https://www.nuget.org/packages/NJsonSchema.NewtonsoftJson It made it work again for me