File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src/Microsoft.OpenApi/Services
test/Microsoft.OpenApi.Readers.Tests/V31Tests Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,10 @@ public bool Contains(string location)
376376 // Prevent infinite recursion in case of circular references
377377 if ( visitedSchemas . Contains ( schema ) )
378378 {
379- return null ;
379+ if ( schema is OpenApiSchemaReference openApiSchemaReference )
380+ throw new InvalidOperationException ( $ "Circular reference detected while resolving schema: { openApiSchemaReference . Reference . ReferenceV3 } ") ;
381+ else
382+ throw new InvalidOperationException ( $ "Circular reference detected while resolving schema") ;
380383 }
381384 visitedSchemas . Push ( schema ) ;
382385 // Traverse schema object to resolve subschemas
Original file line number Diff line number Diff line change @@ -502,9 +502,9 @@ public void ExitsEarlyOnCyclicalReferences()
502502 document . RegisterComponents ( ) ;
503503
504504 var tagsSchemaRef = Assert . IsType < OpenApiSchemaReference > ( categorySchema . Properties [ "tags" ] ) ;
505- Assert . Null ( tagsSchemaRef . Items ) ;
505+ Assert . Throws < InvalidOperationException > ( ( ) => tagsSchemaRef . Items ) ;
506506 Assert . Equal ( "#/components/schemas/Category/properties/parent/properties/tags" , tagsSchemaRef . Reference . ReferenceV3 ) ;
507- Assert . Null ( tagsSchemaRef . Target ) ;
507+ Assert . Throws < InvalidOperationException > ( ( ) => tagsSchemaRef . Target ) ;
508508
509509 var parentSchemaRef = Assert . IsType < OpenApiSchemaReference > ( categorySchema . Properties [ "parent" ] ) ;
510510 Assert . Equal ( "#/components/schemas/Category" , parentSchemaRef . Reference . ReferenceV3 ) ;
You can’t perform that action at this time.
0 commit comments