@@ -15,7 +15,7 @@ namespace Microsoft.OpenApi.Models
1515 /// <summary>
1616 /// The Schema Object allows the definition of input and output data types.
1717 /// </summary>
18- public class OpenApiSchema : IOpenApiAnnotatable , IOpenApiExtensible , IOpenApiReferenceable , IOpenApiSerializable
18+ public class OpenApiSchema : IOpenApiAnnotatable , IOpenApiExtensible , IOpenApiReferenceable
1919 {
2020 private JsonNode _example ;
2121 private JsonNode _default ;
@@ -832,15 +832,9 @@ private void SerializeTypeProperty(JsonSchemaType? type, IOpenApiWriter writer,
832832 }
833833 else
834834 {
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 ( ) ;
844838 writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) => w . WriteValue ( s . ToIdentifier ( ) ) ) ;
845839 }
846840 }
@@ -862,16 +856,9 @@ private void UpCastSchemaTypeToV31(JsonSchemaType? type, IOpenApiWriter writer)
862856 {
863857 // create a new array and insert the type and "null" as values
864858 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 ( ) ;
875862 writer . WriteOptionalCollection ( OpenApiConstants . Type , list , ( w , s ) => w . WriteValue ( s ) ) ;
876863 }
877864
0 commit comments