Skip to content
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

Cyclic dependency with common base type swallows attributes #4666

Open
drakenfly opened this issue May 6, 2024 · 0 comments
Open

Cyclic dependency with common base type swallows attributes #4666

drakenfly opened this issue May 6, 2024 · 0 comments

Comments

@drakenfly
Copy link

Hello,

I recently discovered a bug in Swagger-Core affecting object property resolution. As far as I could debug, it is related to a short circuit in object traversal to prevent StackOverflows - see ModelResolver:394. I could obersve the problem for two objects with a cyclic dependency on each other, whilst sharing a common base type and forcing the OpenAPI generator to traverse the object tree in a specific order using the allOf attribute.

I was able to provide a minimal reproduction in this repository: https://github.com/drakenfly/swagger-inheritance-bug

Performing a mvn clean install in the root of the project will generate an OpenAPI spec in api/target/generatedtest/openapi.[json|yaml].

This spec contains an object called PortfolioViewDto that should contain a list of DepotViewDto, which is missing. Navigating to api/src/main/java/rest/TestEndpoint.java and uncommenting the additional methods (and importing the DTOs of course) will lead to a correct generation of the spec file, as the order of traversal changes with the additional methods.

Is anybody here able to help?

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant