Closed
Description
The documentation states that:
Query parameters are considered optional / nullable.
It would be useful if we could pass a boolean value to the @QueryParam
annotation indicating that such query parameter is required, and that the request should fail if it's not present.
Something like @QueryParam(required = true)
would be very useful.
This would prevent a lot of boilerplate code for checking that required params are present.
This:
@Post
public void doSomething(@QueryParam String foo) {
if (foo == null) {
throw new SomeException("Query parameter \"foo\" is required");
}
// do stuff
}
Becomes:
@Post
public void doSomething(@QueryParam(required = true) String foo) {
// do stuff
}
Another example, with an explicit parameter name "my-foo"
.
@Post
public void doSomething(@QueryParam(value = "my-foo", required = true) String myFoo) {
// do stuff
}
Edit: Updated the examples above because as the method parameter name matches ("foo" matches foo).
Metadata
Metadata
Assignees
Labels
No labels