jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
57 stars 59 forks source link

1.03 doesn't allow remote schemas with ids #74

Closed wbazant closed 7 years ago

wbazant commented 7 years ago

Test case: https://github.com/wbazant/json-validator/commit/27de57c1ae2c5022422919b69963cc4b32b845a0

#   Failed test 'remote ref - remote ref valid'
#   at t/acceptance.t line 52.
#          got: '0'
#     expected: '1'
# Invalid schema:
# /id: Does not match uri format. at /Users/wbazant/dev/json-validator/lib/JSON/Validator.pm line 70.
#   JSON::Validator::load_and_validate_schema('JSON::Validator=HASH(0x7f91a1d0ccf8)', 'HASH(0x7f91a16efa18)') called at t/acceptance.t line 46
#   eval {...} called at t/acceptance.t line 45
jhthorsen commented 7 years ago

Is that really a valid ID? Can you point me to the specification?

wbazant commented 7 years ago

Sure, that's fair to ask, especially that I didn't check this before submitting the issue! It is:

http://json-schema.org/schema says an id is a uri-reference: http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.3.7

https://tools.ietf.org/html/rfc3986 says an uri-reference can be an URI or a relative-ref (4.1) and (4.2) gives this grammar for relative-ref:

relative-ref  = relative-part [ "?" query ] [ "#" fragment ]

      relative-part = "//" authority path-abempty
                    / path-absolute
                    / path-noscheme
                    / path-empty
jhthorsen commented 7 years ago

I've opened a pull request now. Please have a look at #80.