Skip to content

Commit

Permalink
STAC API fixes (#908)
Browse files Browse the repository at this point in the history
* ensure trailing slash for STAC API root links

* update search media type

* update conformance
  • Loading branch information
tomkralidis committed Oct 7, 2023
1 parent ea019b7 commit bd79242
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 19 additions & 10 deletions pycsw/stac/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@


CONFORMANCE_CLASSES = [
'http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core',
'http://www.opengis.net/spec/ogcapi-common-2/1.0/conf/collections',
'http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core',
'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/queryables',
'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/queryables-query-parameters',
'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter',
'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter',
'http://www.opengis.net/spec/ogcapi-features-4/1.0/conf/create-replace-delete',
'http://www.opengis.net/spec/cql2/1.0/conf/cql2-json',
'http://www.opengis.net/spec/cql2/1.0/conf/cql2-text',
'https://api.stacspec.org/v1.0.0/core',
'https://api.stacspec.org/v1.0.0/ogcapi-features',
'https://api.stacspec.org/v1.0.0/item-search',
Expand Down Expand Up @@ -134,7 +144,7 @@ def landing_page(self, headers_, args):
'href': f"{self.config['server']['url']}/queryables"
}, {
'rel': 'search',
'type': 'application/json',
'type': 'application/geo+json',
'href': f"{self.config['server']['url']}/search"
}
]
Expand Down Expand Up @@ -174,12 +184,11 @@ def conformance(self, headers_, args):
headers_['Content-Type'] = 'application/json'
headers_['Accept'] = 'application/json'

headers, status, response = super().conformance(headers_, args)
response2 = json.loads(response)

response2['conformsTo'].extend(CONFORMANCE_CLASSES)
response = {
'conformsTo': CONFORMANCE_CLASSES
}

return self.get_response(200, headers_, response2)
return self.get_response(200, headers_, response)

def collections(self, headers_, args):
"""
Expand Down Expand Up @@ -248,7 +257,7 @@ def collections(self, headers_, args):
}, {
'rel': 'root',
'type': 'application/json',
'href': self.config['server']['url']
'href': f"{self.config['server']['url']}/"
}, {
'rel': 'parent',
'type': 'application/json',
Expand Down Expand Up @@ -291,7 +300,7 @@ def collection(self, headers_, args, collection='metadata:main'):
}, {
'rel': 'root',
'type': 'application/json',
'href': self.config['server']['url']
'href': f"{self.config['server']['url']}/"
}, {
'rel': 'parent',
'type': 'application/json',
Expand Down Expand Up @@ -354,7 +363,7 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
}, {
'rel': 'root',
'type': 'application/json',
'href': self.config['server']['url']
'href': f"{self.config['server']['url']}/"
}, {
'rel': 'parent',
'type': 'application/json',
Expand All @@ -371,7 +380,7 @@ def items(self, headers_, json_post_data, args, collection='metadata:main'):
response2['links'].extend([{
'rel': 'root',
'type': 'application/json',
'href': self.config['server']['url']
'href': f"{self.config['server']['url']}/"
}
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_landing_page(config):

assert content['stac_version'] == '1.0.0'
assert content['type'] == 'Catalog'
assert len(content['conformsTo']) == 4
assert len(content['conformsTo']) == 14
assert len(content['keywords']) == 3


Expand All @@ -70,7 +70,7 @@ def test_conformance(config):
assert headers['Content-Type'] == 'application/json'
assert status == 200

assert len(content['conformsTo']) == 18
assert len(content['conformsTo']) == 14

conformances = [
'https://api.stacspec.org/v1.0.0/core',
Expand Down

0 comments on commit bd79242

Please sign in to comment.