spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
919 stars 563 forks source link

Inconsistent pluralization when using bidirectional @OneToMany [DATAREST-1131] #1492

Open spring-projects-issues opened 7 years ago

spring-projects-issues commented 7 years ago

Ewout Van Gossum opened DATAREST-1131 and commented

I am currently developing using Spring Data REST and things are going swimmingly apart from one thing. The plural nouns don't match the language of my API.

I have an Entity called Test that has a bidirectional @OneToMany relationship (with Resultaat) exposed via Data REST. In my language the plural of test is testen, and of resultaat is resultaten. The "TestRepository" is annotated with:

@RepositoryRestResource(collectionResourceRel = "testen", path = "testen")

And when I retrieve "testen" everything works fine. Also the relationship uses the correct plural (based on the name of the property that contains the "resultaten"). So the URI /testen/{id}/resultaten/{id} works. However the self links of Resultaat show "resultaats" in the URI which is the wrong plural.

If I try to define a RepositoryRestResource for Resultaat, the resultaten are mapped correctly, but the api changes the path of "testen" back to "tests" which is a bug in my opinion.

I think it would be handy to solve this issue via an annotation on the entities, that can override the default pluralization.

I can provide an example project of this later in this week if required.


No further details from DATAREST-1131

spring-projects-issues commented 7 years ago

Ewout Van Gossum commented

I have also noticed that the TestRepository sometimes gets mapped to /tests and sometimes to /testen. This sort of non-deterministic behavior is quite strange