Reputation: 869
Is there a standardized way to specify this documents schema, i have been looking for one, but i am unsure if using the following is the correct way of doing things.
// My JSON Document
{
"$schema": "http://path.to/my/schema.json",
...
}
Upvotes: 1
Views: 423
Reputation: 24399
The JSON Schema spec has two recommendations for correlating a JSON document with a schema. Both have to do with HTTP headers. JSON Schema does not define a way for JSON documents to be self describing, but it could easily be done in a way similar to the example you gave.
The Content-Type
header seems to be the most widely accepted correlation mechanism. It defines a MIME type parameter called profile
whose value is a URI to to schema that defines the JSON document.
Content-Type: application/json; profile="/my-hyper-schema#"
The other correlation mechanism is to include a Link
header with a URI to the schema that defines the JSON document. This Link
should have a rel
of describedBy
Link: </my-hyper-schema#>; rel="describedBy"
Upvotes: 3