You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/07/21 23:31:49 UTC
[superset] branch master updated: chore(view_api): return application/json as content-type for api/v1/form_data endpoint (#24758)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 0631a8086c chore(view_api): return application/json as content-type for api/v1/form_data endpoint (#24758)
0631a8086c is described below
commit 0631a8086cd95f3b6e88b31d29c7fbc2e1d20b25
Author: Zef Lin <ze...@preset.io>
AuthorDate: Fri Jul 21 16:31:41 2023 -0700
chore(view_api): return application/json as content-type for api/v1/form_data endpoint (#24758)
---
superset/views/api.py | 2 +-
tests/integration_tests/charts/api_tests.py | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/superset/views/api.py b/superset/views/api.py
index 84c27d2fac..267d41dd75 100644
--- a/superset/views/api.py
+++ b/superset/views/api.py
@@ -86,7 +86,7 @@ class Api(BaseSupersetView):
update_time_range(form_data)
- return json.dumps(form_data)
+ return self.json_response(form_data)
@api
@handle_api_exception
diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py
index 2db0cc7de3..c5e88426fa 100644
--- a/tests/integration_tests/charts/api_tests.py
+++ b/tests/integration_tests/charts/api_tests.py
@@ -1424,6 +1424,20 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
self.assertEqual(rv.status_code, 200)
self.assertEqual(len(data["result"]), 3)
+ def test_query_form_data(self):
+ """
+ Chart API: Test query form data
+ """
+ self.login(username="admin")
+ slice = db.session.query(Slice).first()
+ uri = f"api/v1/form_data/?slice_id={slice.id if slice else None}"
+ rv = self.client.get(uri)
+ data = json.loads(rv.data.decode("utf-8"))
+ self.assertEqual(rv.status_code, 200)
+ self.assertEqual(rv.content_type, "application/json")
+ if slice:
+ self.assertEqual(data["slice_id"], slice.id)
+
@pytest.mark.usefixtures(
"load_unicode_dashboard_with_slice",
"load_energy_table_with_slice",