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

RepositoryDetectionStrategy not Respected [DATAREST-916]

Open
#1,282 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

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

Description

Alan Hay opened DATAREST-916 and commented

Given the following configuration it would be expected (http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_which_repositories_get_exposed_by_defaults) that only Repositories annotated with @RepositoryRestResource(exported = true) should be exported. However no repositories appear to be exported.

@Bean
  public RepositoryRestConfigurer repositoryRestConfigurer()
  {
    return new RepositoryRestConfigurerAdapter()
    {
      @Override
      public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config)
      {
        config.setBasePath("/api");
        config.setRepositoryDetectionStrategy(RepositoryDetectionStrategies.ANNOTATED);
        config.exposeIdsFor(User.class);
      }
    };
  }
@RepositoyRestResource(exported = true)
public interface UserRepository extends JpaRepository<User, Long>, QueryDslPredicateExecutor<User>
{
     call to /api/users returns 404
}

Given the following configuration it would be expected (http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_which_repositories_get_exposed_by_defaults) that any Repository annotated with @RepositoryRestResource(exported = false) should not be exported. However the annotated repository is exported.

@Bean
  public RepositoryRestConfigurer repositoryRestConfigurer()
  {
    return new RepositoryRestConfigurerAdapter()
    {
      @Override
      public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config)
      {
        config.setBasePath("/api");
        config.setRepositoryDetectionStrategy(RepositoryDetectionStrategies.DEFAULT);
        config.exposeIdsFor(User.class);
      }
    };
  }
@RepositoyRestResource(exported = false)
public interface UserRepository extends JpaRepository<User, Long>, QueryDslPredicateExecutor<User>
{
     call to /api/users returns valid response
}

Affects: 2.5.3 (Hopper SR3)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.