Self Links and Inheritance of Sparse Fieldsets

Hello,

as I understand a self link at any location in a document is basically the link to the same response relative to the documents path.

So if using Sparse Fieldsets I assume that it should be inherited to any self link as well. Not doing so would result in a non matching response if a self link was followed.

Is this correct?
If yes, what links attribute could be used as a reference to the resource object with full details?

{
	"data": [
        {
			"attributes": {
				"name": "First Pool",
				"description": "A good pool"
			},
			"id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
			"links": {
				"self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=name,description"
			},
			"type": "pools"
		},
		{
			"attributes": {
				"name": "Second Pool",
				"description": "Another good pool"
			},
			"id": "a0d6a8c1-eaed-43ed-8937-f3c5387ee78a",
			"links": {
				"self": "/pools/a0d6a8c1-eaed-43ed-8937-f3c5387ee78a?fields[pools]=name,description"
			},
			"type": "pools"
		}
	],
	"links": {
		"self": "/pools?fields[pools]=name,description"
	}
}

Not including the Sparse Fieldsets in a query might produce other reponses.

{
	"data": {
        "attributes": {
	        "name": "First Pool",
	        "description": "A good pool",
            "city": "Berlin",
            "country": "Germany",
            "active": true
	    },
        "id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
        "links": {
            "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
        },
        "type": "pools",
    },
    "links": {
        "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
    }
}

If you’re still looking for the answer, the sparse fieldsets should not be present in a resource-level self link. Otherwise the client has to remove those query parameters before requesting other data from that endpoint.

See also Top-level links vs. resource-level links for item resources. Main take away is that the resource-level self link identifies the resource, not how you want to have it represented in a specific call.

Thus a request for /pools?fields[pools]=name,description returns:

{
	"data": [
        {
			"attributes": {
				"name": "First Pool",
				"description": "A good pool"
			},
			"id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
			"links": {
				"self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
			},
			"type": "pools"
		},
		{
			"attributes": {
				"name": "Second Pool",
				"description": "Another good pool"
			},
			"id": "a0d6a8c1-eaed-43ed-8937-f3c5387ee78a",
			"links": {
				"self": "/pools/a0d6a8c1-eaed-43ed-8937-f3c5387ee78a"
			},
			"type": "pools"
		}
	],
	"links": {
		"self": "/pools?fields[pools]=name,description"
	}
}

The client can then request the extra data if a user interacts with one of the resources using /pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=city,country,active:

{
	"data": {
        "attributes": {
            "city": "Berlin",
            "country": "Germany",
            "active": true
	    },
        "id": "5c071fae-01fa-4f18-b692-7bc6fc98331f",
        "links": {
            "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f"
        },
        "type": "pools",
    },
    "links": {
        "self": "/pools/5c071fae-01fa-4f18-b692-7bc6fc98331f?fields[pools]=city,country,active"
    }
}