-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add support for required query parameters #540
Comments
As some background, JAX-RS An alternative would be to use a bean parameter https://avaje.io/http/#bean-param and have validation annotations on the bean. In this way the error message can be internationalised plus all the parameters are validated rather than a fail-on-first.
A question is if this message should be internationalised? If it gets more involved.
Note that currently the avaje-http-api includes a static method If there was a RequiredParameterException and it was thrown then an exception handler could be registered do perform i8n etc as needed. Hmmm. |
Thanks for the bean parameter and As for i18n, I never really cared for it when building an API. I think i18n is the responsibility of the client, who should be able to show the required message based on e.g. an error code. But that's just me. |
with #550, do we still need this? You can do |
The documentation states that:
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:
Becomes:
Another example, with an explicit parameter name
"my-foo"
.Edit: Updated the examples above because as the method parameter name matches ("foo" matches foo).
The text was updated successfully, but these errors were encountered: