You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
StackOverflowError with object having an array of itself #332
Moving this issue to apicurio-codegen. I've tracked down the issue to the OpenApiAllOfProcessor in that repository. I do not believe there is an issue in apicurio-data-models.
Hey @mcruzdev - a stack overflow is obviously not an acceptable outcome. :)
That said, what do you expect to happen for a recursive type reference in JSON Schema when generating the JAX-RS layer? We could, of course, put in something to detect recursive types and simply fail. I'm not clear on what else we could do...
Yeah I suppose that makes sense. We're using jsonschema2pojo to create the java beans from the schema types. It will probably require some experimenting to figure out how to get something like that working.
I'm just guessing, but perhaps it can already handle simple recursive cycles in the types, but the "AllOf" introduces an additional challenge. Let's expand on your example a bit to get this:
In that case, the someGroup property is a list of Things where each Thing has all of the properties of Something plus all the properties of SomethingElse *and the foo and bar properties.
What we're trying to do right now in the code generator is preprocess the JSON Schema to flatten out the type of someGroup to get rid of the allOf and merge all of the properties into a new object definition. The problem is that Something is self-recursive so the preprocessor gets into a loop.
We can obviously try to detect the cycle and skip the allOf preprocessing when we find one. That will probably result in jsonschema2pojo failing or producing something not usable.
I think the first thing to do here may be to create a few tests with different recursive schemas defined. Then see what we get and iteratively work from there.
I think the first thing to do here may be to create a few tests with different recursive schemas defined. Then see what we get and iteratively work from there.
It is really a challenge, and I think too that it is a good start way.
Activity
EricWittmann commentedon Apr 8, 2025
Moving this issue to apicurio-codegen. I've tracked down the issue to the OpenApiAllOfProcessor in that repository. I do not believe there is an issue in apicurio-data-models.
EricWittmann commentedon Apr 8, 2025
Hey @mcruzdev - a stack overflow is obviously not an acceptable outcome. :)
That said, what do you expect to happen for a recursive type reference in JSON Schema when generating the JAX-RS layer? We could, of course, put in something to detect recursive types and simply fail. I'm not clear on what else we could do...
wdyt?
mathecruz commentedon Apr 8, 2025
I think we need to generate something like it:
EricWittmann commentedon Apr 10, 2025
Yeah I suppose that makes sense. We're using jsonschema2pojo to create the java beans from the schema types. It will probably require some experimenting to figure out how to get something like that working.
I'm just guessing, but perhaps it can already handle simple recursive cycles in the types, but the "AllOf" introduces an additional challenge. Let's expand on your example a bit to get this:
In that case, the
someGroupproperty is a list ofThings where eachThinghas all of the properties ofSomethingplus all the properties ofSomethingElse*and thefooandbarproperties.What we're trying to do right now in the code generator is preprocess the JSON Schema to flatten out the type of
someGroupto get rid of theallOfand merge all of the properties into a new object definition. The problem is thatSomethingis self-recursive so the preprocessor gets into a loop.We can obviously try to detect the cycle and skip the
allOfpreprocessing when we find one. That will probably result in jsonschema2pojo failing or producing something not usable.I think the first thing to do here may be to create a few tests with different recursive schemas defined. Then see what we get and iteratively work from there.
wdyt?
mathecruz commentedon Apr 23, 2025
It is really a challenge, and I think too that it is a good start way.