Skip to content

Commit e948993

Browse files
author
Joel Collins
committed
Removed automatic schema generator
1 parent 03d1fd6 commit e948993

File tree

11 files changed

+69
-500
lines changed

11 files changed

+69
-500
lines changed

src/labthings/server/representations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def default(self, o):
1919
if isinstance(o, set):
2020
return list(o)
2121
if isinstance(o, bytes):
22-
return b64encode(o).decode()
22+
try: # Try unicode
23+
return o.decode()
24+
except UnicodeDecodeError: # Otherwise, base64
25+
return b64encode(o).decode()
2326
return JSONEncoder.default(self, o)
2427

2528

@@ -32,7 +35,7 @@ def output_json(data, code, headers=None):
3235
"""Makes a Flask response with a JSON encoded body, using app JSON settings"""
3336

3437
settings = current_app.config.get("LABTHINGS_JSON", {})
35-
encoder = current_app.json_encoder
38+
encoder = LabThingsJSONEncoder
3639

3740
if current_app.debug:
3841
settings.setdefault("indent", 4)
@@ -55,7 +58,6 @@ def output_cbor(data, code, headers=None):
5558
"""Makes a Flask response with a CBOR encoded body, using app CBOR settings"""
5659

5760
settings = current_app.config.get("LABTHINGS_CBOR", {})
58-
5961
dumped = encode_cbor(data, **settings)
6062

6163
resp = make_response(dumped, code)

src/labthings/server/types/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/labthings/server/types/annotations.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/labthings/server/types/preprocess.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/labthings/server/types/properties.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/labthings/server/types/registry.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/labthings/server/view/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from flask.views import MethodView
22
from flask import request
33
from werkzeug.wrappers import Response as ResponseBase
4+
from werkzeug.exceptions import BadRequest
45

56
from collections import OrderedDict
67

@@ -77,7 +78,6 @@ def represent_response(self, response):
7778
response = representations[mediatype](data, code, headers)
7879
response.headers["Content-Type"] = mediatype
7980
return response
80-
8181
return response
8282

8383

@@ -95,7 +95,10 @@ def dispatch_request(self, *args, **kwargs):
9595
task = taskify(meth)(*args, **kwargs)
9696

9797
# Keep a copy of the raw, unmarshalled JSON input in the task
98-
task.input = request.json
98+
try:
99+
task.input = request.json
100+
except BadRequest:
101+
task.input = None
99102

100103
# Wait up to 2 second for the action to complete or error
101104
try:

0 commit comments

Comments
 (0)