json-schema-org / JSON-Schema-Test-Suite

A language agnostic test suite for the JSON Schema specifications
MIT License
625 stars 209 forks source link

Make all root $ids absolute URIs #667

Closed jdesrosiers closed 1 year ago

jdesrosiers commented 1 year ago

I noticed that there are a few root $ids in some tests that aren't absolute. These tests should work if the test harness assigns an arbitrary retrieval URI, but I don't think that should be expected.

Julian commented 1 year ago

Will have a closer look but at first scan looks right to me.

jdesrosiers commented 1 year ago

Works for me, but yeah mine converts to an absolute URI, so maybe not the best yardstick.

I do something similar. My test harness generates a retrieval URI for each test that resolves against the schema's $id (if any) so I always have a non-relative URI. However, I ran in to a problem when you added the tests for file: URIs. My implementation has a restriction that you can't go from http: to file:. Browsers have a similar rule for security purposes. So, my implementation (correctly) started throwing an error when it received a file: $id from an http: retrieval URI. But, that's not a problem with the test, it's a problem with the test harness.

So, I decided to change my test harness to use $id as the retrieval URI if it existed to avoid this problem. That's when I ran into this problem with relative $ids.