1
- // Copyright (c) Microsoft Corporation. All rights reserved.
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
4
using System . Collections . Generic ;
@@ -630,6 +630,10 @@ internal void WriteAsSchemaProperties(
630
630
}
631
631
632
632
// format
633
+ Format ??= AllOf ? . FirstOrDefault ( x => x . Format != null ) ? . Format ??
634
+ AnyOf ? . FirstOrDefault ( x => x . Format != null ) ? . Format ??
635
+ OneOf ? . FirstOrDefault ( x => x . Format != null ) ? . Format ;
636
+
633
637
writer . WriteProperty ( OpenApiConstants . Format , Format ) ;
634
638
635
639
// title
@@ -695,7 +699,7 @@ internal void WriteAsSchemaProperties(
695
699
// allOf
696
700
writer . WriteOptionalCollection ( OpenApiConstants . AllOf , AllOf , ( w , s ) => s . SerializeAsV2 ( w ) ) ;
697
701
698
- // If there isn't already an AllOf , and the schema contains a oneOf or anyOf write an allOf with the first
702
+ // If there isn't already an allOf , and the schema contains a oneOf or anyOf write an allOf with the first
699
703
// schema in the list as an attempt to guess at a graceful downgrade situation.
700
704
if ( AllOf == null || AllOf . Count == 0 )
701
705
{
@@ -707,12 +711,6 @@ internal void WriteAsSchemaProperties(
707
711
// oneOf (Not Supported in V2) - Write the first schema only as an allOf.
708
712
writer . WriteOptionalCollection ( OpenApiConstants . AllOf , OneOf ? . Take ( 1 ) , ( w , s ) => s . SerializeAsV2 ( w ) ) ;
709
713
}
710
- if ( OneOf ? . Count > 0 )
711
- {
712
- // Take the format and set it at the root
713
- var oneOfFormat = OneOf . Select < OpenApiSchema , string > ( x => x . Format . ToString ( ) ) . FirstOrDefault ( ) ;
714
- this . Format = oneOfFormat ;
715
- }
716
714
}
717
715
718
716
// properties
0 commit comments