diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index b4cc845..4fb9fa1 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -254,6 +254,7 @@ by downstream applications. `local-outlier-factor-plugin`_,Manaaki Whenua – Landcare Research,processes for local outlier detection `ogc-edc`_,Euro Data Cube,coverage provider atop the EDC API `nldi_xstool`_,United States Geological Survey,Water data processing + `pygeometa-plugin`_,pygeometa project,pygeometa as a service .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter-pypackage @@ -263,3 +264,4 @@ by downstream applications. .. _`ogc-edc`: https://github.com/eurodatacube/ogc-edc/tree/oapi/edc_ogc/pygeoapi .. _`nldi_xstool`: https://github.com/ACWI-SSWD/nldi_xstool .. _`pygeoapi-plugin-cookiecutter`: https://code.usgs.gov/wma/nhgf/pygeoapi-plugin-cookiecutter +.. _`pygeometa-plugin`: https://geopython.github.io/pygeometa/pygeoapi-plugin diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 103cac2..00f1160 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -1271,6 +1271,8 @@ class API: return headers, 200, content + headers['Content-Type'] = 'application/schema+json' + return headers, 200, to_json(queryables, self.pretty_print) @gzip diff --git a/pygeoapi/django_/views.py b/pygeoapi/django_/views.py index ac07cc0..2540878 100644 --- a/pygeoapi/django_/views.py +++ b/pygeoapi/django_/views.py @@ -140,9 +140,13 @@ def collection_items(request: HttpRequest, collection_id: str) -> HttpResponse: collection_id, ) elif request.method == 'POST': - response_ = _feed_response( - request, 'manage_collection_item', request, 'create', collection_id - ) + if request.content_type is not None: + if request.content_type == 'application/geo+json': + response_ = _feed_response(request, 'manage_collection_item', + request, 'create', collection_id) + else: + response_ = _feed_response(request, 'post_collection_items', + request, collection_id) response = _to_django_response(*response_) diff --git a/pygeoapi/flask_app.py b/pygeoapi/flask_app.py index 0dbcd66..1a9457f 100644 --- a/pygeoapi/flask_app.py +++ b/pygeoapi/flask_app.py @@ -195,12 +195,13 @@ def collection_items(collection_id, item_id=None): api_.get_collection_items(request, collection_id)) elif request.method == 'POST': # filter or manage items if request.content_type is not None: - return get_response( - api_.manage_collection_item(request, 'create', - collection_id)) - else: - return get_response( - api_.post_collection_items(request, collection_id)) + if request.content_type == 'application/geo+json': + return get_response( + api_.manage_collection_item(request, 'create', + collection_id)) + else: + return get_response( + api_.post_collection_items(request, collection_id)) elif request.method == 'DELETE': return get_response( diff --git a/pygeoapi/starlette_app.py b/pygeoapi/starlette_app.py index c287b2f..307d7d5 100644 --- a/pygeoapi/starlette_app.py +++ b/pygeoapi/starlette_app.py @@ -233,13 +233,15 @@ async def collection_items(request: Request, collection_id=None, item_id=None): api_.get_collection_items( request, collection_id)) elif request.method == 'POST': # filter or manage items - if request.headers.get('content-type') is not None: - return get_response( - api_.manage_collection_item(request, 'create', - collection_id)) - else: - return get_response( - api_.post_collection_items(request, collection_id)) + content_type = request.headers.get('content-type') + if content_type is not None: + if content_type == 'application/geo+json': + return get_response( + api_.manage_collection_item(request, 'create', + collection_id)) + else: + return get_response( + api_.post_collection_items(request, collection_id)) elif request.method == 'DELETE': return get_response( diff --git a/tests/test_api.py b/tests/test_api.py index 2ade9ab..ea2ae3c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -536,6 +536,7 @@ def test_get_collection_queryables(config, api_): req = mock_request({'f': 'json'}) rsp_headers, code, response = api_.get_collection_queryables(req, 'obs') + assert rsp_headers['Content-Type'] == 'application/schema+json' queryables = json.loads(response) assert 'properties' in queryables