2

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.)

M Miller
  • 5,364
  • 9
  • 43
  • 65
  • This is not a duplicate of the linked question *at all*. I mean, it's a completely different question entirely, and a valid one. I am voting to re-open. – tom redfern Oct 04 '19 at 10:00
  • I’m the asker. The question I don’t think was an exact duplicate, but the best answer addressed what I was looking for directly. Can you elaborate on the difference? – M Miller Oct 05 '19 at 16:13

0 Answers0