Json Schema file extension

JsonJsonschema

Json Problem Overview


Is there any naming convention for a json schema file extension? XML has .xsd (XML Schema Definition), what should json schema files have, .jsd (JSON Schema Definition)?

Json Solutions


Solution 1 - Json

From Gary Court:

> I personally use .schema.json, but there is no official file > extension. The official mime type however is > "application/schema+json".

Solution 2 - Json

According to the last draft (v4), there is not a new extension proposed for files storing json-schemas. .json extension is used profusely within that document. .json is also the preferred extension in validators (PHP, Ruby, Python).

So I think that .json should be the preferred option in absence of an official/standard new extension.

Solution 3 - Json

From https://json-schema.org/understanding-json-schema/basics.html#id3

> Since JSON Schema is itself JSON, it’s not always easy to tell when > something is JSON Schema or just an arbitrary chunk of JSON. The > $schema keyword is used to declare that something is JSON Schema. It’s > generally good practice to include it, though it is not required.

So you can use .json as the file extension for JSON schema but maybe with a $schema keyword (although optional) for better distinction.

Solution 4 - Json

I've started using .jschema after I had a run-in with an extension-based JSON Schema parser that automatically added id's to external RAML examples which are also .json files.

They are a specific format, after all. HTML is XML, which is UML, and we use a different file extension for each of those.

Solution 5 - Json

My suggestion is .jsd or .jsonsd standing for Json Schema Document.

I followed the way XML Schemas are named XSD (Xml Schema Document)

Solution 6 - Json

A JSON Schema is a valid JSON file so the extension .json is OK.

Then, the first attribute of your file should be '$schema' to declare the version of the specification you are using. Eg.

    {
      "$schema": "https://json-schema.org/draft/2019-09/schema",

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFresaView Question on Stackoverflow
Solution 1 - JsonEric HartfordView Answer on Stackoverflow
Solution 2 - JsonjruizarangurenView Answer on Stackoverflow
Solution 3 - JsonSaikatView Answer on Stackoverflow
Solution 4 - JsonMichał TatarynowiczView Answer on Stackoverflow
Solution 5 - JsonFabrice TView Answer on Stackoverflow
Solution 6 - JsonDavid BonillaView Answer on Stackoverflow