Spring Data REST - collectionResourceRel vs path

k13i :

I'm using Spring Data REST. RepositoryRestResource annotation has two different fields: path and collectionResourceRel. What's the difference between those two? I can't figure this out by reading the documentation.

path is described:

The path segment under which this resource is to be exported.

and collectionResourceRel is described:

The rel value to use when generating links to the collection resource.

In all code examples I've seen these two properties where the same. Is there any case when they differ? And what is the actual difference between them?

Cepr0 :

For example, for entity User the default values will be:

path = users

itemResourceRel = user

collectionResourceRel = users

Example:

GET /users (path: users)

"_links": { 
        "self": {
            "href": "http://localhost:8080/api/users"
        },
        "users": {  <-- collectionResourceRel
            "href": "http://localhost:8080/api/users"
        }
    }

GET /users/1 (path: users)

"_links": {
        "self": {
            "href": "http://localhost:8080/api/users/1"
        },
        "user": { <-- itemResourceRel
            "href": "http://localhost:8080/api/users/1"
        }
    }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=473699&siteId=1