You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2020/07/23 09:43:56 UTC
[incubator-superset] branch master updated: fix(api): fixes openapi
spec errors and adds a test to validate all spec (#10393)
This is an automated email from the ASF dual-hosted git repository.
dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 98a11e7 fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393)
98a11e7 is described below
commit 98a11e7cf216239df61b7da231c1c99cdbeaca23
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Thu Jul 23 10:43:41 2020 +0100
fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393)
---
requirements-dev.txt | 1 +
superset/charts/api.py | 2 +-
superset/charts/schemas.py | 3 +--
tests/base_api_tests.py | 16 ++++++++++++++++
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 399f9b7..c478ddd 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -21,6 +21,7 @@ flask-testing==0.8.0
ipdb==0.12
isort==4.3.21
mypy==0.770
+openapi-spec-validator==0.2.8
pytest==5.4.3
pytest-cov==2.10.0
parameterized==0.7.4
diff --git a/superset/charts/api.py b/superset/charts/api.py
index 6c8635b..4901041 100644
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -645,7 +645,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
responses:
200:
description: Chart thumbnail image
- /content:
+ content:
image/*:
schema:
type: string
diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py
index 3856404..0449f65 100644
--- a/superset/charts/schemas.py
+++ b/superset/charts/schemas.py
@@ -31,13 +31,12 @@ get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}}
width_height_schema = {
"type": "array",
- "items": [{"type": "integer"}, {"type": "integer"}],
+ "items": {"type": "integer"},
}
thumbnail_query_schema = {
"type": "object",
"properties": {"force": {"type": "boolean"}},
}
-
screenshot_query_schema = {
"type": "object",
"properties": {
diff --git a/tests/base_api_tests.py b/tests/base_api_tests.py
index ba7dde5..2be642c 100644
--- a/tests/base_api_tests.py
+++ b/tests/base_api_tests.py
@@ -48,6 +48,22 @@ class Model1Api(BaseSupersetModelRestApi):
appbuilder.add_api(Model1Api)
+class TestOpenApiSpec(SupersetTestCase):
+ def test_open_api_spec(self):
+ """
+ API: Test validate OpenAPI spec
+ :return:
+ """
+ from openapi_spec_validator import validate_spec
+
+ self.login(username="admin")
+ uri = "api/v1/_openapi"
+ rv = self.client.get(uri)
+ self.assertEqual(rv.status_code, 200)
+ response = json.loads(rv.data.decode("utf-8"))
+ validate_spec(response)
+
+
class TestBaseModelRestApi(SupersetTestCase):
def test_default_missing_declaration_get(self):
"""