From 3f88575648ef82f4cbc90cfe402eaf9b18fc5e29 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 5 Oct 2019 16:57:30 +0200 Subject: [PATCH] Fix service-doc and service-desc inversion, and update media type of openapi+json (#270) * Landing page: fix inversion of service-doc and service-desc service-desc should be for the OpenAPI version of /api, and service-doc for the HTML version See Abstract Test 40 of http://docs.opengeospatial.org/DRAFTS/17-069r3.html * Update media type for OpenAPI JSon 3.0 --- pygeoapi/api.py | 9 +++++---- tests/test_api.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 9f67795..765eb92 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -142,12 +142,12 @@ class API(object): 'href': '{}?f=html'.format(self.config['server']['url']), 'hreflang': self.config['server']['language'] }, { - 'rel': 'service-doc', - 'type': 'application/openapi+json;version=3.0', + 'rel': 'service-desc', + 'type': 'application/vnd.oai.openapi+json;version=3.0', 'title': 'The OpenAPI definition as JSON', 'href': '{}/api'.format(self.config['server']['url']) }, { - 'rel': 'service-desc', + 'rel': 'service-doc', 'type': 'text/html', 'title': 'The OpenAPI definition as HTML', 'href': '{}/api?f=html'.format(self.config['server']['url']), @@ -208,7 +208,8 @@ class API(object): content = _render_j2_template(self.config, 'api.html', data) return headers_, 200, content - headers_['Content-Type'] = 'application/openapi+json;version=3.0' + headers_['Content-Type'] = \ + 'application/vnd.oai.openapi+json;version=3.0' return headers_, 200, json.dumps(openapi) diff --git a/tests/test_api.py b/tests/test_api.py index d1f3fb2..ce7ffc1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -79,7 +79,7 @@ def test_api(config, api_, openapi): req_headers = make_req_headers(HTTP_CONTENT_TYPE='application/json') rsp_headers, code, response = api_.api(req_headers, {}, openapi) assert rsp_headers['Content-Type'] ==\ - 'application/openapi+json;version=3.0' + 'application/vnd.oai.openapi+json;version=3.0' root = json.loads(response) assert isinstance(root, dict)