File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
src/Microsoft.OpenApi/Models Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -442,13 +442,25 @@ internal void SerializeAsV2(
442
442
throw Error . ArgumentNull ( nameof ( writer ) ) ;
443
443
}
444
444
445
-
446
- if ( Reference != null && writer . GetSettings ( ) . ReferenceInline != ReferenceInlineSetting . InlineLocalReferences )
445
+ if ( Reference != null )
447
446
{
448
- Reference . SerializeAsV2 ( writer ) ;
449
- return ;
447
+ var settings = writer . GetSettings ( ) ;
448
+ if ( settings . ReferenceInline != ReferenceInlineSetting . InlineLocalReferences )
449
+ {
450
+ Reference . SerializeAsV2 ( writer ) ;
451
+ return ;
452
+ }
453
+
454
+ // If Loop is detected then just Serialize as a reference.
455
+ if ( ! settings . LoopDetector . PushLoop < OpenApiSchema > ( this ) )
456
+ {
457
+ settings . LoopDetector . SaveLoop ( this ) ;
458
+ Reference . SerializeAsV3 ( writer ) ;
459
+ return ;
460
+ }
450
461
}
451
462
463
+
452
464
if ( parentRequiredProperties == null )
453
465
{
454
466
parentRequiredProperties = new HashSet < string > ( ) ;
You can’t perform that action at this time.
0 commit comments