redhat-developer / redhat-developer/yaml-language-server

Support ref pointers in url with `schema.json#$RefName`

Open
#988 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
352
Avg merge
2d 7h
Merged PRs (30d)
11

Description

Is your enhancement related to a problem? Please describe.

my schema.json:

{
  "$defs": {

    "IncludeAThing": {
      "properties": {
        "include": {
          "type": "string"
        }
      },
      "required": [
        "include"
      ],
      "title": "IncludeAThing",
      "type": "object"
    },

    "ABigThing": {
      "properties": {
        "thing": {
          "$ref": "#/$defs/AThing"
        }
      },
      "required": [
        "thing"
      ],
      "title": "ABigThing",
      "type": "object"
    },

    "AListOfThings": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/AThing"
          },
          {
            "$ref": "#/$defs/IncludeAThing"
          },
          {
            "$ref": "#/$defs/ABigThing"
          }
        ]
      },
      "title": "AListOfThings",
      "type": "array"
    },

    "AThing": {
      "properties": {
        "name": {
          "type": "string"
        },
      },
      "required": [
        "name"
      ],
      "title": "AThing",
      "type": "object"
    },
  },
  "properties": {
    "things": {
        "$ref": "AListOfThings"
    }
  },
  "required": [
    "things",
  ],
  "title": "ASchemaOfThings",
  "type": "object"
}

so i might have :

config.yml

# yaml-language-server: $schema=./schema.json

things: 
  - include: "./some-include.yml"
  - thing:
      name: "The Thing!"
  - name: "Moar things!"

./some-include.yml

- name: "All"
- name: "The"
- name: "Things"
- thing: 
    name: "Foo"
- include: "./moar-things.yml"

I want to be able to do :

./some-include.yml

# yaml-language-server: $schema=./schema.json#$AListOfThings

- name: "All"
- name: "The"
- name: "Things"
- thing: 
    name: "Foo"
- include: "./moar-things.yml"
Describe the solution you would like

allow me to specify that a yaml file be validated by a ref pointer of an existing schema.

Describe alternatives you have considered

Giving up software and becoming a farmer.

Additional context

n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the schema reference in config.yml and schema.json, then trace how the YAML language server resolves the $schema URL and its fragment. Check the existing handling of schema.json references before adding coverage for some-include.yml using schema.json#$AListOfThings. Done means fragment-based validation works without breaking ordinary schema URLs.

Written by the indexing model from the issue text.

Assessment

Tech stack
json, typescript, yaml
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.