Skip to content

Commit e434816

Browse files
authored
Catalog and Collection Link titles (#1037)
* Add link titles * add test for link titles * update changelog * update test assertion * update titles based on PR feedback
1 parent 6083c69 commit e434816

3 files changed

Lines changed: 42 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222
- Bbox queries outside of [-180, -90, 180, 90] return a 400 error
2323
- STAC Items passed to the ingest lambda require the collection field to be set
2424
- The behavior when a `fields` parameter is passed now matches [the spec](https://github.com/stac-api-extensions/fields) ([469](https://github.com/stac-utils/stac-server/pull/1032))
25+
- Link titles were added to dynamically generated Catalog and Collection links ([468](https://github.com/stac-utils/stac-server/pull/1037))
2526

2627
## [4.5.0]
2728

src/lib/api.js

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -487,42 +487,49 @@ export const addCollectionLinks = function (results, endpoint) {
487487
links.splice(0, 0, {
488488
rel: 'self',
489489
type: 'application/json',
490-
href: `${endpoint}/collections/${id}`
490+
href: `${endpoint}/collections/${id}`,
491+
title: id
491492
})
492493
// parent catalog
493494
links.push({
494495
rel: 'parent',
495496
type: 'application/json',
496-
href: `${endpoint}`
497+
href: `${endpoint}`,
498+
title: 'Catalog'
497499
})
498500
// root catalog
499501
links.push({
500502
rel: 'root',
501503
type: 'application/json',
502-
href: `${endpoint}`
504+
href: `${endpoint}`,
505+
title: 'Catalog'
503506
})
504507
// child items
505508
links.push({
506509
rel: 'items',
507510
type: 'application/geo+json',
508-
href: `${endpoint}/collections/${id}/items`
511+
href: `${endpoint}/collections/${id}/items`,
512+
title: 'Items'
509513
})
510514
// queryables
511515
links.push({
512516
rel: 'http://www.opengis.net/def/rel/ogc/1.0/queryables',
513517
type: 'application/schema+json',
514-
href: `${endpoint}/collections/${id}/queryables`
518+
href: `${endpoint}/collections/${id}/queryables`,
519+
title: 'Queryables'
515520
})
516521
links.push({
517522
rel: 'aggregate',
518523
type: 'application/json',
519524
href: `${endpoint}/collections/${id}/aggregate`,
520-
method: 'GET'
525+
method: 'GET',
526+
title: 'STAC aggregation [GET]'
521527
})
522528
links.push({
523529
rel: 'aggregations',
524530
type: 'application/json',
525-
href: `${endpoint}/collections/${id}/aggregations`
531+
href: `${endpoint}/collections/${id}/aggregations`,
532+
title: 'Aggregations'
526533
})
527534
})
528535
return results
@@ -1203,60 +1210,71 @@ const getCatalog = async function (txnEnabled, endpoint = '') {
12031210
{
12041211
rel: 'self',
12051212
type: 'application/json',
1206-
href: `${endpoint}`
1213+
href: `${endpoint}`,
1214+
title: 'Root Catalog'
12071215
},
12081216
{
12091217
rel: 'root',
12101218
type: 'application/json',
1211-
href: `${endpoint}`
1219+
href: `${endpoint}`,
1220+
title: 'Root Catalog'
12121221
},
12131222
{
12141223
rel: 'conformance',
12151224
type: 'application/json',
1216-
href: `${endpoint}/conformance`
1225+
href: `${endpoint}/conformance`,
1226+
title: 'STAC/OGC confromance classes'
12171227
},
12181228
{
12191229
rel: 'data',
12201230
type: 'application/json',
1221-
href: `${endpoint}/collections`
1231+
href: `${endpoint}/collections`,
1232+
title: 'Collections'
12221233
},
12231234
{
12241235
rel: 'search',
12251236
type: 'application/geo+json',
12261237
href: `${endpoint}/search`,
12271238
method: 'GET',
1239+
title: 'STAC search [GET]'
12281240
},
12291241
{
12301242
rel: 'search',
12311243
type: 'application/geo+json',
12321244
href: `${endpoint}/search`,
12331245
method: 'POST',
1246+
title: 'STAC search [POST]'
12341247
},
12351248
{
12361249
rel: 'aggregate',
12371250
type: 'application/json',
12381251
href: `${endpoint}/aggregate`,
12391252
method: 'GET',
1253+
title: 'STAC aggregate [GET]'
12401254
},
12411255
{
12421256
rel: 'aggregations',
12431257
type: 'application/json',
1244-
href: `${endpoint}/aggregations`
1258+
href: `${endpoint}/aggregations`,
1259+
title: 'Aggregations'
12451260
},
12461261
{
12471262
rel: 'service-desc',
12481263
type: 'application/vnd.oai.openapi',
1249-
href: `${endpoint}/api`
1264+
href: `${endpoint}/api`,
1265+
title: 'OpenAPI service description'
12501266
},
12511267
{
12521268
rel: 'service-doc',
12531269
type: 'text/html',
1254-
href: `${endpoint}/api.html`
1270+
href: `${endpoint}/api.html`,
1271+
title: 'OpenAPI service documentation'
12551272
},
12561273
{
12571274
rel: 'http://www.opengis.net/def/rel/ogc/1.0/queryables',
12581275
type: 'application/schema+json',
1259-
href: `${endpoint}/queryables`
1276+
href: `${endpoint}/queryables`,
1277+
title: 'Queryables'
12601278
},
12611279
]
12621280

@@ -1265,6 +1283,7 @@ const getCatalog = async function (txnEnabled, endpoint = '') {
12651283
rel: 'server',
12661284
type: 'text/html',
12671285
href: process.env['STAC_DOCS_URL'],
1286+
title: 'API documentation'
12681287
})
12691288
}
12701289

@@ -1311,11 +1330,13 @@ const getCollections = async function (backend, endpoint, parameters, headers) {
13111330
rel: 'self',
13121331
type: 'application/json',
13131332
href: `${endpoint}/collections`,
1333+
title: 'Collections'
13141334
},
13151335
{
13161336
rel: 'root',
13171337
type: 'application/json',
13181338
href: `${endpoint}`,
1339+
title: 'Root Catalog'
13191340
},
13201341
],
13211342
}

tests/system/test-api-get-collection.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ test('GET /collections/:collectionId returns a collection', async (t) => {
5353
t.true(aggregateLink?.href.endsWith(`/collections/${collectionId}/aggregate`))
5454
const aggregationsLink = response.body.links.find((l) => l.rel === 'aggregations')
5555
t.true(aggregationsLink?.href.endsWith(`/collections/${collectionId}/aggregations`))
56+
57+
// Check that proper link titles are generated
58+
response.body.links.forEach((link) => {
59+
t.truthy(link.hasOwnProperty('title') && link.title)
60+
})
5661
})
5762

5863
test('GET /collection/:collectionId for non-existent collection returns Not Found', async (t) => {

0 commit comments

Comments
 (0)