Skip to content

Commit ee664f8

Browse files
committed
Use jsonschema draft-6
For now, this needs the pre-release version of jsonschema: * python-jsonschema/jsonschema#337 * https://pypi.org/project/jsonschema/#history
1 parent 2271b01 commit ee664f8

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ tool.)
9696
9797
virtualenv -p python3 env
9898
source env/bin/activate
99+
pip install --upgrade --pre jsonschema
99100
pip install -r requirements.txt
100101
pip install -e .
101102

buildspec.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ phases:
33
pre_build:
44
commands:
55
- pip install --upgrade pip wheel -r requirements.txt .
6+
- pip install --upgrade --pre jsonschema
67
build:
78
commands:
89
- isort --check-only --verbose --recursive "setup.py" "run_lint" "uluru/" "tests/"

uluru/data_loaders.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import json
22
import logging
33

4-
import jsonschema
54
import pkg_resources
65
import yaml
6+
from jsonschema import Draft6Validator
7+
from jsonschema.exceptions import ValidationError
78

89
LOG = logging.getLogger(__name__)
910

@@ -22,10 +23,10 @@ def load_resource_spec(resource_spec_file):
2223
) as f:
2324
resource_spec_schema = json.load(f)
2425

26+
validator = Draft6Validator(resource_spec_schema)
2527
try:
26-
jsonschema.validate(resource_spec, resource_spec_schema)
27-
# the unit tests should catch `SchemaError`/if the schema is invalid
28-
except jsonschema.exceptions.ValidationError as e:
28+
validator.validate(resource_spec)
29+
except ValidationError as e:
2930
LOG.error(
3031
"The resource provider definition is invalid: %s", e.message # noqa: B306
3132
)
@@ -57,10 +58,10 @@ def load_project_settings(plugin, project_settings_file):
5758
"to further customize code generation."
5859
)
5960

61+
validator = Draft6Validator(plugin.project_settings_schema())
6062
try:
61-
jsonschema.validate(project_settings, plugin.project_settings_schema())
62-
# the unit tests should catch `SchemaError`/if the schema is invalid
63-
except jsonschema.exceptions.ValidationError as e:
63+
validator.validate(project_settings)
64+
except ValidationError as e:
6465
LOG.error("The project settings are invalid: %s", e.message) # noqa: B306
6566
raise # TODO: error handling
6667

0 commit comments

Comments
 (0)