@@ -1122,6 +1122,38 @@ await VerifyOpenApiDocument(builder, document =>
11221122 } ) ;
11231123 }
11241124
1125+ // Test for: https://github.com/dotnet/aspnetcore/issues/64048
1126+ public static object [ ] [ ] CircularReferencesWithArraysHandlers =>
1127+ [
1128+ [ ( CircularReferenceWithArrayRootOrderArrayFirst dto ) => { } ] ,
1129+ [ ( CircularReferenceWithArrayRootOrderArrayLast dto ) => { } ] ,
1130+ ] ;
1131+
1132+ [ Theory ]
1133+ [ MemberData ( nameof ( CircularReferencesWithArraysHandlers ) ) ]
1134+ public async Task HandlesCircularReferencesWithArraysRegardlessOfPropertyOrder ( Delegate requestHandler )
1135+ {
1136+ var builder = CreateBuilder ( ) ;
1137+ builder . MapPost ( "/" , requestHandler ) ;
1138+
1139+ await VerifyOpenApiDocument ( builder , ( OpenApiDocument document ) =>
1140+ {
1141+ Assert . NotNull ( document . Components ? . Schemas ) ;
1142+ var schema = document . Components . Schemas [ "CircularReferenceWithArrayModel" ] ;
1143+ Assert . Equal ( JsonSchemaType . Object , schema . Type ) ;
1144+ Assert . NotNull ( schema . Properties ) ;
1145+ Assert . Collection ( schema . Properties ,
1146+ property =>
1147+ {
1148+ Assert . Equal ( "selfArray" , property . Key ) ;
1149+ var arraySchema = Assert . IsType < OpenApiSchema > ( property . Value ) ;
1150+ Assert . Equal ( JsonSchemaType . Array , arraySchema . Type ) ;
1151+ var itemReference = Assert . IsType < OpenApiSchemaReference > ( arraySchema . Items ) ;
1152+ Assert . Equal ( "#/components/schemas/CircularReferenceWithArrayModel" , itemReference . Reference . ReferenceV3 ) ;
1153+ } ) ;
1154+ } ) ;
1155+ }
1156+
11251157 // Test models for issue 61194
11261158 private class Config
11271159 {
@@ -1203,5 +1235,23 @@ private class ReferencedModel
12031235 {
12041236 public int Id { get ; set ; }
12051237 }
1238+
1239+ // Test models for issue 64048
1240+ public class CircularReferenceWithArrayRootOrderArrayLast
1241+ {
1242+ public CircularReferenceWithArrayModel Item { get ; set ; }
1243+ public ICollection < CircularReferenceWithArrayModel > ItemArray { get ; set ; }
1244+ }
1245+
1246+ public class CircularReferenceWithArrayRootOrderArrayFirst
1247+ {
1248+ public ICollection < CircularReferenceWithArrayModel > ItemArray { get ; set ; }
1249+ public CircularReferenceWithArrayModel Item { get ; set ; }
1250+ }
1251+
1252+ public class CircularReferenceWithArrayModel
1253+ {
1254+ public ICollection < CircularReferenceWithArrayModel > SelfArray { get ; set ; }
1255+ }
12061256}
12071257#nullable restore
0 commit comments