spring-projects / spring-projects/spring-data-rest

please support optionally null parameters in finder endpoints [DATAREST-90]

Open
#474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Josh Long opened DATAREST-90 and commented

For example, suppose i have the following repository:

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.repository.annotation.RestResource;

import java.util.List;

@RestResource(path = "users", rel = "users")
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
User findByUsername(@Param ("username") String username);
List<User> findUsersByFirstNameOrLastNameOrUsername( @Param ("firstName") String firstName, @Param("lastName") String lastName, @Param("username") String username);
}

if i use the endpoint and specify all the parameters, everything works. http://localhost:8080/users/search/findUsersByFirstNameOrLastNameOrUsername?firstName=X&username=Y&lastName=Z, but fails when one of the query parameters are missing.


No further details from DATAREST-90

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Spring Data REST finder endpoint shown in the issue and trace how repository query parameters are handled when a parameter is absent. Reproduce the example using findUsersByFirstNameOrLastNameOrUsername with one or more missing parameters. Done means the finder endpoint accepts omitted parameters instead of failing while preserving the existing behavior when all parameters are supplied.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.