mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: initial work to make v1 API compatible with SIP-40 and SIP-41 (#13960)
* WIP * Use errorhandler * Add response schema * Fix status on HTTPException * s/found/encountered/g * Fix test * Fix lint * Fix lint and test
This commit is contained in:
@@ -35,6 +35,7 @@ from superset.extensions import db, event_logger, security_manager
|
||||
from superset.models.core import FavStar
|
||||
from superset.models.dashboard import Dashboard
|
||||
from superset.models.slice import Slice
|
||||
from superset.schemas import error_payload_content
|
||||
from superset.sql_lab import Query as SqllabQuery
|
||||
from superset.stats_logger import BaseStatsLogger
|
||||
from superset.typing import FlaskResponse
|
||||
@@ -77,7 +78,12 @@ def statsd_metrics(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||
"""
|
||||
|
||||
def wraps(self: "BaseSupersetModelRestApi", *args: Any, **kwargs: Any) -> Response:
|
||||
duration, response = time_function(f, self, *args, **kwargs)
|
||||
try:
|
||||
duration, response = time_function(f, self, *args, **kwargs)
|
||||
except Exception as ex:
|
||||
self.incr_stats("error", f.__name__)
|
||||
raise ex
|
||||
|
||||
self.send_stats_metrics(response, f.__name__, duration)
|
||||
return response
|
||||
|
||||
@@ -198,6 +204,18 @@ class BaseSupersetModelRestApi(ModelRestApi):
|
||||
list_columns: List[str]
|
||||
show_columns: List[str]
|
||||
|
||||
responses = {
|
||||
"400": {"description": "Bad request", "content": error_payload_content},
|
||||
"401": {"description": "Unauthorized", "content": error_payload_content},
|
||||
"403": {"description": "Forbidden", "content": error_payload_content},
|
||||
"404": {"description": "Not found", "content": error_payload_content},
|
||||
"422": {
|
||||
"description": "Could not process entity",
|
||||
"content": error_payload_content,
|
||||
},
|
||||
"500": {"description": "Fatal error", "content": error_payload_content},
|
||||
}
|
||||
|
||||
def __init__(self) -> None:
|
||||
# Setup statsd
|
||||
self.stats_logger = BaseStatsLogger()
|
||||
|
||||
Reference in New Issue
Block a user