summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/api/traces.py
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-02 14:26:23 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-02 18:07:42 +0200
commit45b73e4683cce35de79117c5b4a6919556d9644f (patch)
treefdbb282b639d03e0cc940c8587d5fe90c2283aa5 /opendc-web/opendc-web-api/opendc/api/traces.py
parente2ec16a1a40f3ffc437378b4e22fda64f86fe284 (diff)
api: Add stricter validation of input/output data
This change adds stricter validation of data that enters and leaves the database. As a result, we clearly separate the database model from the data model that the REST API exports.
Diffstat (limited to 'opendc-web/opendc-web-api/opendc/api/traces.py')
-rw-r--r--opendc-web/opendc-web-api/opendc/api/traces.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/opendc-web/opendc-web-api/opendc/api/traces.py b/opendc-web/opendc-web-api/opendc/api/traces.py
index f685f00c..6be8c5e5 100644
--- a/opendc-web/opendc-web-api/opendc/api/traces.py
+++ b/opendc-web/opendc-web-api/opendc/api/traces.py
@@ -21,7 +21,7 @@
from flask_restful import Resource
from opendc.exts import requires_auth
-from opendc.models.trace import Trace as TraceModel
+from opendc.models.trace import Trace as TraceModel, TraceSchema
class TraceList(Resource):
@@ -33,7 +33,7 @@ class TraceList(Resource):
def get(self):
"""Get all available Traces."""
traces = TraceModel.get_all()
- data = traces.obj
+ data = TraceSchema().dump(traces.obj, many=True)
return {'data': data}
@@ -47,5 +47,5 @@ class Trace(Resource):
"""Get trace information by identifier."""
trace = TraceModel.from_id(trace_id)
trace.check_exists()
- data = trace.obj
+ data = TraceSchema().dump(trace.obj)
return {'data': data}