@@ -666,7 +666,7 @@ public bool AddComponent<T>(string id, T componentToRegister)
666
666
Utils . CheckArgumentNullOrEmpty ( id ) ;
667
667
Components ??= new ( ) ;
668
668
669
- static bool AddToDictionary < TValue > ( Dictionary < string , TValue > dict , string key , TValue value )
669
+ static bool AddToDictionary < TValue > ( IDictionary < string , TValue > dict , string key , TValue value )
670
670
{
671
671
#if NET5_0_OR_GREATER
672
672
return dict . TryAdd ( key , value ) ;
@@ -684,43 +684,43 @@ static bool AddToDictionary<TValue>(Dictionary<string, TValue> dict, string key,
684
684
switch ( componentToRegister )
685
685
{
686
686
case IOpenApiSchema openApiSchema :
687
- Components . Schemas ??= [ ] ;
687
+ Components . Schemas ??= new Dictionary < string , IOpenApiSchema > ( ) ;
688
688
added = AddToDictionary ( Components . Schemas , id , openApiSchema ) ;
689
689
break ;
690
690
case IOpenApiParameter openApiParameter :
691
- Components . Parameters ??= [ ] ;
691
+ Components . Parameters ??= new Dictionary < string , IOpenApiParameter > ( ) ;
692
692
added = AddToDictionary ( Components . Parameters , id , openApiParameter ) ;
693
693
break ;
694
694
case IOpenApiResponse openApiResponse :
695
- Components . Responses ??= [ ] ;
695
+ Components . Responses ??= new Dictionary < string , IOpenApiResponse > ( ) ;
696
696
added = AddToDictionary ( Components . Responses , id , openApiResponse ) ;
697
697
break ;
698
698
case IOpenApiRequestBody openApiRequestBody :
699
- Components . RequestBodies ??= [ ] ;
699
+ Components . RequestBodies ??= new Dictionary < string , IOpenApiRequestBody > ( ) ;
700
700
added = AddToDictionary ( Components . RequestBodies , id , openApiRequestBody ) ;
701
701
break ;
702
702
case IOpenApiLink openApiLink :
703
- Components . Links ??= [ ] ;
703
+ Components . Links ??= new Dictionary < string , IOpenApiLink > ( ) ;
704
704
added = AddToDictionary ( Components . Links , id , openApiLink ) ;
705
705
break ;
706
706
case IOpenApiCallback openApiCallback :
707
- Components . Callbacks ??= [ ] ;
707
+ Components . Callbacks ??= new Dictionary < string , IOpenApiCallback > ( ) ;
708
708
added = AddToDictionary ( Components . Callbacks , id , openApiCallback ) ;
709
709
break ;
710
710
case IOpenApiPathItem openApiPathItem :
711
- Components . PathItems ??= [ ] ;
711
+ Components . PathItems ??= new Dictionary < string , IOpenApiPathItem > ( ) ;
712
712
added = AddToDictionary ( Components . PathItems , id , openApiPathItem ) ;
713
713
break ;
714
714
case IOpenApiExample openApiExample :
715
- Components . Examples ??= [ ] ;
715
+ Components . Examples ??= new Dictionary < string , IOpenApiExample > ( ) ;
716
716
added = AddToDictionary ( Components . Examples , id , openApiExample ) ;
717
717
break ;
718
718
case IOpenApiHeader openApiHeader :
719
- Components . Headers ??= [ ] ;
719
+ Components . Headers ??= new Dictionary < string , IOpenApiHeader > ( ) ;
720
720
added = AddToDictionary ( Components . Headers , id , openApiHeader ) ;
721
721
break ;
722
722
case IOpenApiSecurityScheme openApiSecurityScheme :
723
- Components . SecuritySchemes ??= [ ] ;
723
+ Components . SecuritySchemes ??= new Dictionary < string , IOpenApiSecurityScheme > ( ) ;
724
724
added = AddToDictionary ( Components . SecuritySchemes , id , openApiSecurityScheme ) ;
725
725
break ;
726
726
default :
0 commit comments