Skip to content
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

Support for QueryValue as a object #11473

Open
gs-kug opened this issue Dec 28, 2024 · 0 comments
Open

Support for QueryValue as a object #11473

gs-kug opened this issue Dec 28, 2024 · 0 comments
Labels
type: improvement A minor improvement to an existing feature

Comments

@gs-kug
Copy link

gs-kug commented Dec 28, 2024

Feature description

When creating multiple or reusable query parameters like pagination object for example is good to have all fields in a class converted to @QueryValue. For example:

class JsPaginationRequest {
  Integer page;
  Integer size;
}

@Controller {
   @Get(@QueryValue JsPaginationRequest pagination) {
   }
}

the pagination object could be populated by the params ?page=1&size=10 as optional parameters.
This should be equivalent to:

@Controller {
   @Get(@QueryValue @Nullable Integer page, @QueryValue @Nullable Integer size) {
   }
}

Another use case is in a filter UI where a huge number of parameters are optional and part of the search.

Consider validation required and nonrequired fields inside object.

SpringDoc has a @ParameterObject annotation that does this.

Another advantage is from a developer perspective you don't have a chance to misspell any filter or pagination in different controllers as it is now reusable, and you can pass the hole object thought your layer no need to manual create the object in controller layer.

@yawkat yawkat added the type: improvement A minor improvement to an existing feature label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants