@@ -15,7 +15,7 @@ namespace Microsoft.OpenApi.Models
15
15
/// <summary>
16
16
/// The Schema Object allows the definition of input and output data types.
17
17
/// </summary>
18
- public class OpenApiSchema : IOpenApiAnnotatable , IOpenApiExtensible , IOpenApiReferenceable , IOpenApiSerializable
18
+ public class OpenApiSchema : IOpenApiAnnotatable , IOpenApiExtensible , IOpenApiReferenceable
19
19
{
20
20
private JsonNode _example ;
21
21
private JsonNode _default ;
@@ -832,15 +832,9 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer,
832
832
}
833
833
else
834
834
{
835
- var list = new List < JsonSchemaType > ( ) ;
836
- foreach ( JsonSchemaType flag in jsonSchemaTypeValues )
837
- {
838
- if ( type . Value . HasFlag ( flag ) )
839
- {
840
- list . Add ( flag ) ;
841
- }
842
- }
843
-
835
+ var list = ( from JsonSchemaType flag in jsonSchemaTypeValues
836
+ where type . Value . HasFlag ( flag )
837
+ select flag ) . ToList ( ) ;
844
838
writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) => w . WriteValue ( s . ToIdentifier ( ) ) ) ;
845
839
}
846
840
}
@@ -862,16 +856,9 @@ private void UpCastSchemaTypeToV31(JsonSchemaType? type, IOpenApiWriter writer)
862
856
{
863
857
// create a new array and insert the type and "null" as values
864
858
Type = type | JsonSchemaType . Null ;
865
- var list = new List < string > ( ) ;
866
- foreach ( JsonSchemaType ? flag in jsonSchemaTypeValues )
867
- {
868
- // Check if the flag is set in 'type' using a bitwise AND operation
869
- if ( Type . Value . HasFlag ( flag ) )
870
- {
871
- list . Add ( flag . ToIdentifier ( ) ) ;
872
- }
873
- }
874
-
859
+ var list = ( from JsonSchemaType ? flag in jsonSchemaTypeValues // Check if the flag is set in 'type' using a bitwise AND operation
860
+ where Type . Value . HasFlag ( flag )
861
+ select flag . ToIdentifier ( ) ) . ToList ( ) ;
875
862
writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) => w . WriteValue ( s ) ) ;
876
863
}
877
864
0 commit comments