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

Hide DELETE method for associations

Open
#2,173 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Sep 12, 2022.

status: waiting-for-triage
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

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.