@@ -464,10 +464,10 @@ private JsonNode CreateSchema(OpenApiSchemaKey key)
464464
465465 private static JsonNode ResolveReferences ( JsonNode node , JsonNode rootSchema )
466466 {
467- return ResolveReferencesRecursive ( node , rootSchema , [ ] ) ;
467+ return ResolveReferencesRecursive ( node , rootSchema ) ;
468468 }
469469
470- private static JsonNode ResolveReferencesRecursive ( JsonNode node , JsonNode rootSchema , HashSet < string > visitedRefs )
470+ private static JsonNode ResolveReferencesRecursive ( JsonNode node , JsonNode rootSchema )
471471 {
472472 if ( node is JsonObject jsonObject )
473473 {
@@ -476,13 +476,6 @@ refNode is JsonValue refValue &&
476476 refValue . TryGetValue < string > ( out var refString ) &&
477477 refString . StartsWith ( OpenApiConstants . RefPrefix , StringComparison . Ordinal ) )
478478 {
479- if ( visitedRefs . Contains ( refString ) )
480- {
481- return node ;
482- }
483-
484- visitedRefs . Add ( refString ) ;
485-
486479 try
487480 {
488481 // Resolve the reference path to the actual schema content
@@ -498,11 +491,6 @@ refNode is JsonValue refValue &&
498491 // If resolution fails due to invalid path, return the original reference
499492 // This maintains backward compatibility while preventing crashes
500493 }
501- finally
502- {
503- // Remove from visited set to allow the same reference in different branches
504- visitedRefs . Remove ( refString ) ;
505- }
506494
507495 // If resolution fails, return the original reference
508496 return node ;
@@ -514,7 +502,7 @@ refNode is JsonValue refValue &&
514502 {
515503 if ( property . Value != null )
516504 {
517- var processedValue = ResolveReferencesRecursive ( property . Value , rootSchema , visitedRefs ) ;
505+ var processedValue = ResolveReferencesRecursive ( property . Value , rootSchema ) ;
518506 newObject [ property . Key ] = processedValue ? . DeepClone ( ) ;
519507 }
520508 else
@@ -531,7 +519,7 @@ refNode is JsonValue refValue &&
531519 {
532520 if ( jsonArray [ i ] != null )
533521 {
534- var processedValue = ResolveReferencesRecursive ( jsonArray [ i ] ! , rootSchema , visitedRefs ) ;
522+ var processedValue = ResolveReferencesRecursive ( jsonArray [ i ] ! , rootSchema ) ;
535523 newArray . Add ( processedValue ? . DeepClone ( ) ) ;
536524 }
537525 else
0 commit comments