Skip to content

Commit fbd8bcd

Browse files
martinitusMRuecklCC
authored andcommitted
resolve infinite recursion
1 parent 77ff900 commit fbd8bcd

File tree

2 files changed

+16
-19
lines changed
  • springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters
  • springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results

2 files changed

+16
-19
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato
134134
if(resolvedSchema.get$ref().contains(Components.COMPONENTS_SCHEMAS_REF)) {
135135
String schemaName = resolvedSchema.get$ref().substring(Components.COMPONENTS_SCHEMAS_REF.length());
136136
Schema existingSchema = context.getDefinedModels().get(schemaName);
137-
if (existingSchema != null && existingSchema.getOneOf() != null) {
137+
if (existingSchema != null && (existingSchema.getOneOf() != null || existingSchema.getAllOf() != null || existingSchema.getAnyOf() != null)) {
138138
return resolvedSchema;
139139
}
140140
}

springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app13.json

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,30 @@
3636
"KeyValue" : {
3737
"required" : [ "key", "value" ],
3838
"type" : "object",
39-
"properties" : {
40-
"key" : {
41-
"type" : "string"
42-
},
43-
"value" : {
44-
"type" : "string"
39+
"description" : "Generic description",
40+
"allOf" : [ {
41+
"$ref" : "#/components/schemas/KeyValue"
42+
}, {
43+
"type" : "object",
44+
"properties" : {
45+
"key" : {
46+
"type" : "string"
47+
},
48+
"value" : {
49+
"type" : "string"
50+
}
4551
}
46-
},
47-
"description" : "Generic description"
52+
} ]
4853
},
4954
"SomeDTO" : {
5055
"required" : [ "fieldA", "fieldB" ],
5156
"type" : "object",
5257
"properties" : {
5358
"fieldA" : {
54-
"type" : "object",
55-
"description" : "Description A",
56-
"allOf" : [ {
57-
"$ref" : "#/components/schemas/KeyValue"
58-
} ]
59+
"$ref" : "#/components/schemas/KeyValue"
5960
},
6061
"fieldB" : {
61-
"type" : "object",
62-
"description" : "Description B",
63-
"allOf" : [ {
64-
"$ref" : "#/components/schemas/KeyValue"
65-
} ]
62+
"$ref" : "#/components/schemas/KeyValue"
6663
}
6764
}
6865
}

0 commit comments

Comments
 (0)