You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JSON schema spec does not seem to put any constraints on the $id, but all the examples seem to follow a similar pattern that omits the extension, e.g.:
{ "$id": "/schemas/address", ... }
Is it discouraged to put the extension in the URL, as this is how the schema will be stored?
{ "$id": "/schemas/address.schema.json", ... }
The text was updated successfully, but these errors were encountered:
The short answer is that it doesn't matter. Use whatever you like.
That said, keep in mind that schema identifiers can't be relative as they are in your example. Whether or not I would use an extension depends on the URI scheme being used. If using http(s):, I wouldn't use an extension https://example.com/schemas/address) because that's the convention for the http(s): URI scheme.
However, what I prefer is to not use $id and allow the file's location on the file system to be the be the schema's identifier (file:///path/to/schema/address.schema.json). In this case, the identifier includes the extension because the file has an extension. References to this schema are file system relative, so you'll see references like, ./address.schema.json for this schema.
@andriy-dmytruk, to clarify, the JSON Schema specification explicitly recommends in section 8.2.1.1 that $id be included with a fully-qualified (absolute), fragment-less URI to serve as a base identifier.
Self identification holds the highest priority according to the URI specification, section 5.1, whereas file location holds the second lowest.
The JSON schema spec does not seem to put any constraints on the
$id
, but all the examples seem to follow a similar pattern that omits the extension, e.g.:Is it discouraged to put the extension in the URL, as this is how the schema will be stored?
The text was updated successfully, but these errors were encountered: