-
Notifications
You must be signed in to change notification settings - Fork 7
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
When there is one QueryParam and you don't sent any QueryParam the router doesn't find the route #4
Comments
It fails also when you have 2 QueryParam, if you don't put both on the request it doesn't find the route. |
Thanks @cristiangarciascmspain, tomorrow I will fix it and I will take care of the tests :) |
The key of the problem seems to be the defaultValue="", when we used other value it worked. |
It seems that if you set both the You set that QueryParam as required but you don't set a defaultValue (empty string is not a valid required value I think) so it expects to fail, isn't it? |
IMHO an empty string is a valid value. It's common to have a default with an empty string, because if not you'll have a null. The other thing is the incoherence having both default and required, the behaviour should be documented, because to me, if I have a default it should work, and for the library if it's required the default doesn't matter. |
It seems strange for me to declare a required parameter that it accepts empty string as valid value, but maybe it's me :P |
Remove the required, can't I set a defaultValue="" ? |
Maybe this issue should be split into:
|
If the param is not required for me defaultValue="" is valid. |
Strange to have two different behaviours, but anyway without the required is sending a null instead of an empty String. |
IMO these are two different issues:
|
Ok then, hands up for the next solution: If param required is set and given queryparam doesn't exist in the uri -> 400 bad request Currently we only need to fix a null value in query param when default="" Ok? |
I agree with the solution proposed, but I fail to understand this:
If the defaultValue is set to |
Yes, exactly, it shouldn't be null, currently we are returning null because of this: @Override
public String getParameterValue() throws ParamAnnotationException {
List<String> values = queryParams.get(queryParam.value());
String queryParamValue = null;
if (values != null && !values.isEmpty()) {
queryParamValue = values.get(0);
}
if (queryParamValue == null) {
if (!QueryParam.DEFAULT_VALUE.equals(queryParam.defaultValue())) {
queryParamValue = queryParam.defaultValue();
} else if (queryParam.required()) {
throw new QueryParamRequiredNotFoundException(queryParam.value());
}
}
return queryParamValue;
} I'm working on fix it... |
👏 👏 |
PR #5 |
example:
it works with:
http://..../api/meme?text=hello
but NOT with:
http://..../api/meme
The text was updated successfully, but these errors were encountered: