Skip to content

Commit 3cac2f3

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

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
@@ -21,7 +21,13 @@
2121
]
2222

2323
extras_require = {
24-
"format" : ["jsonpointer>1.13", "rfc3987", "strict-rfc3339", "webcolors"],
24+
"format": [
25+
"jsonpointer>1.13",
26+
"rfc3987",
27+
"strict-rfc3339",
28+
"uritemplate>3.0.0",
29+
"webcolors",
30+
],
2531
":python_version=='2.7'": ["functools32"],
2632
}
2733

0 commit comments

Comments
 (0)