@@ -16,6 +16,8 @@ namespace Microsoft.OpenApi.Reader.V2
1616 /// </summary>
1717 internal static partial class OpenApiV2Deserializer
1818 {
19+ private const string EncounteredNullableExtensionTrueMetadataKey = "encounteredNullable" ;
20+
1921 private static readonly FixedFieldMap < OpenApiSchema > _openApiSchemaFixedFields = new ( )
2022 {
2123 {
@@ -228,7 +230,7 @@ internal static partial class OpenApiV2Deserializer
228230 // If, at a later point during deserialization, Type was set, we apply nullable to it.
229231 // Otherwise, we throw it away.
230232 o . Metadata ??= new Dictionary < string , object > ( ) ;
231- o . Metadata [ "encounteredNullable" ] = true ;
233+ o . Metadata [ EncounteredNullableExtensionTrueMetadataKey ] = true ;
232234 }
233235 }
234236 }
@@ -291,9 +293,9 @@ public static IOpenApiSchema LoadSchema(JsonNode node, OpenApiDocument hostDocum
291293
292294 ParseMap ( jsonObject , schema , _openApiSchemaFixedFields , _openApiSchemaPatternFields , hostDocument , context ) ;
293295
294- if ( schema . Metadata ? . TryGetValue ( "encounteredNullable" , out var value ) == true )
296+ if ( schema . Metadata ? . TryGetValue ( EncounteredNullableExtensionTrueMetadataKey , out var value ) == true )
295297 {
296- schema . Metadata . Remove ( "encounteredNullable" ) ;
298+ schema . Metadata . Remove ( EncounteredNullableExtensionTrueMetadataKey ) ;
297299 if ( schema . Type is not null && schema . Type != 0 && value is bool isNullable && isNullable )
298300 {
299301 schema . Type |= JsonSchemaType . Null ;
0 commit comments