vscode-yaml
vscode-yaml copied to clipboard
Multiple JSON Schemas - Selection of single Schema not working
Describe the bug
It is not possible to select one JSON schema of the list, if multiple are detected for a specific file.
Detected Schemas: https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/bungee-plugin.json https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/bukkit-plugin.json https://github.com/SchemaStore/schemastore/blob/404ada34125022391ae5a4484d490f3d769a6555/src/schemas/json/pocketmine-plugin.json
Expected Behavior
The selection should work without problems.
Current Behavior
This VSCode extension is detecting three schemas for the same file, what is is right due to the same file name... of the file. In the right lower corner it shows "Multiple JSON Schemas...", when I click on this, a menu opens with the title "Select JSON schema", but when I'm going to select one out of the list nothing is happening. Still the same selection of all three files.
Steps to Reproduce
- Create a file named
plugin.yml - Click the button "Multiple JSON Schemas..."
- Select one, for example "Bukkit plugin.yml"
- Look at the button and see, that the button didn't change and the selection is still the same.
Environment
- [X] Windows
- [ ] Mac
- [ ] Linux
- [ ] other (please specify)
Thank you for this ticket.
I've fixed by editing .vscode/settings.json file
I have also encountered this. Where would the information about what the current schema is be stored?
+1, can't select single JSON schema
+1
From what I can see, if one selects a JSON Schema by hand, the mapping of schema-path onto filename is added to the list yaml.schemas in settings.json -- irrespective of a previous match.
It doesn't matter, whether the previous match is via wildcard, or relative file name: an absolute-pathed entry is added. ⇒ Multiple entries match and the error is shown.
I think, this could be healed, if
- the relative entries would be matched and modified / replaced,
- there was an option to set schema paths relative to a variable, but there isn't.^1
So far, what works best for me is:
- Map schemas only onto files, that are always to be validated with that schema -- no option to switch schema for these files.
- List all (relative) schemas, mapping onto empty lists
: [], to make them available in the JSON Schema switcher for manual choosing.