Skip to content

Support custom JSON schema validation in the Web IDE

Problem to solve

Projects that rely on people writing configurations in JSON or YAML format can cause problems because it's easy to make a typo and break things. It's possible to write validation tools that catch this in the CI pipeline but using a JSON schema file, can be helpful for offering documentation and hints.

Further details

This is a problem for the www-gitlab-com where we need to write release post items every month.

Proposal

Users should be able to define custom schema files that are loaded in the Web IDE.

Implementation Details

The Web IDE has an existing file that's loaded for settings used by the Web Terminal .gitlab/.gitlab-webide.yml. This should be extended with an additional section schemas that allows users to define additional schemas.

schemas:
  - uri: https://json.schemastore.org/package
    match: 
      - package.json
  - uri: https://absolute/raw/url
    match: 
      - data/release_posts/unreleased/*.yml
      - data/release_posts/unreleased/*.yaml
  - uri: https://absolute/raw/url2
    match: 
      - data/release_posts/unreleased/*.{yml,yaml}
  - uri: https://absolute/second/raw/url
    match: 
      - "*.gitlab-ci.yml"

As an MVC we will only load schema files referenced by absolute URL and not relative path in the repository. This could be the RAW url to a file in the project, a snippet, or something else.

Pricing Tier

This feature is going to be part of GitLab Premium in the Enterprise Edition. The rationale for this decision is that teams collaborating on projects where custom schema may be required would benefit from having feedback and mechanisms to use this in the Web IDE.

Edited by Himanshu Kapoor