yaml-language-server
yaml-language-server copied to clipboard
Numbers in comments
Describe the bug
I am using yaml-language-server via RedHat's VSCode plugin and whenever I put a number (like '7') into a comment that occurs at the beginning of the document, the schema does not get loaded:
The error also occurs when I have the comment above the document start line ('---
') or when I add a %YAML
directive. See this discussion of the behavior in the VSCode plugin.
This is not an issue with the plugin since I can reproduce the issue with vim:
Expected Behavior
The schema should be loaded and used to validate the YAML file.
Current Behavior
Instead, I get the error message Unable to parse content from '[absolute path]/testSchema.yaml': Parse error at offset 0.
Steps to Reproduce
- Create this schema file:
---
# a comment - that seems to work unless we add a number 123
title: Learning JSON/YAML schema
type: object
properties:
id:
type: string
- Create this YAML file in the same directory:
# yaml-language-server: $schema=./testSchema.yaml
---
id: "123"
description: "a short description"
Environment
- [ ] Windows
- [X] Mac (and vim or VSCode)
- [ ] Linux
- [ ] other (please specify)
One more observation: the problem disappears when I add a modeline. Hope this helps.
# yaml-language-server: $schema=http://json-schema.org/draft-07/schema