spring-projects / spring-projects/spring-data-rest
Hide DELETE method for associations
@odrotbohm is already working on this.
Since Sep 12, 2022.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
According to this answer https://stackoverflow.com/questions/28679934/why-is-delete-not-supported-on-to-many-association-resources-in-spring-data-rest DELETE method not supported for OneToMany and ManyToMany associations. It returns 405 Method not allowed. But this method is visible in Swagger UI and confuses people. Is it possible to hide it?
The following has no any effect:
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
config.getExposureConfiguration()
.withAssociationExposure((metadata, methods) -> methods.disable(HttpMethod.DELETE))
.withCollectionExposure((metadata, methods) -> methods.disable(HttpMethod.DELETE));
}
The following disables all delete methods, but I need to disable it for assocations only:
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
config.getExposureConfiguration()
.withItemExposure((metadata, methods) -> methods.disable(HttpMethod.DELETE));
}
It seems that .withAssociationExposure() is never called.
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.