Skip to content

Fixes validation for uri-template format #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2021
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
13 changes: 5 additions & 8 deletions jsonschema/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,15 @@ def is_relative_json_pointer(instance):


try:
import uritemplate.exceptions
import uri_template
except ImportError:
pass
else:
@_checks_drafts(
draft6="uri-template",
draft7="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)
def is_uri_template(instance):
if not isinstance(instance, str):
return True
return uri_template.validate(instance)
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ format =
rfc3987
strict-rfc3339
webcolors
uri_template
format_nongpl =
fqdn
idna
jsonpointer>1.13
webcolors
rfc3986-validator>0.1.0
rfc3339-validator
uri_template

[options.entry_points]
console_scripts =
Expand Down