Add userParameterMode = CUSTOM for selecting a custom type for authentication in servers#2569
Conversation
|
@giovanniberti need to sign CLA |
|
@giovanniberti ping |
|
Sorry for the delay! :) |
Ok! I'm ready to merge this PR. Waiting your fix |
831cf91 to
250b8f4
Compare
…entication in servers
250b8f4 to
198c621
Compare
|
Added checks and tests for the combination of |
|
@giovanniberti run
|
198c621 to
410c14f
Compare
|
Done |
…ith `userParameterClass`
410c14f to
6167932
Compare
|
@giovanniberti you need to run build locally before commit.
Some tests failed: KotlinMicronautServerCodegenTest.testEnumNullable()
|
| userParameterClass = (String) additionalProperties.get(OPT_USER_PARAMETER_CLASS); | ||
| var className = userParameterClass.substring(userParameterClass.lastIndexOf('.') + 1); | ||
| importMapping.put(className, userParameterClass); | ||
| } else if (additionalProperties.containsKey(OPT_USER_PARAMETER_CLASS)) { |
There was a problem hiding this comment.
There is your mistake: you need to check this parameter only when userModeOpt == CUSTOM
There was a problem hiding this comment.
That's the point of the check, we have four possible cases:
userParameterMode == CUSTOM- and
userParameterClassnot set -> user error, covered by the first check - and
userParameterClassset -> ok
- and
userParameterMode != CUSTOM- and
userParameterClassnot set -> ok - and
userParameterClassset -> user error, covered by theelse if
- and
One parameter without the other is not a configuration that makes sense to support.
The problem at the implementation level was that additionalProperties.contains(OPT_USER_PARAMETER_CLASS) evaluates to true because there are other parts of the code that populate the map with that key and set null as the value if the user doesn't provide it.
Does it make sense to you?
There was a problem hiding this comment.
Yes, of course, I understand that we have four possible combinations.
But in my opinion, it would be easier to simply ignore the userParameterClass parameter if the mode is different from CUSTOM, rather than throwing an error. Because here you're already checking for the mode.
So, now you're checking the mode at startup, and then checking the mode every time you substitute the class.
There was a problem hiding this comment.
The main idea is that if a user switches the mode via a gradle plugin, so that his build doesn't break due to the fact that he has specified a parameter userParameterClass that is used only in CUSTOM mode, but simply silently ignore this parameter
There was a problem hiding this comment.
Personally I don't like inferring the correct configuration via precedence rules, but if that's the convention in Gradle or specifically in this plugin I'll remove the extra check
There was a problem hiding this comment.
This is a small thing, in my opinion. That's okay too
Weird, I did, something must have broken Gradle's config on my IDE 🤔 EDIT: I'm getting test failures (specifically a |
|
Given the open discussion and my current setup limitations I'm leaving this PR in draft for the moment until you're ok with it moving forward |



Closes #2562