Derive a link's description from its title

Previously, a LinkDescriptor had to be created with both a rel and a
description. If a description was not provided a failure would occur.

This commit relaxes the above-described restriction by allowing a
link's title to be used as its default description. If a descriptor
has a description, it will always be used irrespective of whether or
not the link has a title. If the descriptor does not have a
description and the link does have a title, the link's title will be
used. If the descriptor does not have a description and the link does
not have a title a failure will occur.

Closes gh-105
This commit is contained in:
Andy Wilkinson
2016-04-13 14:01:33 +01:00
parent 984f90fa7b
commit c4b7438708
17 changed files with 137 additions and 27 deletions

View File

@@ -1,7 +1,8 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com"
"href": "http://alpha.example.com",
"title": "Alpha"
}, {
"rel": "bravo",
"href": "http://bravo.example.com"

View File

@@ -1,7 +1,8 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com/one"
"href": "http://alpha.example.com/one",
"title": "Alpha one"
}, {
"rel": "alpha",
"href": "http://alpha.example.com/two"

View File

@@ -1,6 +1,7 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com"
"href": "http://alpha.example.com",
"title": "Alpha"
} ]
}

View File

@@ -1,7 +1,8 @@
{
"_links": {
"alpha": {
"href": "http://alpha.example.com"
"href": "http://alpha.example.com",
"title": "Alpha"
},
"bravo": {
"href": "http://bravo.example.com"

View File

@@ -1,7 +1,8 @@
{
"_links": {
"alpha": [{
"href": "http://alpha.example.com/one"
"href": "http://alpha.example.com/one",
"title": "Alpha one"
}, {
"href": "http://alpha.example.com/two"
}]

View File

@@ -1,7 +1,8 @@
{
"_links": {
"alpha": {
"href": "http://alpha.example.com"
"href": "http://alpha.example.com",
"title": "Alpha"
}
}
}