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

RepositoryRestConfiguration with EvoInflectorLinkRelationProvider [DATAREST-1556]

Open
#1,916 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

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

Description

nilzao opened DATAREST-1556 and commented

class:

org.springframework.data.rest.core.config.RepositoryRestConfiguration

private LinkRelationProvider relProvider = new EvoInflectorLinkRelationProvider();

 

class:

org.springframework.data.rest.core.mapping.RepositoryCollectionResourceMapping

private static final boolean EVO_INFLECTOR_IS_PRESENT = ClassUtils.isPresent("org.atteo.evo.inflector.English", null);
/*
.....
*/
//constructor
RepositoryCollectionResourceMapping(RepositoryMetadata metadata, RepositoryDetectionStrategy strategy,
			LinkRelationProvider relProvider){
//...
CollectionResourceMapping domainTypeMapping = EVO_INFLECTOR_IS_PRESENT
				? new EvoInflectorTypeBasedCollectionResourceMapping(domainType, relProvider)
				: new TypeBasedCollectionResourceMapping(domainType, relProvider);
//...
}

to disable evo-inflector workaround config (I had to disable evo-inflector, because of another bug that I will report later)

pom.xml:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.atteo</groupId>
                <artifactId>evo-inflector</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

class MyRepositoryRestConfigurerConfig.java

@Configuration
public class MyRepositoryRestConfigurerConfig implements RepositoryRestConfigurer {

    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
        config.setRelProvider(new DefaultLinkRelationProvider());
    }
}

suggestion:
class org.springframework.data.rest.core.config.RepositoryRestConfiguration

private LinkRelationProvider relProvider = ClassUtils.isPresent("org.atteo.evo.inflector.English", null) ? new EvoInflectorLinkRelationProvider() : new DefaultLinkRelationProvider();

Affects: 3.4 M2 (2020.0.0), 3.3.3 (Neumann SR3)

Reference URL: https://stackoverflow.com/questions/26037045/how-to-globally-customize-the-collection-resource-rel-and-path-for-spring-data-r

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.