-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack Overflow / infinite recursion in PolymorphicModelConverter.findComposedSchemas #2801
Comments
Not reproducible. This ticket will be closed, but can be reopened if your provide the reproducible sample. |
Here you go: https://github.com/martinitus/springdoc-openapi-sample Run app and open localhost:8080/swagger-ui.html. 💥 I've seen you have kotlin tests in here, and I tried to get them going on my non-work windows pc for like 15minutes, but then gave up. Should be easy to add one test scenario that includes this :-) |
@bnasslahsen I think when migrating to OpenAPI v3.1 the workaround I am trying to achieve would no longer be necessary: I was able to get the desired behaviour out of the swagger-core library. I'll keep experimenting and see if I can get this working with the current springdoc-openapi version. I also have a small branch that would resolve the infinite recursion, but I'm not sure whether my changes make sense.. I'll add a link to the fork later. |
I am experiencing the same problem after upgrading spring boot to 3.4.1 and springdoc to 2.7.0. I have two self-referential models (ModelA contains a field of type ModelA), and this type of modelling is no longer supported in 2.7.0 it seems. It keeps on recursing in org.springdoc.core.converters.PolymorphicModelConverter#findComposedSchemas. If I remove these models from my code the error is gone. Also, downgrading to v2.5.0 removes the error. I have a wild hunch that this commit is the culprit: 497bfae |
It might make sense to add the self referential model scenario as a unit test, as it is unrelated to the solution i have in #2833. |
@omarfi I could not reproduce your issue with a simple self-referential model in the latest main commit after #2833 was merged: @Schema
data class TreeNode(
@Schema(description = "The children") val children: List<TreeNode>,
@Schema(description = "Root nodes don't have a parent") val parent: TreeNode?,
)
@RestController
@RequestMapping("/test")
class TestController {
@PostMapping("/test")
fun create(@RequestBody root: TreeNode) {
}
} So I guess its resolved :) |
Describe the bug
I am trying to work around the problem described here with the workaround described here. TLDR: I want to have a description on a type that is not defined by the type, but by the context where the type is used.
To Reproduce
Expected behavior
Expected Open API Json
Screenshots
It loads (no StackOverflow) and renders correctly, when I change type of
field_a
andfield_b
toString
. But that's obviously not what I want.** Stack Trace**
The text was updated successfully, but these errors were encountered: