
It´s a matter of creating a schema describing your file following the JSON schema specification, and import it in your editor. JSON Schema Store hosts schemas for many popular file formats, but you can also create your own as demonstrated in this article. JSON Schema provides a simple way to implement auto-completion for JSON and YAML files and is supported out of the box, by many popular editors like Visual Studio, Visual Studio Code, and the Jetbrains family IDEs.

We have just built an autocomplete feature for hadolint.yaml files.

Note that, it could take some seconds for VS Code to index the schema in the first time.Īnd that´s it. hadolint.yaml file and press CTRL + Space, VS Code should then display the suggestions based on the schema we created for this file type. If everything worked as expected, when we create a new. Save the file and reload VS Code to finish the process. JSON Schema is a specification that allows you to describe the structure of a JSON document and validate documents against that schema.įor example, the following schema could be used to describe a "Person" entity: Be sure to check their respective documentation.
:max_bytes(150000):strip_icc()/xsd-visual-studio-5c3f2a14c9e77c00014ba34b.png)
Note: other editors like the ones from the Jetbrains family, also use the same strategy to provide the same functionality, so, while in this article VS Code is used as an example, the concepts should be applicable to any of these IDEs. To be able to do this, VS Code uses JSON Schema under the hood. This is very practical and provides a quick way of knowing all the available options without having to look at Documentation. Visual Studio Code has the ability to display autocomplete suggestions for popular configuration files in JSON and YAML format out of the box.įor example, If you have a package.json file opened in VS Code, you can tap CTRL + Space and a pop-up will appear, displaying suggestions for all the available fields for that file type.
