I couldn't find information on this in the Understanding JSON schema site and I tried to parse the official specification, but wanted to see if I was overlooking something.
When creating a JSON schema, you typically add the $schema
property to indicate that the JSON schema conforms to the schema for JSON schemas themselves.
Would it also be considered standard to add this property to non-schemas? As in, it would be nice to explicitly embed in a JSON document what schema it conforms to, so it's immediately identifiable. Like:
{
"$schema": "https://api.example.org/schemas/v1/product.json",
"name": "Foobar",
"price": 100,
"description": "A bar of solid foo"
}
This would be particularly nice for arrays of subdocuments, over something less globally distinct, like an enum
on some type
property.
I wouldn't want to use this, however, if it's unconventional.
(I'm guessing if there's an official version, it wouldn't look exactly like this, as that would imply that $schema
is a reserved property, and that'd be a JSON schema anti-pattern afaict.)