NJsonSchema
NJsonSchema copied to clipboard
Сircular reference inside SampleJsonSchemaGenerator
https://github.com/RicoSuter/NJsonSchema/blob/424e9ad6b747f7761b09873454289b536c0080e7/src/NJsonSchema/Generation/SampleJsonSchemaGenerator.cs#L49 hi, guys, It looks like there is a little bug which causes cyclical dependency in the final scheme produced by SampleJsonSchemaGenerator.Generate(). We used following JSON for testing it:
[
{
"Data": {
"EmptyObj": {},
"ArrayObj": {
"AnotherEmptyObj": {}
}
}
}
]
and what we've got was a bit different than what we expected(left side - current behaviour, right side - expected):
Looking at your code it seems the problem might be in the LINQ extension method .All() which you probably expect returns false for the empty JSON object(because it doesn't have any fields inside). But it returns true. For example following C# code returns true:
var arr = new List<bool>();
var test = arr.All(x => false);
Output:
You are making a great product and it is really helpful. It simplifies life for many people. Could you please take into account this ticket and check whether it possible to correct such a little(but pity) bug? Looking forward on your response
Would be great if you could create a PR to fix this?