@@ -512,7 +512,7 @@ public void GenerateSchema_SupportsOption_UseAllOfForPolymorphism()
512
512
Assert . NotNull ( schema . OneOf [ 0 ] . Reference ) ;
513
513
var baseSchema = schemaRepository . Schemas [ schema . OneOf [ 0 ] . Reference . Id ] ;
514
514
Assert . Equal ( "object" , baseSchema . Type ) ;
515
- Assert . Equal ( new [ ] { "BaseProperty" } , baseSchema . Properties . Keys ) ;
515
+ Assert . Equal ( new [ ] { "BaseProperty" } , baseSchema . Properties . Keys ) ;
516
516
// The first sub type schema
517
517
Assert . NotNull ( schema . OneOf [ 1 ] . Reference ) ;
518
518
var subType1Schema = schemaRepository . Schemas [ schema . OneOf [ 1 ] . Reference . Id ] ;
@@ -586,10 +586,34 @@ public void GenerateSchema_SupportsOption_SupportNonNullableReferenceTypes(
586
586
Assert . Equal ( expectedNullable , propertySchema . Nullable ) ;
587
587
}
588
588
589
+ [ Theory ]
590
+ [ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . NullableDictionaryWithNonNullableContent ) , true , false ) ]
591
+ [ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . NonNullableDictionaryWithNonNullableContent ) , false , false ) ]
592
+ [ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . NonNullableDictionaryWithNullableContent ) , false , true ) ]
593
+ [ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . NullableDictionaryWithNullableContent ) , true , true ) ]
594
+ public void GenerateSchema_SupportsOption_SupportNonNullableReferenceTypes_NullableAttribute_Compiler_Optimizations_Situations (
595
+ Type declaringType ,
596
+ string propertyName ,
597
+ bool expectedNullableProperty ,
598
+ bool expectedNullableContent )
599
+ {
600
+ var subject = Subject (
601
+ configureGenerator : c => c . SupportNonNullableReferenceTypes = true
602
+ ) ;
603
+ var schemaRepository = new SchemaRepository ( ) ;
604
+
605
+ var referenceSchema = subject . GenerateSchema ( declaringType , schemaRepository ) ;
606
+
607
+ var propertySchema = schemaRepository . Schemas [ referenceSchema . Reference . Id ] . Properties [ propertyName ] ;
608
+ var contentSchema = schemaRepository . Schemas [ referenceSchema . Reference . Id ] . Properties [ propertyName ] . AdditionalProperties ;
609
+ Assert . Equal ( expectedNullableProperty , propertySchema . Nullable ) ;
610
+ Assert . Equal ( expectedNullableContent , contentSchema . Nullable ) ;
611
+ }
612
+
589
613
[ Theory ]
590
614
[ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . SubTypeWithOneNullableContent ) , nameof ( TypeWithNullableContext . NullableString ) , true ) ]
591
615
[ InlineData ( typeof ( TypeWithNullableContext ) , nameof ( TypeWithNullableContext . SubTypeWithOneNonNullableContent ) , nameof ( TypeWithNullableContext . NonNullableString ) , false ) ]
592
- public void GenerateSchema_SupportsOption_SupportNonNullableReferenceTypes_NullableAttribute_Compiler_Optimizations_Situations (
616
+ public void GenerateSchema_SupportsOption_SupportNonNullableReferenceTypesInDictionary_NullableAttribute_Compiler_Optimizations_Situations (
593
617
Type declaringType ,
594
618
string subType ,
595
619
string propertyName ,
@@ -606,7 +630,6 @@ public void GenerateSchema_SupportsOption_SupportNonNullableReferenceTypes_Nulla
606
630
Assert . Equal ( expectedNullable , propertySchema . Nullable ) ;
607
631
}
608
632
609
-
610
633
[ Fact ]
611
634
public void GenerateSchema_HandlesTypesWithNestedTypes ( )
612
635
{
@@ -740,7 +763,7 @@ public void GenerateSchema_HonorsSerializerAttribute_JsonPropertyName()
740
763
var referenceSchema = Subject ( ) . GenerateSchema ( typeof ( JsonPropertyNameAnnotatedType ) , schemaRepository ) ;
741
764
742
765
var schema = schemaRepository . Schemas [ referenceSchema . Reference . Id ] ;
743
- Assert . Equal ( new [ ] { "string-with-json-property-name" } , schema . Properties . Keys . ToArray ( ) ) ;
766
+ Assert . Equal ( new [ ] { "string-with-json-property-name" } , schema . Properties . Keys . ToArray ( ) ) ;
744
767
}
745
768
746
769
[ Fact ]
0 commit comments