#67 validation fails on F30, with latest python-jsonschema (version > 3.0)
Closed by ralph. Opened by mvadkert.

Seems new jsonschema is trying to validate refurls, which are invalid.


(Let's just remove the refurls. I'm not sure what they're useful for.)

yeah, seen this too. The documentation for $id doesn't absolutely state that the URI has to be valid, but I think what we're running into here is this bit:

"But be aware of the second purpose of the $id property: that it declares a base URL for relative $ref URLs elsewhere in the file. For example, if you had:

{ "$ref": "person.json" }

in the same file, a JSON schema validation library that supported network fetching would fetch person.json from http://foo.bar/schemas/person.json, even if address.json was loaded from somewhere else, such as the local filesystem."

okay, so the doc is slightly confusing about what is allowed here because I think it is using incorrect terminology. Specifically, it keeps saying that $ids and $refs should be "URIs", but it gives examples which are not strictly speaking URIs, like here:

"$ref can also be a relative or absolute URI, so if you prefer to include your definitions in separate files, you can also do that. For example:

{ "$ref": "definitions.json#/address" }

would load the address schema from another file residing alongside this one."

But...definitions.json#/address is not strictly a URI, because a URI requires a scheme. I believe the correct terminology here would be that this is a "relative URI reference", per this bit of the spec.

It seems pretty definite from the examples and context in the doc that it is valid for $refs to be relative references. It's also clear that $ids for lower-level schemas can be relative references. It's not entirely clear whether it's considered valid for top-level schema $ids to be relative references, such that there is no absolute URI for anything anywhere in the whole set of schemas. However, I tried it, and it seems like doing that does work with Python jsonschema at least, so I guess that's what we should do at least for now...

Ah, OK, so if I look at the actual JSON Schema IETF draft, this is a little clearer. Section 8.2 covers $id and states "If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference [RFC3986]." (note "URI-reference" not "URI"). Section 8.3 covers $ref and states "The value of the "$ref" property MUST be a URI Reference." So I think we're good. I sent a PR for the json-schema.org docs.

Sections 8.3.1-8.3.2 are also interesting (though hard to parse) and may suggest that jsonschema is doing the wrong thing here: I think it's trying to say that jsonschema should realize the schema is available locally and work, even though the URI doesn't resolve. I need more coffee and the author of the draft to yell at in order to be sure, though...

Metadata Update from @ralph:
- Issue status updated to: Closed (was: Open)

Should be closed with #75.

Metadata