@@ -74,7 +74,7 @@ static Optional<String> getDiscriminatorPropertyTypeFromChildren(OpenAPI openAPI
7474 if (resolved == null ) {
7575 continue ;
7676 }
77- Schema discSchema = getDiscriminatorSchemaDeep (openAPI , resolved , discriminatorPropertyName );
77+ Schema discSchema = getDiscriminatorSchemaDeep (openAPI , resolved , discriminatorPropertyName , new ArrayList <>() );
7878 if (discSchema != null && discSchema .get$ref () != null ) {
7979 return Optional .ofNullable (ModelUtils .getSimpleRef (discSchema .get$ref ()));
8080 }
@@ -90,16 +90,10 @@ static Optional<String> getDiscriminatorPropertyTypeFromChildren(OpenAPI openAPI
9090 * @param openAPI the OpenAPI specification, used to resolve referenced allOf members.
9191 * @param schema The schema to inspect.
9292 * @param discriminatorName The name of the discriminator property.
93+ * @param visited A list of schemas already visited in the recursion, to avoid infinite loops.
94+ * @return The discriminator property schema, or null if not found.
9395 */
94- static Schema getDiscriminatorSchemaDeep (OpenAPI openAPI , Schema schema , String discriminatorName ) {
95- return getDiscriminatorSchemaDeep (openAPI , schema , discriminatorName , new ArrayList <>());
96- }
97-
98- /**
99- * @param visited the schemas already visited on the current allOf descent, used to guard against a
100- * cyclic allOf composition recursing infinitely.
101- */
102- private static Schema getDiscriminatorSchemaDeep (OpenAPI openAPI , Schema schema , String discriminatorName , ArrayList <Schema > visited ) {
96+ static Schema getDiscriminatorSchemaDeep (OpenAPI openAPI , Schema schema , String discriminatorName , List <Schema > visited ) {
10397 for (Schema s : visited ) {
10498 if (s == schema ) {
10599 return null ;
0 commit comments