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

Documentation uses incorrect annotation in the code example #2352

Open
sergey-morenets opened this issue Jan 11, 2024 · 0 comments
Open

Documentation uses incorrect annotation in the code example #2352

sergey-morenets opened this issue Jan 11, 2024 · 0 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@sergey-morenets
Copy link

sergey-morenets commented Jan 11, 2024

Hi

Current documentation section that describes overriding default response handlers (https://docs.spring.io/spring-data/rest/reference/customizing/overriding-sdr-response-handlers.html) states multiple times that @RepositoryRestController annotation should be used:

Sometimes, you may want to write a custom handler for a specific resource. To take advantage of Spring Data REST’s settings, message converters, exception handling, and more, use the @RepositoryRestController annotation instead of a standard Spring MVC @Controller or @RestController. Controllers annotated with @RepositoryRestController are served from the API base path defined in RepositoryRestConfiguration.setBasePath, which is used by all other RESTful endpoints (for example, /api). The following example shows how to use the @RepositoryRestController annotation:

However in the code block after this text @BasePathAwareController annotation is used:

@BasePathAwareController
class ScannerController {

  private final ScannerRepository repository;

  ScannerController(ScannerRepository repository) { 
    repository = repository;
  }

  @GetMapping(path = "/scanners/search/producers") 
  ResponseEntity<?> getProducers() {

    List<String> producers = repository.listProducers(); 

    //
    // do some intermediate processing, logging, etc. with the producers
    //

    CollectionModel<String> resources = CollectionModel.of(producers); 

    resources.add(linkTo(methodOn(ScannerController.class).getProducers()).withSelfRel()); 

    // add other links as needed

    return ResponseEntity.ok(resources); 
  }
}

Spring Data REST: 4.2.1

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants