Skip to content

Bug in Documentation: @RepositoryRestController is NOT exposed under base-path [DATAREST-1327] #1686

@spring-projects-issues

Description

@spring-projects-issues

Doogiemuc opened DATAREST-1327 and commented

The spring-data-rest doc sais:

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).

https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.overriding-sdr-response-handlers

This is not true.

@RepositoryRestController
public class MyCustomController {
  @RequestMapping(value = "/myCustomResource")
  public ResponseEntity<?> customResource() { ... }
}

is not mapped at all.

One MUST use a @RequestMapping on class level.  Even @RequestMapping("/")  works to map MyCustomController. See also https://stackoverflow.com/questions/38607421/spring-data-rest-controllers-behaviour-and-usage-of-basepathawarecontroller

There is a workaround:

@RepositoryRestController
@RequestMapping("${spring.data.rest.base-path}")
public class MyCustomController { ... }

At least update the documentation to describe this correctly


Reference URL: https://stackoverflow.com/questions/38607421/spring-data-rest-controllers-behaviour-and-usage-of-basepathawarecontroller

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions