diff --git a/pygeoapi/flask_app.py b/pygeoapi/flask_app.py index 4bed078..061ef62 100644 --- a/pygeoapi/flask_app.py +++ b/pygeoapi/flask_app.py @@ -84,9 +84,10 @@ def api_conformance(): @APP.route('/collections') -def describe_collections(): +@APP.route('/collections/') +def describe_collections(name=None): headers, status_code, content = views.describe_collections( - request.headers, request.args) + request.headers, request.args, name) response = make_response(content, status_code) if headers: @@ -95,8 +96,8 @@ def describe_collections(): return response -@APP.route('/collections//') -@APP.route('/collections//') +@APP.route('/collections//items') +@APP.route('/collections//items/') def dataset(feature_collection, feature=None): if feature is None: headers, status_code, content = views.get_features( diff --git a/pygeoapi/openapi.py b/pygeoapi/openapi.py index 277eb32..5001f3e 100644 --- a/pygeoapi/openapi.py +++ b/pygeoapi/openapi.py @@ -149,8 +149,29 @@ def get_oas_30(cfg): tag['externalDocs']['description'] = link['type'] tag['externalDocs']['url'] = link['url'] break + oas['tags'].append(tag) + paths['/collections/{}'.format(k)] = { + 'get': { + 'summary': 'Get feature collection metadata'.format(v['title']), # noqa + 'description': v['description'], + 'tags': [k], + 'responses': { + 200: { + 'description': 'successful operation' + }, + 400: { + 'description': 'Invalid ID supplied' + }, + 404: { + 'description': 'not found' + } + } + } + } + + paths['/collections/{}/items'.format(k)] = { 'get': { 'summary': 'Get {} features'.format(v['title']), 'description': v['description'], diff --git a/pygeoapi/views.py b/pygeoapi/views.py index 0042fef..c6d611f 100644 --- a/pygeoapi/views.py +++ b/pygeoapi/views.py @@ -150,7 +150,7 @@ def api_conformance(headers, args): return headers_, 200, json.dumps(conformance) -def describe_collections(headers, args): +def describe_collections(headers, args, name=None): """ Provide feature collection metadata @@ -194,6 +194,9 @@ def describe_collections(headers, args): lnk = {'rel': link['type'], 'href': link['url']} collection['links'].append(lnk) + if name is not None and k == name: + return headers_, 200, json.dumps(collection) + fcm['collections'].append(collection) if format_ == 'html': # render