Skip to content

Commit dccb6e3

Browse files
committed
Merge branch 'fix/fast_json_schema' of https://github.com/Geode-solutions/OpenGeodeWeb-Back into fix/fast_json_schema
2 parents 9ad7016 + 582687f commit dccb6e3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/opengeodeweb_back/utils_functions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ def validate_request(request, schema):
8585
validate(json_data)
8686
except fastjsonschema.JsonSchemaException as e:
8787
error_msg = str(e)
88-
flask.abort(400, error_msg)
88+
89+
if "data must contain" in error_msg:
90+
field = error_msg.split("data must contain ['")[1].split("']")[0]
91+
error_msg = f"'{field}' is a required property"
92+
elif "data must not contain" in error_msg:
93+
field = error_msg.split("data must not contain {'")[1].split("'")[0]
94+
error_msg = f"Additional properties are not allowed ('{field}' was unexpected)"
95+
96+
flask.abort(400, f"Validation error: {error_msg}")
8997

9098

9199
def set_interval(func, sec, args=None):

0 commit comments

Comments
 (0)