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

Bad schema return type when created a generic wrapper class for response entity #2733

Closed
kamilkrzywanski opened this issue Sep 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@kamilkrzywanski
Copy link
Contributor

kamilkrzywanski commented Sep 29, 2024

project.zip
Bug Description
When I created a wrapper for ResponseEntity with a generic class inside, the API is generated with the wrapper type instead of the expected ResponseEntity type.

Steps to Reproduce

Create a custom wrapper for ResponseEntity with a generic class.
Generate API documentation (e.g., Swagger/OpenAPI).
Notice that the API uses the custom wrapper class instead of ResponseEntity.
Included a zip file with the code.

Expected Behavior
The API should return the exact type wrapped in the ResponseEntity, not the wrapper itself.

Screenshots
If applicable, add screenshots to help explain your problem.
image
image
image

Additional context
The bug has already been fixed. I'll write tests and submit a PR shortly!

kamilkrzywanski added a commit to kamilkrzywanski/springdoc-openapi that referenced this issue Sep 29, 2024
kamilkrzywanski added a commit to kamilkrzywanski/springdoc-openapi that referenced this issue Sep 29, 2024
kamilkrzywanski added a commit to kamilkrzywanski/springdoc-openapi that referenced this issue Sep 29, 2024
@bnasslahsen bnasslahsen added the enhancement New feature or request label Sep 29, 2024
@bnasslahsen
Copy link
Collaborator

@kamilkrzywanski,

I have changed the fix, as it breaks other tests.
Do not hesitate to test the new latest SNAPSHOT.

@kamilkrzywanski
Copy link
Contributor Author

You're right, I only checked my test and had hope that this project would have some pipeline.
I've reviewed your changes, and this approach works as long as we have only one wrapper. However, if we enclose it with another class, my test will fail again. I believe the issue mainly lies with ResponseEntity. My second mistake is that the excluded classes list contains interfaces, and we never get the exact class.

This approach pass all tests, and works in my opinion correct:
#2736

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

No branches or pull requests

2 participants