Open
Description
A while ago I released an implementation of the official bundling process and included a set of tests in JSON that could be adopted here if there is interest.
Here's an example:
{
"description": "One external reference",
"schema": {
"$id": "https://bundler.hyperjump.io/main",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"foo": { "$ref": "/string" }
}
},
"externalSchemas": [
{
"$id": "https://bundler.hyperjump.io/string",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string"
}
],
"bundledSchema": {
"$id": "https://bundler.hyperjump.io/main",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"foo": { "$ref": "/string" }
},
"$defs": {
"https://bundler.hyperjump.io/string": {
"$id": "https://bundler.hyperjump.io/string",
"type": "string"
}
}
}
}
Notes/Comments/Rationale:
- I think this structure is pretty self explanatory, but please ask if anything isn't clear.
- In hindsight, it might make more sense for
"externalSchemas"
to be an object rather than an array. The keys would be retrieval URIs and the values would be schemas. This would allow for tests where the retrieval URI and the$id
don't match, or where the$id
is relative, or where there is no$id
. - Some of my tests might be a bit implementation specific, so I'm not sure the should all be here. For example, I have an option that allows the bundler to skip certain schemas that you want to remain external. That's not necessarily a feature everyone needs to support.