vscode-yaml
vscode-yaml copied to clipboard
Editing a YAML file with its schema in parallel will force apply the schema to itself as well
Describe the bug
I'm writing a YAML data file and its schema (in YAML as well) in parallel. In multiple ways now, I tried to reference the schema to the data file so the data file gets validated, however when switching back to the schema file, it also get validated by itself, which of course results in many errors.
Interestingly, after adding the line # yaml-language-server: $schema=https://json-schema.org/draft/2020-12/schema to the schema file, VSC displayed that multiple schemas are available and I could select the "json schema" schema. But still the wrong validation will be applied and at at the status bar the yellow warning will still be displayed after selecting the schema.
My settings.json both globally and for the workspace do not contain any yaml.schemas or other keys for this plugin (except after selecting the correct schema after adding the meta schema line).
Expected Behavior
Only apply the schema file to the data file (where the reference is defined) and not to the schema file itself.
Current Behavior
The schema gets applied to itself.
Steps to Reproduce
- Create/copy both files inside a workspace
- Append
# yaml-language-server: $schema=./SB_Flowchart_Schema.yamlto the data file - Switch to the schema file and see the red errors.
Environment
- [ ] Windows
- [ ] Mac
- [x] Linux
- [ ] other (please specify)
Screenshots
Screenshots

After adding the additional yaml-language-server line to the schema file:


Data & Schema File
File contents
Schema File (called SB_Flowchart_Schema.yaml)
$schema: "https://json-schema.org/draft/2020-12/schema"
title: Schema with questions leading to results
description: |-
This schema can be used to describe a set questions and results.
For example an app can ask its user these questions in the defined order
and return or use the result afterwards.
This schema was originally created to define the SponsorBlock flowchart
(see https://github.com/cole8888/SponsorBlock-Flowchart) in a structural way.
line_endings: unix
type: object
properties:
results:
type: object
additionalProperties:
type: object
text:
type: string
category:
type: string
required:
- results
- questions
additionalProperties: false
Data File (called SB_Flowchart.yaml)
# yaml-language-server: $schema=./SB_Flowchart_Schema.yaml
# texts might be markdown
results: # sorted alphabetical by id TODO
nothing:
text: >-
Do not submit anything!
highlight:
text: >-
Highlight
category: poi_highlight
sponsor:
text: >-
Sponsor
category: sponsor
music_non_music:
text: >-
Music: Non-Music section
category: music_offtopic
platform_split_exclusive:
text: >-
While promoting their exclusive: _self promo_.
While promoting the platform: _sponsor_.
questions: # sorted alphabetical by id TODO
is_skip_really_required:
text: >-
Is the video better off without skipping the segment or is the transition really bad?
boolean: true
answers:
- text: "Yes"
result: nothing
skips_to_poi:
text: >-
Does the segment skip ahead to the point of interest?
boolean: true
answers:
- text: "Yes"
is_highlight:
text: >-
Does the segment meet any of the _highlight_ use cases?
is_music_primary:
text: >-
Is music the primary aspect of the video?
is_present_in_official:
text: >-
Is the segment present in the official music? (Spotify version?)
is_part_of_song_playing:
text: >-
Is part of the song playing in the background of the segment?
is_disclaimer_protecting:
text: >-
Is this a disclaimer intended to protect the viewer? (epilepsy, trigger warning, 18+)
is_segment_near_end:
text: >-
Is the segment located at or near the end of the video?
Duplicate of #477
@msivasubramaniaan could you have a look at this bug (I'm assuming you're a maintainer)? It's been reported at least 3 times independently and seems to be the bug with the most users affected by number of likes/reports. It's been open for >1 year with no apparent action from maintainers :(