NJsonSchema
NJsonSchema copied to clipboard
Could not find the JSON path of a referenced schema: Manually referenced schemas must be added to the 'Definitions' of a parent schema
I get an error when calling ToJson
.
I don't understand why it works fine when the type is simply Customer, but I encounter an error when it's a list.
public record Customer(string FirstName, string LastName)
{
}
var settings = new SystemTextJsonSchemaGeneratorSettings();
var document = new OpenApiDocument();
JsonSchemaGenerator generator = new(settings);
OpenApiSchemaResolver resolver = new(document, settings);
var customerListType = typeof(List<Customer>);
var schema = generator.Generate(customerListType, resolver);
var jschema = schema.ToJson();