mirror of https://github.com/apache/superset.git
fix(api): fixes openapi spec errors and adds a test to validate all spec (#10393)
This commit is contained in:
parent
b438ba9ed5
commit
98a11e7cf2
|
@ -21,6 +21,7 @@ flask-testing==0.8.0
|
||||||
ipdb==0.12
|
ipdb==0.12
|
||||||
isort==4.3.21
|
isort==4.3.21
|
||||||
mypy==0.770
|
mypy==0.770
|
||||||
|
openapi-spec-validator==0.2.8
|
||||||
pytest==5.4.3
|
pytest==5.4.3
|
||||||
pytest-cov==2.10.0
|
pytest-cov==2.10.0
|
||||||
parameterized==0.7.4
|
parameterized==0.7.4
|
||||||
|
|
|
@ -645,7 +645,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Chart thumbnail image
|
description: Chart thumbnail image
|
||||||
/content:
|
content:
|
||||||
image/*:
|
image/*:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -31,13 +31,12 @@ get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}}
|
||||||
|
|
||||||
width_height_schema = {
|
width_height_schema = {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": [{"type": "integer"}, {"type": "integer"}],
|
"items": {"type": "integer"},
|
||||||
}
|
}
|
||||||
thumbnail_query_schema = {
|
thumbnail_query_schema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {"force": {"type": "boolean"}},
|
"properties": {"force": {"type": "boolean"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
screenshot_query_schema = {
|
screenshot_query_schema = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -48,6 +48,22 @@ class Model1Api(BaseSupersetModelRestApi):
|
||||||
appbuilder.add_api(Model1Api)
|
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):
|
class TestBaseModelRestApi(SupersetTestCase):
|
||||||
def test_default_missing_declaration_get(self):
|
def test_default_missing_declaration_get(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue