diff --git a/superset/charts/api.py b/superset/charts/api.py index 66c0781ffb31..e8be9e84261f 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -362,7 +362,7 @@ def post(self) -> Response: return self.response_400(message=error.messages) try: new_model = CreateChartCommand(item).run() - return self.response(201, id=new_model.id, result=item) + return self.response(201, id=new_model.id, result=item, uuid=new_model.uuid) except DashboardsForbiddenError as ex: return self.response(ex.status, message=ex.message) except ChartInvalidError as ex: diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index 4592138866e9..ba720798f982 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -702,7 +702,7 @@ def post(self) -> Response: return self.response_400(message=error.messages) try: new_model = CreateDashboardCommand(item).run() - return self.response(201, id=new_model.id, result=item) + return self.response(201, id=new_model.id, result=item, uuid=new_model.uuid) except DashboardInvalidError as ex: return self.response_422(message=ex.normalized_messages()) except DashboardCreateFailedError as ex: diff --git a/superset/datasets/api.py b/superset/datasets/api.py index dbb51b9bf355..aa9d9f160d5c 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -363,7 +363,7 @@ def post(self) -> Response: try: new_model = CreateDatasetCommand(item).run() - return self.response(201, id=new_model.id, result=item, data=new_model.data) + return self.response(201, id=new_model.id, result=item, data=new_model.data, uuid=new_model.uuid) except DatasetInvalidError as ex: return self.response_422(message=ex.normalized_messages()) except DatasetCreateFailedError as ex: diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py index b8b60355419a..c9aeec999345 100644 --- a/tests/integration_tests/charts/api_tests.py +++ b/tests/integration_tests/charts/api_tests.py @@ -556,6 +556,9 @@ def test_create_chart(self): assert rv.status_code == 201 data = json.loads(rv.data.decode("utf-8")) model = db.session.query(Slice).get(data.get("id")) + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) db.session.delete(model) db.session.commit() diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py index ca0e8fa8968e..67c22102d3dc 100644 --- a/tests/integration_tests/dashboards/api_tests.py +++ b/tests/integration_tests/dashboards/api_tests.py @@ -1591,6 +1591,9 @@ def test_create_dashboard(self): assert rv.status_code == 201 data = json.loads(rv.data.decode("utf-8")) model = db.session.query(Dashboard).get(data.get("id")) + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) db.session.delete(model) db.session.commit() diff --git a/tests/integration_tests/datasets/api_tests.py b/tests/integration_tests/datasets/api_tests.py index 6677f19f8ad1..8541176e8aed 100644 --- a/tests/integration_tests/datasets/api_tests.py +++ b/tests/integration_tests/datasets/api_tests.py @@ -725,6 +725,9 @@ def test_create_dataset_item(self): assert model.database_id == table_data["database"] # normalize_columns should default to False assert model.normalize_columns is False + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) # Assert that columns were created columns = (