update queryables response
This commit is contained in:
committed by
paul van genuchten
parent
dea90efcfb
commit
e0003b066b
@@ -62,7 +62,7 @@ Collection queryables
|
||||
|
||||
http://localhost:5000/collections/obs/queryables
|
||||
|
||||
The queryables endpoint provides a list of queryable properties and their associated datatypes.
|
||||
The queryables endpoint provides the collection's queryable properties and associated datatypes.
|
||||
|
||||
|
||||
Collection items
|
||||
|
||||
+12
-5
@@ -696,7 +696,12 @@ class API:
|
||||
return headers_, 500, to_json(exception, self.pretty_print)
|
||||
|
||||
queryables = {
|
||||
'queryables': []
|
||||
'type': 'object',
|
||||
'title': self.config['resources'][dataset]['title'],
|
||||
'properties': {},
|
||||
'$schema': 'http://json-schema.org/draft/2019-09/schema',
|
||||
'$id': '{}/collections/{}/queryables'.format(
|
||||
self.config['server']['url'], dataset)
|
||||
}
|
||||
|
||||
for k, v in p.fields.items():
|
||||
@@ -708,10 +713,12 @@ class API:
|
||||
show_field = True
|
||||
|
||||
if show_field:
|
||||
queryables['queryables'].append({
|
||||
'queryable': k,
|
||||
'type': v
|
||||
})
|
||||
queryables['properties'][k] = {
|
||||
'title': k,
|
||||
'type': v['type']
|
||||
}
|
||||
if 'values' in v:
|
||||
queryables['properties'][k]['enum'] = v['values']
|
||||
|
||||
if format_ == 'html': # render
|
||||
queryables['title'] = self.config['resources'][dataset]['title']
|
||||
|
||||
+4
-4
@@ -258,8 +258,8 @@ def test_get_collection_queryables(config, api_):
|
||||
req_headers, {'f': 'json'}, 'obs')
|
||||
queryables = json.loads(response)
|
||||
|
||||
assert 'queryables' in queryables
|
||||
assert len(queryables['queryables']) == 6
|
||||
assert 'properties' in queryables
|
||||
assert len(queryables['properties']) == 6
|
||||
|
||||
# test with provider filtered properties
|
||||
api_.config['resources']['obs']['providers'][0]['properties'] = ['stn_id']
|
||||
@@ -268,8 +268,8 @@ def test_get_collection_queryables(config, api_):
|
||||
req_headers, {'f': 'json'}, 'obs')
|
||||
queryables = json.loads(response)
|
||||
|
||||
assert 'queryables' in queryables
|
||||
assert len(queryables['queryables']) == 1
|
||||
assert 'properties' in queryables
|
||||
assert len(queryables['properties']) == 1
|
||||
|
||||
|
||||
def test_describe_collections_json_ld(config, api_):
|
||||
|
||||
Reference in New Issue
Block a user