@@ -560,14 +560,7 @@ internal void WriteAsItemsProperties(IOpenApiWriter writer)
560560 writer . WriteProperty ( OpenApiConstants . Type , Type ) ;
561561
562562 // format
563- if ( string . IsNullOrEmpty ( Format ) )
564- {
565- Format = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
566- AnyOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
567- OneOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ;
568- }
569-
570- writer . WriteProperty ( OpenApiConstants . Format , Format ) ;
563+ WriteFormatProperty ( writer ) ;
571564
572565 // items
573566 writer . WriteOptionalObject ( OpenApiConstants . Items , Items , ( w , s ) => s . SerializeAsV2 ( w ) ) ;
@@ -620,20 +613,26 @@ internal void WriteAsItemsProperties(IOpenApiWriter writer)
620613 writer . WriteExtensions ( Extensions , OpenApiSpecVersion . OpenApi2_0 ) ;
621614 }
622615
623- internal void WriteAsSchemaProperties (
624- IOpenApiWriter writer ,
625- ISet < string > parentRequiredProperties ,
626- string propertyName )
616+ private void WriteFormatProperty ( IOpenApiWriter writer )
627617 {
628- // format
629- if ( string . IsNullOrEmpty ( Format ) )
618+ var formatToWrite = Format ;
619+ if ( string . IsNullOrEmpty ( formatToWrite ) )
630620 {
631- Format = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
621+ formatToWrite = AllOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
632622 AnyOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ??
633623 OneOf ? . FirstOrDefault ( static x => ! string . IsNullOrEmpty ( x . Format ) ) ? . Format ;
634624 }
635625
636- writer . WriteProperty ( OpenApiConstants . Format , Format ) ;
626+ writer . WriteProperty ( OpenApiConstants . Format , formatToWrite ) ;
627+ }
628+
629+ internal void WriteAsSchemaProperties (
630+ IOpenApiWriter writer ,
631+ ISet < string > parentRequiredProperties ,
632+ string propertyName )
633+ {
634+ // format
635+ WriteFormatProperty ( writer ) ;
637636
638637 // title
639638 writer . WriteProperty ( OpenApiConstants . Title , Title ) ;
0 commit comments