JSON Schema Core, $dynamicAnchor, and $vocabulary
Slightly off-topic, but I'm writing a Deno library.
Anyone deeply knowledgeable on JSON Schema Core? I have this meta-schema, and I can't figure out how the heck it's supposed to work that
"$ref": "meta/core"
would refer to "https://json-schema.org/draft/2020-12/vocab/core"
– any ideas? I feel like I'm missing something fundamental knowledge on the JSON Schema Core spec here...
3 Replies
Isn't the vocab and the allOf aligned one-to-one? JSON is ordered mostly by insertion time so it seems pretty easy to match the two up.
>Isn't the vocab and the allOf aligned one-to-one?
i mean... yes, but the syntax in each
$ref
seems completely arbitrary. the json schema core spec doesn't say anything about such a syntax that i'm aware. https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#appendix-D.2IETF Datatracker
JSON Schema: A Media Type for Describing JSON Documents
JSON Schema defines the media type "application/schema+json", a JSON- based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/ schema-instance+json" media type provides additional feature-rich integration wi...
from the link:
hm, i think i get it now.
"$id": "https://json-schema.org/draft/2020-12/schema",
this identifies the URI of the schema itself.
so then the relative URI meta/core
becomes:
https://json-schema.org/draft/2020-12/meta/core
which is what's actually being $ref
'd here.
the vocabulary URI's themselves aren't actually schemas, more like unique identifiers.