Skip to content

Commit

Permalink
Start on uri-template based on the provisional API.
Browse files Browse the repository at this point in the history
Will probably change as python-hyper/uritemplate#36
is merged.
  • Loading branch information
Julian committed Oct 29, 2017
1 parent 1d2a119 commit ab82fe5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions jsonschema/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,22 @@ def is_json_pointer(instance):
return jsonpointer.JsonPointer(instance)


try:
import uritemplate.exceptions
except ImportError:
pass
else:
@_checks_drafts(
draft6="uri-template", raises=uritemplate.exceptions.InvalidTemplate,
)
def is_uri_template(
instance,
template_validator=uritemplate.Validator().force_balanced_braces(),
):
template = uritemplate.URITemplate(instance)
return template_validator.validate(template)


draft3_format_checker = FormatChecker(_draft_checkers["draft3"])
draft4_format_checker = FormatChecker(_draft_checkers["draft4"])
draft6_format_checker = FormatChecker(_draft_checkers["draft6"])
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
]

extras_require = {
"format" : ["jsonpointer>1.13", "rfc3987", "strict-rfc3339", "webcolors"],
"format": [
"jsonpointer>1.13",
"rfc3987",
"strict-rfc3339",
"uritemplate>3.0.0",
"webcolors",
],
":python_version=='2.7'": ["functools32"],
}

Expand Down

0 comments on commit ab82fe5

Please sign in to comment.