@@ -89,9 +89,9 @@ private void AddSchemaToComponents(IOpenApiSchema? schema, string? referenceId =
89
89
{
90
90
EnsureComponentsExist ( ) ;
91
91
EnsureSchemasExist ( ) ;
92
- Components . Schemas ??= new Dictionary < string , IOpenApiSchema > ( ) ;
93
- if ( referenceId is not null && schema is not null && ! Components . Schemas . ContainsKey ( referenceId ) )
92
+ if ( referenceId is not null && schema is not null && ! ( Components . Schemas ? . ContainsKey ( referenceId ) ?? false ) )
94
93
{
94
+ Components . Schemas ??= new Dictionary < string , IOpenApiSchema > ( ) ;
95
95
Components . Schemas . Add ( referenceId , schema ) ;
96
96
}
97
97
}
@@ -100,9 +100,9 @@ private void AddParameterToComponents(IOpenApiParameter? parameter, string? refe
100
100
{
101
101
EnsureComponentsExist ( ) ;
102
102
EnsureParametersExist ( ) ;
103
- Components . Parameters ??= new Dictionary < string , IOpenApiParameter > ( ) ;
104
- if ( parameter is not null && referenceId is not null && ! Components . Parameters . ContainsKey ( referenceId ) )
103
+ if ( parameter is not null && referenceId is not null && ! ( Components . Parameters ? . ContainsKey ( referenceId ) ?? false ) )
105
104
{
105
+ Components . Parameters ??= new Dictionary < string , IOpenApiParameter > ( ) ;
106
106
Components . Parameters . Add ( referenceId , parameter ) ;
107
107
}
108
108
}
@@ -111,79 +111,79 @@ private void AddResponseToComponents(IOpenApiResponse? response, string? referen
111
111
{
112
112
EnsureComponentsExist ( ) ;
113
113
EnsureResponsesExist ( ) ;
114
- Components . Responses ??= new Dictionary < string , IOpenApiResponse > ( ) ;
115
- if ( referenceId is not null && response is not null && ! Components . Responses . ContainsKey ( referenceId ) )
114
+ if ( referenceId is not null && response is not null && ! ( Components . Responses ? . ContainsKey ( referenceId ) ?? false ) )
116
115
{
116
+ Components . Responses ??= new Dictionary < string , IOpenApiResponse > ( ) ;
117
117
Components . Responses . Add ( referenceId , response ) ;
118
118
}
119
119
}
120
120
private void AddRequestBodyToComponents ( IOpenApiRequestBody ? requestBody , string ? referenceId = null )
121
121
{
122
122
EnsureComponentsExist ( ) ;
123
123
EnsureRequestBodiesExist ( ) ;
124
- Components . RequestBodies ??= new Dictionary < string , IOpenApiRequestBody > ( ) ;
125
- if ( requestBody is not null && referenceId is not null && ! Components . RequestBodies . ContainsKey ( referenceId ) )
124
+ if ( requestBody is not null && referenceId is not null && ! ( Components . RequestBodies ? . ContainsKey ( referenceId ) ?? false ) )
126
125
{
126
+ Components . RequestBodies ??= new Dictionary < string , IOpenApiRequestBody > ( ) ;
127
127
Components . RequestBodies . Add ( referenceId , requestBody ) ;
128
128
}
129
129
}
130
130
private void AddLinkToComponents ( IOpenApiLink ? link , string ? referenceId = null )
131
131
{
132
132
EnsureComponentsExist ( ) ;
133
133
EnsureLinksExist ( ) ;
134
- Components . Links ??= new Dictionary < string , IOpenApiLink > ( ) ;
135
- if ( link is not null && referenceId is not null && ! Components . Links . ContainsKey ( referenceId ) )
134
+ if ( link is not null && referenceId is not null && ! ( Components . Links ? . ContainsKey ( referenceId ) ?? false ) )
136
135
{
136
+ Components . Links ??= new Dictionary < string , IOpenApiLink > ( ) ;
137
137
Components . Links . Add ( referenceId , link ) ;
138
138
}
139
139
}
140
140
private void AddCallbackToComponents ( IOpenApiCallback ? callback , string ? referenceId = null )
141
141
{
142
142
EnsureComponentsExist ( ) ;
143
143
EnsureCallbacksExist ( ) ;
144
- Components . Callbacks ??= new Dictionary < string , IOpenApiCallback > ( ) ;
145
- if ( callback is not null && referenceId is not null && ! Components . Callbacks . ContainsKey ( referenceId ) )
144
+ if ( callback is not null && referenceId is not null && ! ( Components . Callbacks ? . ContainsKey ( referenceId ) ?? false ) )
146
145
{
146
+ Components . Callbacks ??= new Dictionary < string , IOpenApiCallback > ( ) ;
147
147
Components . Callbacks . Add ( referenceId , callback ) ;
148
148
}
149
149
}
150
150
private void AddHeaderToComponents ( IOpenApiHeader ? header , string ? referenceId = null )
151
151
{
152
152
EnsureComponentsExist ( ) ;
153
153
EnsureHeadersExist ( ) ;
154
- Components . Headers ??= new Dictionary < string , IOpenApiHeader > ( ) ;
155
- if ( header is not null && referenceId is not null && ! Components . Headers . ContainsKey ( referenceId ) )
154
+ if ( header is not null && referenceId is not null && ! ( Components . Headers ? . ContainsKey ( referenceId ) ?? false ) )
156
155
{
156
+ Components . Headers ??= new Dictionary < string , IOpenApiHeader > ( ) ;
157
157
Components . Headers . Add ( referenceId , header ) ;
158
158
}
159
159
}
160
160
private void AddExampleToComponents ( IOpenApiExample ? example , string ? referenceId = null )
161
161
{
162
162
EnsureComponentsExist ( ) ;
163
163
EnsureExamplesExist ( ) ;
164
- Components . Examples ??= new Dictionary < string , IOpenApiExample > ( ) ;
165
- if ( example is not null && referenceId is not null && ! Components . Examples . ContainsKey ( referenceId ) )
164
+ if ( example is not null && referenceId is not null && ! ( Components . Examples ? . ContainsKey ( referenceId ) ?? false ) )
166
165
{
166
+ Components . Examples ??= new Dictionary < string , IOpenApiExample > ( ) ;
167
167
Components . Examples . Add ( referenceId , example ) ;
168
168
}
169
169
}
170
170
private void AddPathItemToComponents ( IOpenApiPathItem ? pathItem , string ? referenceId = null )
171
171
{
172
172
EnsureComponentsExist ( ) ;
173
173
EnsurePathItemsExist ( ) ;
174
- Components . PathItems ??= new Dictionary < string , IOpenApiPathItem > ( ) ;
175
- if ( pathItem is not null && referenceId is not null && ! Components . PathItems . ContainsKey ( referenceId ) )
174
+ if ( pathItem is not null && referenceId is not null && ! ( Components . PathItems ? . ContainsKey ( referenceId ) ?? false ) )
176
175
{
176
+ Components . PathItems ??= new Dictionary < string , IOpenApiPathItem > ( ) ;
177
177
Components . PathItems . Add ( referenceId , pathItem ) ;
178
178
}
179
179
}
180
180
private void AddSecuritySchemeToComponents ( IOpenApiSecurityScheme ? securityScheme , string ? referenceId = null )
181
181
{
182
182
EnsureComponentsExist ( ) ;
183
183
EnsureSecuritySchemesExist ( ) ;
184
- Components . SecuritySchemes ??= new Dictionary < string , IOpenApiSecurityScheme > ( ) ;
185
- if ( securityScheme is not null && referenceId is not null && ! Components . SecuritySchemes . ContainsKey ( referenceId ) )
184
+ if ( securityScheme is not null && referenceId is not null && ! ( Components . SecuritySchemes ? . ContainsKey ( referenceId ) ?? false ) )
186
185
{
186
+ Components . SecuritySchemes ??= new Dictionary < string , IOpenApiSecurityScheme > ( ) ;
187
187
Components . SecuritySchemes . Add ( referenceId , securityScheme ) ;
188
188
}
189
189
}
0 commit comments