Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fixes openapi spec errors and adds a test to validate all spec #10393

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def thumbnail(
responses:
200:
description: Chart thumbnail image
/content:
content:
image/*:
schema:
type: string
Expand Down
3 changes: 1 addition & 2 deletions superset/charts/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@

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": {
Expand Down
16 changes: 16 additions & 0 deletions tests/base_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down