@@ -288,6 +288,27 @@ public static IEnumerable<ITestData> GetTestDataCore()
288
288
}
289
289
""" ) ;
290
290
291
+ // Same as above with non-nullable reference type handling
292
+ yield return new TestData < PocoWithRecursiveMembers > (
293
+ Value : new ( ) { Value = 1 , Next = new ( ) { Value = 2 , Next = new ( ) { Value = 3 } } } ,
294
+ AdditionalValues : [ new ( ) { Value = 1 , Next = null } ] ,
295
+ ExpectedJsonSchema : """
296
+ {
297
+ "type": "object",
298
+ "properties": {
299
+ "Value": { "type": "integer" },
300
+ "Next": {
301
+ "type": ["object", "null"],
302
+ "properties": {
303
+ "Value": { "type": "integer" },
304
+ "Next": { "$ref": "#/properties/Next" }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ """ ,
310
+ Options : new ( ) { TreatNullObliviousAsNonNullable = true } ) ;
311
+
291
312
// Same as above but using an anchor-based reference scheme
292
313
yield return new TestData < PocoWithRecursiveMembers > (
293
314
Value : new ( ) { Value = 1 , Next = new ( ) { Value = 2 , Next = new ( ) { Value = 3 } } } ,
@@ -398,6 +419,22 @@ public static IEnumerable<ITestData> GetTestDataCore()
398
419
}
399
420
""" ) ;
400
421
422
+ // Same as above but with non-nullable reference type handling
423
+ yield return new TestData < PocoWithRecursiveCollectionElement > (
424
+ Value : new ( ) { Children = [ new ( ) , new ( ) { Children = [ ] } ] } ,
425
+ ExpectedJsonSchema : """
426
+ {
427
+ "type": "object",
428
+ "properties": {
429
+ "Children": {
430
+ "type": "array",
431
+ "items": { "$ref" : "#" }
432
+ }
433
+ }
434
+ }
435
+ """ ,
436
+ Options : new ( ) { TreatNullObliviousAsNonNullable = true } ) ;
437
+
401
438
yield return new TestData < PocoWithRecursiveDictionaryValue > (
402
439
Value : new ( ) { Children = new ( ) { [ "key1" ] = new ( ) , [ "key2" ] = new ( ) { Children = new ( ) { [ "key3" ] = new ( ) } } } } ,
403
440
ExpectedJsonSchema : """
@@ -412,6 +449,22 @@ public static IEnumerable<ITestData> GetTestDataCore()
412
449
}
413
450
""" ) ;
414
451
452
+ // Same as above but with non-nullable reference type handling
453
+ yield return new TestData < PocoWithRecursiveDictionaryValue > (
454
+ Value : new ( ) { Children = new ( ) { [ "key1" ] = new ( ) , [ "key2" ] = new ( ) { Children = new ( ) { [ "key3" ] = new ( ) } } } } ,
455
+ ExpectedJsonSchema : """
456
+ {
457
+ "type": "object",
458
+ "properties": {
459
+ "Children": {
460
+ "type": "object",
461
+ "additionalProperties": { "$ref" : "#" }
462
+ }
463
+ }
464
+ }
465
+ """ ,
466
+ Options : new ( ) { TreatNullObliviousAsNonNullable = true } ) ;
467
+
415
468
yield return new TestData < PocoWithDescription > (
416
469
Value : new ( ) { X = 42 } ,
417
470
ExpectedJsonSchema : """
@@ -1390,7 +1443,7 @@ IEnumerable<ITestData> ITestData.GetTestDataForAllValues()
1390
1443
{
1391
1444
yield return this ;
1392
1445
1393
- if ( default ( T ) is null )
1446
+ if ( default ( T ) is null && Options ? . TreatNullObliviousAsNonNullable != true )
1394
1447
{
1395
1448
yield return this with { Value = default , AdditionalValues = null } ;
1396
1449
}
0 commit comments