-
-
Notifications
You must be signed in to change notification settings - Fork 192
Closed
Labels
Description
Environment
- Nuget Package: JsonSchema.Net
- Nuget Version: 4.0.0
- OS: Linux
- .Net Target: .NET 7.0
Describe the bug
JsonSchemaExtensions.Bundle(EvaluationOptions) throws NullReferenceException given a schema containing ItemsKeyword.
To Reproduce
#r "nuget: JsonSchema.Net, 4.0.0"
using Json.Schema;
// items: true
var singleItemSchema = new JsonSchemaBuilder()
.Items(JsonSchema.True)
.Build();
singleItemSchema.Bundle(); // throws
// items: [true, true]
var multiItemSchema = new JsonSchemaBuilder()
.Items(new[]{JsonSchema.True, JsonSchema.True})
.Build();
multiItemSchema.Bundle(); // throwsstacktrace
for singleItemSchema:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at Json.Schema.JsonSchemaExtensions.Bundle(JsonSchema jsonSchema, EvaluationOptions options)
for multiItemSchema:
System.NullReferenceException: Object reference not set to an instance of an object.
at Json.Schema.JsonSchemaExtensions.Bundle(JsonSchema jsonSchema, EvaluationOptions options)
Expected behavior
Method returns bundled schema without exception.
Additional context
It seems (at least for the single-item case) this code is the problem:
On line 123, ItemsKeyword is ISchemaCollector, but when initialized with a single non-array value, it will return a null for ISchemaCollector.Schemas.
For multi-item case, I am not sure.
Reactions are currently unavailable