vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Multiple JSON Schemas - Selection of single Schema not working

Open BlockyTheDev opened this issue 1 year ago • 5 comments

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

  1. Create a file named plugin.yml
  2. Click the button "Multiple JSON Schemas..."
  3. Select one, for example "Bukkit plugin.yml"
  4. 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)

BlockyTheDev avatar Nov 18 '23 17:11 BlockyTheDev

Thank you for this ticket.

I've fixed by editing .vscode/settings.json file

confiq avatar Dec 13 '23 11:12 confiq

I have also encountered this. Where would the information about what the current schema is be stored?

ephb avatar Jan 17 '24 16:01 ephb

+1, can't select single JSON schema

yaroslavsadin avatar Feb 16 '24 18:02 yaroslavsadin

+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

  1. the relative entries would be matched and modified / replaced,
  2. 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.

UnePierre avatar Mar 27 '24 10:03 UnePierre