Repository navigation
Use absolute URIs for schema ids - #2688
Conversation
javagl
left a comment
There was a problem hiding this comment.
I scrolled over the changes, and it seems to insert
https://schema.khronos.org/gltf/2.0/specification/
everywhere. I have not verified that none of the changes contained a typo (but that's unlikely). I have not checked that all files are covered (but it looks like they are).
I have not yet tried out my code generator or wetzel on this state, but I think that they are both not using the id to begin with.
Whether or not this change affects other code generators is hard to say, but regardless of that, the change is "The Right Thing To Do".
Can you elabroate that? There are references like EDIT: Does this only refer to the (intended) portability, of essentially replacing this ref with the "full URL / ID"? That would make sense, but wouldn't be strictly required, I guess... |
|
An URI used in Main spec example (heavily reduced): {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schema.khronos.org/gltf/2.0/specification/texture.schema.json",
"properties": {
"sampler": { "$ref": "glTFid.schema.json" },
"source": { "$ref": "glTFid.schema.json" }
}
}The Now let's look at the punctual light example (with the expected updates applied). {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schema.khronos.org/gltf/2.0/extensions/KHR_lights_punctual/node.KHR_lights_punctual.schema.json",
...The base URI is different here so there are two equivalent options for {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schema.khronos.org/gltf/2.0/extensions/KHR_lights_punctual/node.KHR_lights_punctual.schema.json",
"$ref": "../../specification/glTFProperty.schema.json",
"properties": {
"light": { "$ref": "../../specification/glTFid.schema.json" }
}
}{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schema.khronos.org/gltf/2.0/extensions/KHR_lights_punctual/node.KHR_lights_punctual.schema.json",
"$ref": "https://schema.khronos.org/gltf/2.0/specification/glTFProperty.schema.json",
"properties": {
"light": { "$ref": "https://schema.khronos.org/gltf/2.0/specification/glTFid.schema.json" }
}
} |
|
The statement
sounds like a strong (and somewhat surprising) constraint that doesn't appear to be derived directly from things like https://json-schema.org/draft/2020-12/json-schema-core (but it has been a while since I read the related parts of these ""specs"" the last time). My understanding was (roughly):
In any case, if these are replaced with absolute URLs, then there shouldn't be an issue: Everything is absolute (and matches the IDs). For practical applications, using absolute URIs may be a challenge, though. Tools like wetzel may then have to dissect that absolute URI, for example, to find out that |
From the upstream specs:
So if the Another upstream quote:
So any tool processing glTF schemas should ignore physical locations of schema files and instead load them all at once and use those absolute This only becomes an issue for schemas without |
Fixes #2182.
This PR only covers the main schemas. Aligning the extension schemas to use absolute URIs for
$idvalues (among various other tweaks) would be done as a part of #2049.Note that
$refproperties inside the main schema files do not need to be updated because$refURIs are resolved against base URIs derived from$idURIs.However,
$refproperties that refer to something likeglTFid.schema.jsonfrom extension schemas will have to be adjusted together with their$idURIs.