There is no official, standardized file extension for JSON Schema documents, but several conventions are widely used.
.jsonis the most common and accepted extension, as JSON Schema is itself valid JSON. It is used by validators and tools across languages (Python, Ruby, PHP, etc.). The presence of the$schemakeyword in the file helps distinguish it from regular JSON..schema.jsonis a popular convention, especially in development environments like Visual Studio Code and Visual Studio, to clearly identify schema files. Extensions like JSON Schema Tools and Smart JSON Schema generate files with this extension automatically..jschemaor.jsdhave been suggested as alternatives (inspired by.xsdfor XML Schema), but they are not widely adopted.The official MIME type for JSON Schema is
application/schema+json, and there is an ongoing proposal to officially associate this with the.schema.jsonextension via themime-dbdatabase.
In practice, .schema.json is increasingly favored for clarity, particularly in projects using IDEs with built-in schema support.
From Gary Court:
Answer from Eric Hartford on Stack OverflowI personally use .schema.json, but there is no official file extension. The official mime type however is "application/schema+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".
Update 2022Nov
application/schema+json and application/schema-instance+json will be published by an IETF RFC.
According to current proposal, both json and schema.json extensions are supported. I still find it quite inconvenient for processing based on conventions to have a dot within an extension.
Previous comment
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.
Videos
Hello everyone, I am writing a CLI tool that will have a fairly complex yaml configuration, so I wanted to create a VSCode extension to support that with completion provided by the JSON Schema and some snippets, but it seems not to work.
This is my package.json:
{
"name": "lake-config",
"displayName": "Lake Configuration Helper",
"publisher": "essay97",
"description": "Provides schema validation and snippets to configure Lake",
"version": "0.0.1",
"engines": {
"vscode": "^1.80.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./extension.js",
"contributes": {
"languages": [
{
"id": "yaml",
"extensions": [
".lake"
],
"aliases": [
"Lake Config"
]
}
],
"jsonValidation": [
{
"fileMatch": "**/*.lake",
"url": "./lake-schema.json"
}
]
},
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "node ./test/runTest.js"
},
"devDependencies": {
"@types/vscode": "^1.84.0",
"@types/mocha": "^10.0.3",
"@types/node": "18.x",
"eslint": "^8.52.0",
"glob": "^10.3.10",
"mocha": "^10.2.0",
"typescript": "^5.2.2",
"@vscode/test-electron": "^2.3.6"
}
}When I try to open an extension development host with F5 and open a .lake file, I get the YAML syntax highlighting, but not the JSON Schema, the bottom bar says "no json schema".
What am I missing? I even tried to set the jsonValidation.url to a random json schema from the internet to make sure it was not a problem in my schema but it's still not working.
Also: I'm not sure if I should depend on redhat.vscode-yaml. extension and what extensionDependencies does exactly.
Thanks in advance!
EDIT: I forgot one last doubt. It seems to me that snippets are bound to languages, but I don't like the idea of polluting the YAML environment with my snippets. Is there any way to define a "lake" language that inherits everything from yaml, kind of a "sub-language"?