Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to configure YAML schema to make editing files easier

November 25, 2020
Aurélien Pupier
Related topics:
Developer toolsIDEs

    YAML is a friendly data serialization standard that works with all programming languages. While configuration files are often defined in YAML, it can even be used as a programming language, like the workflow language at Google, or Apache Camel K.

    It has the advantage of not having any braces, making it lightweight visually. One of the drawbacks is that editing YAML files may not always be easy. For instance, writing a tag at the wrong indentation level can be hard to detect. To help with editing, it is possible to provide a YAML schema that can be leveraged by a large set of integrated development environments (IDEs). Unfortunately, this practice is not widespread. Consequently, users waste time searching for a missing or extra space and browsing documentation.

    In this article, you will discover the benefits of providing a YAML schema and how to make it consumable for all your users, making it easier to edit YAML files.

    YAML schema

    Providing a schema describing the structure of a YAML file type is possible. You might not find the specification easily because it relies on the JSON Schema specifications. YAML schemas allow several IDEs and editors to provide code completion, documentation on hover, and validation of the file, including Eclipse Desktop IDE, Eclipse Che, VS Code, IntelliJ, Emacs, and vim.

    For instance, see the code completion example in VS Code for an Apache Camel K integration file in Figure 1.

    VS Code showing code completion in the file test.camelk.yaml.
    Figure 1: Code faster with the code completion provided by your YAML schema.

    Figure 2 shows an example of file validation.

    VS Code showing a validation error in the file test.camelk.yaml
    Figure 2: Validate your file against your YAML schema to ensure that it has the right structure.

    Figure 3 shows an example of documentation on hover.

    Documentation on hover in a kustomization.yaml file
    Figure 3: Hover over a property to see a description.

    Schema registry

    I recommend that you register the schema in the JSON Schema store which is, as far as I know, the largest registry of JSON and YAML schemas. The JSON Schema store is used directly or through the YAML Language Server in several IDEs. It allows an automatic binding of YAML files with their corresponding schema. The biggest advantage is that it is completely transparent for the end user.

    To benefit from the JSON Schema store and the built-in integration offered by IDEs, the YAML schema writer needs to set a file name pattern for the YAML files and the schema's users need to respect that pattern. For instance, you can use this kind of file pattern *.myId.yaml. Take care to avoid collision with the existing file name pattern. Colliding with the existing file name patterns will complicate things for your users.

    Schema association without a file name pattern

    If you do not want to impose a file name pattern, two possibilities remain that benefit from the schema association. Using one of these other methods will add extra effort either for the user or during your tooling maintenance.

    Possibility 1: Specific IDE schema association

    Most IDEs provide ways to associate a schema to a specific file via preferences. In this case, the burden is on your user.

    It is also possible to write a specific extension to auto-associate the schema. The drawback is that specific IDE extensions must be written for each IDE that you want to support. Hopefully, for some of them, there is a specific API to do it. For instance, vscode-yaml is one way you could accomplish this.

    Possibility 2: Using in-file declarations

    It is possible to use inline metadata to specify the schema corresponding to the file. The following modeline-like format must be used:

    # yaml-language-server: $schema=https://my.url.to/the/schema

    The main drawback is that this option places a burden on your users. This annotation is also specific to yaml-language-server and not part of the specifications. If you think it would be nice to have it directly inside the YAML specification, please cast your vote here.

    The main advantage is that it is available under the hood with all recent IDEs by using the YAML Language Server.

    Summary

    Providing a YAML schema provides a tremendous benefit to your users. Now you know multiple ways to make your YAML schema easily accessible to all of your users, and make editing these YAML files easier. From here, I hope to see a huge increase in registered schemas on the Schema store!

    Last updated: January 25, 2021

    Recent Posts

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.