@@ -583,14 +583,7 @@ internal void WriteAsItemsProperties(IOpenApiWriter writer)
583
583
writer . WriteProperty ( OpenApiConstants . Type , Type . ToIdentifier ( ) ) ;
584
584
585
585
// format
586
- if ( string . IsNullOrEmpty ( Format ) )
587
- {
588
- Format = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
589
- AnyOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
590
- OneOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ;
591
- }
592
-
593
- writer . WriteProperty ( OpenApiConstants . Format , Format ) ;
586
+ WriteFormatProperty ( writer ) ;
594
587
595
588
// items
596
589
writer . WriteOptionalObject ( OpenApiConstants . Items , Items , ( w , s ) => s . SerializeAsV2 ( w ) ) ;
@@ -643,6 +636,19 @@ internal void WriteAsItemsProperties(IOpenApiWriter writer)
643
636
writer . WriteExtensions ( Extensions , OpenApiSpecVersion . OpenApi2_0 ) ;
644
637
}
645
638
639
+ private void WriteFormatProperty ( IOpenApiWriter writer )
640
+ {
641
+ var formatToWrite = Format ;
642
+ if ( string . IsNullOrEmpty ( formatToWrite ) )
643
+ {
644
+ formatToWrite = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
645
+ AnyOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
646
+ OneOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ;
647
+ }
648
+
649
+ writer . WriteProperty ( OpenApiConstants . Format , formatToWrite ) ;
650
+ }
651
+
646
652
/// <summary>
647
653
/// Serialize <see cref="OpenApiSchema"/> to Open Api v2.0 and handles not marking the provided property
648
654
/// as readonly if its included in the provided list of required properties of parent schema.
@@ -666,14 +672,7 @@ internal virtual void SerializeAsV2(
666
672
writer . WriteProperty ( OpenApiConstants . Description , Description ) ;
667
673
668
674
// format
669
- if ( string . IsNullOrEmpty ( Format ) )
670
- {
671
- Format = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
672
- AnyOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
673
- OneOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ;
674
- }
675
-
676
- writer . WriteProperty ( OpenApiConstants . Format , Format ) ;
675
+ WriteFormatProperty ( writer ) ;
677
676
678
677
// title
679
678
writer . WriteProperty ( OpenApiConstants . Title , Title ) ;
0 commit comments