Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ geode-simplex
geode-explicit
geode-implicit
geode-common
jsonschema
fastjsonschema
Flask[async]
Flask-Cors
werkzeug
8 changes: 3 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ blinker==1.9.0
# via flask
click==8.2.1
# via flask
fastjsonschema==2.21.1
# via -r requirements.in
flask[async]==3.1.1
# via
# -r requirements.in
Expand Down Expand Up @@ -60,10 +62,6 @@ itsdangerous==2.2.0
# via flask
jinja2==3.1.6
# via flask
jsonschema==4.24.0
# via -r requirements.in
jsonschema-specifications==2025.4.1
# via jsonschema
markupsafe==3.0.2
# via
# flask
Expand Down Expand Up @@ -120,4 +118,4 @@ werkzeug==3.1.3
# via
# -r requirements.in
# flask
# flask-cors
# flask-cors
9 changes: 4 additions & 5 deletions src/opengeodeweb_back/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ def test_route_wrong_params(client, route, get_full_data):
response = client.post(route, json=json)
assert response.status_code == 400
error_description = response.json["description"]
assert error_description == f"Validation error: '{key}' is a required property"
assert "data must contain" in error_description
assert f"'{key}'" in error_description

json = get_full_data()
json["dumb_key"] = "dumb_value"
response = client.post(route, json=json)
assert response.status_code == 400
error_description = response.json["description"]
assert (
error_description
== "Validation error: Additional properties are not allowed ('dumb_key' was unexpected)"
)
assert "data must not contain" in error_description
assert "'dumb_key'" in error_description
11 changes: 6 additions & 5 deletions src/opengeodeweb_back/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

# Third party imports
import flask
from jsonschema import validate
from jsonschema.exceptions import ValidationError
import fastjsonschema
import importlib.metadata as metadata

# Local application imports
Expand Down Expand Up @@ -82,9 +81,11 @@ def validate_request(request, schema):
json_data = {}

try:
validate(instance=json_data, schema=schema)
except ValidationError as e:
flask.abort(400, f"Validation error: {e.message}")
validate = fastjsonschema.compile(schema)
validate(json_data)
except fastjsonschema.JsonSchemaException as e:
error_msg = str(e)
flask.abort(400, error_msg)


def set_interval(func, sec, args=None):
Expand Down