File tree Expand file tree Collapse file tree 4 files changed +58
-7
lines changed Expand file tree Collapse file tree 4 files changed +58
-7
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "python.testing.pytestArgs" : [
3+ " ."
4+ ],
5+ "python.testing.unittestEnabled" : false ,
6+ "python.testing.pytestEnabled" : true
7+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,6 @@ OpenGeode-Inspector
44OpenGeode-Geosciences
55OpenGeode-GeosciencesIO
66Geode-Viewables
7+ jsonschema
8+ flask[async]
9+ werkzeug
Original file line number Diff line number Diff line change 11#
2- # This file is autogenerated by pip-compile with Python 3.9
2+ # This file is autogenerated by pip-compile with Python 3.10
33# by the following command:
44#
5- # pip-compile --resolver=backtracking requirements.in
5+ # pip-compile
66#
7+ asgiref == 3.7.2
8+ # via flask
9+ attrs == 23.1.0
10+ # via
11+ # jsonschema
12+ # referencing
13+ blinker == 1.7.0
14+ # via flask
15+ click == 8.1.7
16+ # via flask
17+ flask [async ]== 3.0.0
18+ # via -r requirements.in
719geode-common == 29.0.1
820 # via geode-viewables
921geode-viewables == 2.1.3
1022 # via -r requirements.in
23+ itsdangerous == 2.1.2
24+ # via flask
25+ jinja2 == 3.1.2
26+ # via flask
27+ jsonschema == 4.19.2
28+ # via -r requirements.in
29+ jsonschema-specifications == 2023.7.1
30+ # via jsonschema
31+ markupsafe == 2.1.3
32+ # via
33+ # jinja2
34+ # werkzeug
1135opengeode-core == 14.9.3
1236 # via
1337 # -r requirements.in
@@ -34,3 +58,17 @@ opengeode-io==6.2.1
3458 # -r requirements.in
3559 # geode-viewables
3660 # opengeode-inspector
61+ referencing == 0.30.2
62+ # via
63+ # jsonschema
64+ # jsonschema-specifications
65+ rpds-py == 0.12.0
66+ # via
67+ # jsonschema
68+ # referencing
69+ typing-extensions == 4.8.0
70+ # via asgiref
71+ werkzeug == 3.0.1
72+ # via
73+ # -r requirements.in
74+ # flask
Original file line number Diff line number Diff line change 1111import opengeode as og
1212import pkg_resources
1313import werkzeug
14+ from jsonschema import validate
15+ from jsonschema .exceptions import ValidationError
1416
1517# Local application imports
1618from .geode_objects import geode_objects_dict
@@ -234,15 +236,16 @@ def extension_from_filename(filename):
234236 return os .path .splitext (filename )[1 ][1 :]
235237
236238
237- def validate_request (request , variables_array ):
239+ def validate_request (request , schema ):
238240 json_data = request .get_json (force = True , silent = True )
239241
240242 if json_data is None :
241- flask . abort ( 400 , f"No json sent" )
243+ json_data = {}
242244
243- for variable in variables_array :
244- if variable not in json_data .keys ():
245- flask .abort (400 , f"No { variable } sent" )
245+ try :
246+ validate (instance = json_data , schema = schema )
247+ except ValidationError as e :
248+ flask .abort (400 , f"Validation error: { e .message } " )
246249
247250
248251def geographic_coordinate_systems (geode_object : str ):
You can’t perform that action at this time.
0 commit comments