SchemaLoader downloads external resources
See original GitHub issueMy application includes a local copy of the JSON schema metaschema, which looks like this:
{
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
Now when SchemaLoader
is instructed to load this schema (from a local file), it attempts to fetch the resource given by the URL in the id
property.
In a certain installation, my application is supposed to work offline, so this HTTP request is intercepted by the firewall, leading to an exception.
When I remove the "id"
property, SchemaLoader
does not attempt to fetch that resource.
I believe that this behavior is wrong, as per the following text in the JSON Schema spec (emphasis mine):
http://json-schema.org/latest/json-schema-core.html#rfc.section.8
The URI is not a network locator, only an identifier. A schema need not be downloadable from the address if it is a network-addressable URL, and implementations SHOULD NOT assume they should perform a network operation when they encounter a network-addressable URI.
http://json-schema.org/latest/json-schema-core.html#rfc.section.9.2.2
To differentiate schemas between each other in a vast ecosystem, schemas are identified by URI. As specified above, this does not necessarily mean anything is downloaded, but instead JSON Schema implementations SHOULD already understand the schemas they will be using, including the URIs that identify them.
Also, I wonder why the "id"
property gets any special treatment: unless I’m mistaken, the spec assigns no specific meaning to this property, only to the "$id"
property.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Hello @JakimLi , thanks for your kind words.
The process to deploy an artifact to the central repository is simpler now as it used to be, so I published the latest version as
com.github.erosb:everit-json-schema:1.9.2
. I’d still like to keep jitpack as the primary distibution channel though.Hello @raphw , currently we distribute the library on maven central too, though it lags a bit behind the jitpack version. The latest coordinates are
com.github.erosb:everit-json-schema:1.9.2