spring-projects / spring-projects/spring-data-rest
RepositoryDetectionStrategy not Respected [DATAREST-916]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.