@@ -172,64 +172,20 @@ public decimal? Minimum
172172 /// <inheritdoc />
173173 public bool WriteOnly { get ; set ; }
174174
175- private IList < IOpenApiSchema > ? _allOf ;
176175 /// <inheritdoc />
177- public IList < IOpenApiSchema > ? AllOf
178- {
179- get => _allOf ??= [ ] ;
180- set => _allOf = value ;
181- }
182-
183- private IList < IOpenApiSchema > ? _oneOf ;
184- private bool _isExplicitlyNull ;
176+ public IList < IOpenApiSchema > ? AllOf { get ; set ; }
185177
186178 /// <inheritdoc />
187- public IList < IOpenApiSchema > ? OneOf
188- {
189- get
190- {
191- if ( _isExplicitlyNull )
192- {
193- return null ;
194- }
195- return _oneOf ??= [ ] ;
196- }
197- set
198- {
199- _oneOf = value ;
200- _isExplicitlyNull = value is null ;
201- }
202- }
179+ public IList < IOpenApiSchema > ? OneOf { get ; set ; }
203180
204- private IList < IOpenApiSchema > ? _anyOf ;
205181 /// <inheritdoc />
206- public IList < IOpenApiSchema > ? AnyOf
207- {
208- get
209- {
210- if ( _isExplicitlyNull )
211- {
212- return null ;
213- }
214- return _anyOf ??= [ ] ;
215- }
216- set
217- {
218- _anyOf = value ;
219- _isExplicitlyNull = value is null ;
220- }
221- }
182+ public IList < IOpenApiSchema > ? AnyOf { get ; set ; }
222183
223184 /// <inheritdoc />
224185 public IOpenApiSchema ? Not { get ; set ; }
225186
226- private ISet < string > ? _required ;
227187 /// <inheritdoc />
228- public ISet < string > ? Required
229- {
230- get => _required ??= new HashSet < string > ( ) ;
231- set => _required = value ;
232- }
188+ public ISet < string > ? Required { get ; set ; }
233189
234190 /// <inheritdoc />
235191 public IOpenApiSchema ? Items { get ; set ; }
@@ -243,21 +199,11 @@ public ISet<string>? Required
243199 /// <inheritdoc />
244200 public bool ? UniqueItems { get ; set ; }
245201
246- private IDictionary < string , IOpenApiSchema > ? _properties ;
247202 /// <inheritdoc />
248- public IDictionary < string , IOpenApiSchema > ? Properties
249- {
250- get => _properties ??= new Dictionary < string , IOpenApiSchema > ( StringComparer . Ordinal ) ;
251- set => _properties = value ;
252- }
203+ public IDictionary < string , IOpenApiSchema > ? Properties { get ; set ; }
253204
254- private IDictionary < string , IOpenApiSchema > ? _patternProperties ;
255205 /// <inheritdoc />
256- public IDictionary < string , IOpenApiSchema > ? PatternProperties
257- {
258- get => _patternProperties ??= new Dictionary < string , IOpenApiSchema > ( StringComparer . Ordinal ) ;
259- set => _patternProperties = value ;
260- }
206+ public IDictionary < string , IOpenApiSchema > ? PatternProperties { get ; set ; }
261207
262208 /// <inheritdoc />
263209 public int ? MaxProperties { get ; set ; }
@@ -280,16 +226,11 @@ public IDictionary<string, IOpenApiSchema>? PatternProperties
280226 /// <inheritdoc />
281227 public IList < JsonNode > ? Examples { get ; set ; }
282228
283- private IList < JsonNode > ? _enum ;
284229 /// <inheritdoc />
285- public IList < JsonNode > ? Enum
286- {
287- get => _enum ??= new List < JsonNode > ( ) ;
288- set => _enum = value ;
289- }
230+ public IList < JsonNode > ? Enum { get ; set ; }
290231
291232 /// <inheritdoc />
292- public bool UnevaluatedProperties { get ; set ; }
233+ public bool UnevaluatedProperties { get ; set ; }
293234
294235 /// <inheritdoc />
295236 public OpenApiExternalDocs ? ExternalDocs { get ; set ; }
@@ -300,32 +241,17 @@ public IList<JsonNode>? Enum
300241 /// <inheritdoc />
301242 public OpenApiXml ? Xml { get ; set ; }
302243
303- private IDictionary < string , IOpenApiExtension > ? _extensions ;
304244 /// <inheritdoc />
305- public IDictionary < string , IOpenApiExtension > ? Extensions
306- {
307- get => _extensions ??= new Dictionary < string , IOpenApiExtension > ( StringComparer . Ordinal ) ;
308- set => _extensions = value ;
309- }
245+ public IDictionary < string , IOpenApiExtension > ? Extensions { get ; set ; }
310246
311- private IDictionary < string , JsonNode > ? _unrecognizedKeywords ;
312247 /// <inheritdoc />
313- public IDictionary < string , JsonNode > ? UnrecognizedKeywords
314- {
315- get => _unrecognizedKeywords ??= new Dictionary < string , JsonNode > ( StringComparer . Ordinal ) ;
316- set => _unrecognizedKeywords = value ;
317- }
248+ public IDictionary < string , JsonNode > ? UnrecognizedKeywords { get ; set ; }
318249
319250 /// <inheritdoc />
320251 public IDictionary < string , object > ? Annotations { get ; set ; }
321252
322- private IDictionary < string , ISet < string > > ? _dependentRequired ;
323253 /// <inheritdoc />
324- public IDictionary < string , ISet < string > > ? DependentRequired
325- {
326- get => _dependentRequired ??= new Dictionary < string , ISet < string > > ( StringComparer . Ordinal ) ;
327- set => _dependentRequired = value ;
328- }
254+ public IDictionary < string , ISet < string > > ? DependentRequired { get ; set ; }
329255
330256 /// <summary>
331257 /// Parameterless constructor
@@ -383,7 +309,7 @@ internal OpenApiSchema(IOpenApiSchema schema)
383309 MinProperties = schema . MinProperties ?? MinProperties ;
384310 AdditionalPropertiesAllowed = schema . AdditionalPropertiesAllowed ;
385311 AdditionalProperties = schema . AdditionalProperties ? . CreateShallowCopy ( ) ;
386- Discriminator = schema . Discriminator != null ? new ( schema . Discriminator ) : null ;
312+ Discriminator = schema . Discriminator != null ? new ( schema . Discriminator ) : null ;
387313 Example = schema . Example != null ? JsonNodeCloneHelper . Clone ( schema . Example ) : null ;
388314 Examples = schema . Examples != null ? new List < JsonNode > ( schema . Examples ) : null ;
389315 Enum = schema . Enum != null ? new List < JsonNode > ( schema . Enum ) : null ;
@@ -495,7 +421,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
495421 writer . WriteProperty ( OpenApiConstants . MinProperties , MinProperties ) ;
496422
497423 // required
498- writer . WriteOptionalCollection ( OpenApiConstants . Required , Required , ( w , s ) =>
424+ writer . WriteOptionalCollection ( OpenApiConstants . Required , Required , ( w , s ) =>
499425 {
500426 if ( ! string . IsNullOrEmpty ( s ) && s is not null )
501427 {
@@ -576,7 +502,7 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
576502 // Unrecognized keywords
577503 if ( UnrecognizedKeywords is not null && UnrecognizedKeywords . Any ( ) )
578504 {
579- writer . WriteOptionalMap ( OpenApiConstants . UnrecognizedKeywords , UnrecognizedKeywords , ( w , s ) => w . WriteAny ( s ) ) ;
505+ writer . WriteOptionalMap ( OpenApiConstants . UnrecognizedKeywords , UnrecognizedKeywords , ( w , s ) => w . WriteAny ( s ) ) ;
580506 }
581507
582508 writer . WriteEndObject ( ) ;
@@ -739,7 +665,7 @@ private void SerializeAsV2(
739665 writer . WriteProperty ( OpenApiConstants . MinProperties , MinProperties ) ;
740666
741667 // required
742- writer . WriteOptionalCollection ( OpenApiConstants . Required , Required , ( w , s ) =>
668+ writer . WriteOptionalCollection ( OpenApiConstants . Required , Required , ( w , s ) =>
743669 {
744670 if ( ! string . IsNullOrEmpty ( s ) && s is not null )
745671 {
@@ -823,7 +749,7 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer,
823749 // check whether nullable is true for upcasting purposes
824750 var isNullable = ( Type . HasValue && Type . Value . HasFlag ( JsonSchemaType . Null ) ) ||
825751 Extensions is not null &&
826- Extensions . TryGetValue ( OpenApiConstants . NullableExtension , out var nullExtRawValue ) &&
752+ Extensions . TryGetValue ( OpenApiConstants . NullableExtension , out var nullExtRawValue ) &&
827753 nullExtRawValue is OpenApiAny { Node : JsonNode jsonNode } &&
828754 jsonNode . GetValueKind ( ) is JsonValueKind . True ;
829755 if ( type is null )
@@ -835,7 +761,7 @@ Extensions is not null &&
835761 }
836762 else if ( ! HasMultipleTypes ( type . Value ) )
837763 {
838-
764+
839765 switch ( version )
840766 {
841767 case OpenApiSpecVersion . OpenApi3_1 when isNullable :
@@ -868,13 +794,13 @@ where type.Value.HasFlag(flag)
868794 select flag ) . ToList ( ) ;
869795 writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) =>
870796 {
871- foreach ( var item in s . ToIdentifiers ( ) )
797+ foreach ( var item in s . ToIdentifiers ( ) )
872798 {
873799 w . WriteValue ( item ) ;
874800 }
875801 } ) ;
876802 }
877- }
803+ }
878804 }
879805
880806 private static bool IsPowerOfTwo ( int x )
@@ -898,7 +824,7 @@ where temporaryType.HasFlag(flag)
898824 select flag . ToFirstIdentifier ( ) ) . ToList ( ) ;
899825 if ( list . Count > 1 )
900826 {
901- writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) =>
827+ writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) =>
902828 {
903829 if ( ! string . IsNullOrEmpty ( s ) && s is not null )
904830 {
0 commit comments