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
If a controller operation has a parameter or return type with a wildcard generic type, the type information is lost and any customizers will see the generically typed property of the class as just an Object rather than the upper bound of the type parameter.
This is fairly complex so I've created an example on a fork of the project: robfletcher@6f212b2
With the wildcard the schemas in the API treat the PetRecord.pet property as just an object. If I change the generic declarations on the controller to PetRecord<? extends Pet> then it works correctly. However, this shouldn't be necessary since that is just re-declaring the same variance as on the PetRecord class. Removing the generic type altogether also works (with a compiler warning). I originally ran into this problem in a Kotlin codebase where omitting the generic type is not possible.
The text was updated successfully, but these errors were encountered:
As you know we rely on swagger-core official libraries.
The behaviour that you are describing is related to swagger-core. There is still some related issues:
You can use the attached ModelConverter, is a kind of fix and should help you achieve your goal.
Let me know if that helps, so we can plan to integrate it in future releases:
If a controller operation has a parameter or return type with a wildcard generic type, the type information is lost and any customizers will see the generically typed property of the class as just an
Object
rather than the upper bound of the type parameter.This is fairly complex so I've created an example on a fork of the project: robfletcher@6f212b2
When considering the parameter and response types of the controller method here: robfletcher@6f212b2#diff-3cea84ffe0d7e0808cc1ed9cd9c1fe9aR16-R18
With the wildcard the schemas in the API treat the
PetRecord.pet
property as just anobject
. If I change the generic declarations on the controller toPetRecord<? extends Pet>
then it works correctly. However, this shouldn't be necessary since that is just re-declaring the same variance as on thePetRecord
class. Removing the generic type altogether also works (with a compiler warning). I originally ran into this problem in a Kotlin codebase where omitting the generic type is not possible.The text was updated successfully, but these errors were encountered: