NJsonSchema icon indicating copy to clipboard operation
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

Open christophdebaene opened this issue 1 year ago • 2 comments

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();

christophdebaene avatar Feb 07 '24 00:02 christophdebaene