Basing on https://spring.io/guides/gs/accessing-data-rest/ in the sample project https://github.com/jcoig/gs-accessing-data-rest) i have repository defined as follows:
@RepositoryRestResource
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
List<Person> findByLastName(@Param("name") String name);
}
Such defined repository is available via http://localhost:8080/persons
and the response is:
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/persons{?page,size,sort}",
"templated" : true
},
"search" : {
"href" : "http://localhost:8080/persons/search"
}
},
"_embedded" : {
"persons" : [ {
"firstName" : "John",
"lastName" : "Smith",
"_links" : {
"self" : {
"href" : "http://localhost:8080/persons/1"
}
}
} ]
},
"page" : {
"size" : 20,
"totalElements" : 1,
"totalPages" : 1,
"number" : 0
}
}
I don't want to have persons
in the URL and I don't want to have persons
as the key in the returned JSON. Of Course I can define my repository as below:
@RepositoryRestResource(collectionResourceRel = "key", path = "path")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
List<Person> findByLastName(@Param("name") String name);
}
but my question is how to change default Spring's behavior and got custom key and custom path provider (just as example to disable s
suffixes).