@@ -666,7 +666,7 @@ public bool AddComponent<T>(string id, T componentToRegister)
666666 Utils . CheckArgumentNullOrEmpty ( id ) ;
667667 Components ??= new ( ) ;
668668
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 )
670670 {
671671#if NET5_0_OR_GREATER
672672 return dict . TryAdd ( key , value ) ;
@@ -684,43 +684,43 @@ static bool AddToDictionary<TValue>(Dictionary<string, TValue> dict, string key,
684684 switch ( componentToRegister )
685685 {
686686 case IOpenApiSchema openApiSchema :
687- Components . Schemas ??= [ ] ;
687+ Components . Schemas ??= new Dictionary < string , IOpenApiSchema > ( ) ;
688688 added = AddToDictionary ( Components . Schemas , id , openApiSchema ) ;
689689 break ;
690690 case IOpenApiParameter openApiParameter :
691- Components . Parameters ??= [ ] ;
691+ Components . Parameters ??= new Dictionary < string , IOpenApiParameter > ( ) ;
692692 added = AddToDictionary ( Components . Parameters , id , openApiParameter ) ;
693693 break ;
694694 case IOpenApiResponse openApiResponse :
695- Components . Responses ??= [ ] ;
695+ Components . Responses ??= new Dictionary < string , IOpenApiResponse > ( ) ;
696696 added = AddToDictionary ( Components . Responses , id , openApiResponse ) ;
697697 break ;
698698 case IOpenApiRequestBody openApiRequestBody :
699- Components . RequestBodies ??= [ ] ;
699+ Components . RequestBodies ??= new Dictionary < string , IOpenApiRequestBody > ( ) ;
700700 added = AddToDictionary ( Components . RequestBodies , id , openApiRequestBody ) ;
701701 break ;
702702 case IOpenApiLink openApiLink :
703- Components . Links ??= [ ] ;
703+ Components . Links ??= new Dictionary < string , IOpenApiLink > ( ) ;
704704 added = AddToDictionary ( Components . Links , id , openApiLink ) ;
705705 break ;
706706 case IOpenApiCallback openApiCallback :
707- Components . Callbacks ??= [ ] ;
707+ Components . Callbacks ??= new Dictionary < string , IOpenApiCallback > ( ) ;
708708 added = AddToDictionary ( Components . Callbacks , id , openApiCallback ) ;
709709 break ;
710710 case IOpenApiPathItem openApiPathItem :
711- Components . PathItems ??= [ ] ;
711+ Components . PathItems ??= new Dictionary < string , IOpenApiPathItem > ( ) ;
712712 added = AddToDictionary ( Components . PathItems , id , openApiPathItem ) ;
713713 break ;
714714 case IOpenApiExample openApiExample :
715- Components . Examples ??= [ ] ;
715+ Components . Examples ??= new Dictionary < string , IOpenApiExample > ( ) ;
716716 added = AddToDictionary ( Components . Examples , id , openApiExample ) ;
717717 break ;
718718 case IOpenApiHeader openApiHeader :
719- Components . Headers ??= [ ] ;
719+ Components . Headers ??= new Dictionary < string , IOpenApiHeader > ( ) ;
720720 added = AddToDictionary ( Components . Headers , id , openApiHeader ) ;
721721 break ;
722722 case IOpenApiSecurityScheme openApiSecurityScheme :
723- Components . SecuritySchemes ??= [ ] ;
723+ Components . SecuritySchemes ??= new Dictionary < string , IOpenApiSecurityScheme > ( ) ;
724724 added = AddToDictionary ( Components . SecuritySchemes , id , openApiSecurityScheme ) ;
725725 break ;
726726 default :
0 commit comments