Skip to content

Commit ab82fe5

Browse files
committed
Start on uri-template based on the provisional API.
Will probably change as python-hyper/uritemplate#36 is merged.
1 parent 1d2a119 commit ab82fe5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jsonschema/_format.py

+16
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,22 @@ def is_json_pointer(instance):
299299
return jsonpointer.JsonPointer(instance)
300300

301301

302+
try:
303+
import uritemplate.exceptions
304+
except ImportError:
305+
pass
306+
else:
307+
@_checks_drafts(
308+
draft6="uri-template", raises=uritemplate.exceptions.InvalidTemplate,
309+
)
310+
def is_uri_template(
311+
instance,
312+
template_validator=uritemplate.Validator().force_balanced_braces(),
313+
):
314+
template = uritemplate.URITemplate(instance)
315+
return template_validator.validate(template)
316+
317+
302318
draft3_format_checker = FormatChecker(_draft_checkers["draft3"])
303319
draft4_format_checker = FormatChecker(_draft_checkers["draft4"])
304320
draft6_format_checker = FormatChecker(_draft_checkers["draft6"])

setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
]
2525

2626
extras_require = {
27-
"format" : ["jsonpointer>1.13", "rfc3987", "strict-rfc3339", "webcolors"],
27+
"format": [
28+
"jsonpointer>1.13",
29+
"rfc3987",
30+
"strict-rfc3339",
31+
"uritemplate>3.0.0",
32+
"webcolors",
33+
],
2834
":python_version=='2.7'": ["functools32"],
2935
}
3036

0 commit comments

Comments
 (0)