-
-
Notifications
You must be signed in to change notification settings - Fork 497
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
Kotlin enums are always marked as required if used in Java controllers #2622
Comments
I am adding a fix for this non usual use case. If you need further customization, feel free to override nullableKotlinRequestParameterCustomizer |
Thank you, I really appreciate it! |
@bcmedeiros & @bnasslahsen Thanks for getting this fixed. There are many people that this will help as large projects converting to Kotlin will be doing so incrementally. |
Describe the bug
If a Kotlin enum is used as a parameter in a request method of a controller written in Java, the parameter is always marked as required.
To Reproduce
Steps to reproduce the behavior:
Add the following classes to a Spring Boot project:
enum (kotlin):
controller (java):
This will generate the following spec, which is not consistent:
Expected behavior
required
should be equals false, since even though the enum is written in Kotlin, it's being used on a Java method and all parameters in a Java method are effective nullable.@Parameter(required = false)
and@Nullable
annotations were added to the parameter in a tentative to override the current behaviour, but without success.If we convert the exact same controller to Kotlin, then the
required
property of the parameter follows the nullability flag of the method parameter (MyEnum
vsMyEnum?
), which is the correct thing to do. We unfortunately cannot convert the controller right now (see context below).Screenshots
(none)
Additional context
I know this is an unusual combination of Kotlin and Java classes, but we are gradually migrating our Java classes to Kotlin and that's our current reality, some of the business class are already Kotlin but we still have some Java controllers that will take some time to migrate.
3.2.4
2.5.0
The text was updated successfully, but these errors were encountered: