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

Cannot expose resource IDs via custom RepositoryRestMvcConfiguration [DATAREST-501]

Open
#876 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

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

Description

Justin Lewis Salmon opened DATAREST-501 and commented

Hi,

(copied from gs-accessing-mongodb-data-rest#3)

I'm trying to expose resource IDs in my project by using RepositoryRestConfiguration#exposeIdsFor(). It wasn't working in my larger application, so I came all the way back to the starter project to see if I'd messed something up somehow.

But I'm still not able to see IDs in the JSON responses with the following custom configuration:

@Configuration
public class CustomRepositoryRestMvcConfiguration extends SpringBootRepositoryRestMvcConfiguration {

  @Override
  protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.exposeIdsFor(Person.class);
  }
}

Application.java:

@SpringBootApplication
@Import(CustomRepositoryRestMvcConfiguration.class)
public class Application {

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

Am I doing something obviously wrong here? All the examples I've found online indicate that this should work. Maybe I've found a regression, but I doubt it.

Here's a link to a fork of the starter project that reproduces the issue (relevant commit: 54be405)

Thanks in advance for any help!

p.s. spring-boot-starter-data-rest and spring-boot-starter-data-mongodb deps are both at 1.2.2.RELEASE


No further details from DATAREST-501

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.