I have a json schema for an array. The schema is correct and my array can validate against it. Now I would like to define the schema in the json like i could do with an object like this :
{
"$schema": "pathtomyschema",
"prop1": "value",
...
}
Obvisouly I can't simply set $schema in the array like this :
[
"$schema": "pathtomyschema",
{ "prop1": "value" },
...
]
So, is there any way to do this ?
The goal here is to help people create their json with schema reference.
$schema
does not work on JSON instances in general. it is a keyword for schemas to declare what metaschema they use. information on what schema describes an instance is out-of-band to the instance.
if your instance is accessed over http, the recommended method to communicate what schema describes an instance is the 'describedby' link header - see http://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.9.5.1.1