microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.19k stars 28.85k forks source link

[json] allow to override & replace existing schemas #219855

Open abgox opened 3 months ago

abgox commented 3 months ago

Does this issue occur when all extensions are disabled?: Yes/No

  1. Add schema in settings.json
    "json.schemas": [
        {
            "fileMatch": [
                "demo.json"
            ],
            "url": "https://abgox.github.io/schema/prettier/zh-CN/.prettierrc-min.json"
        },
        {
            "fileMatch": [
                "demo.json"
            ],
            "url": "https://abgox.github.io/schema/prettier/en-US/.prettierrc-min.json"
        }
    ]
  2. When I edit a demo.json, it matches to two schema.
  3. But,I cannot select the specified json schema !

image

  1. When I try to apply a given schema, it just goes to the schema page and doesn't apply it!
abgox commented 3 months ago
abgox commented 2 months ago
aeschli commented 2 months ago

At the moment, schemas are always additive. There's currently not way of disabling other schemas.

abgox commented 2 months ago
  • By the way, when I define the schema in settings.json, it means that I want to use my own defined schema, not the default or third-party-provided one.
  • So, in this case, the schema I defined in settings.json should have the highest priority. It should take effect immediately, without me even having to make a choice.
abgox commented 1 month ago

By the way, all schemas are as follows:

  1. The $schema attribute in the JSON file.
  2. The json.schemas attribute in settings.json (Workspace)
  3. The json.schemas attribute in settings.json (User)
  4. The schema provided by the extension.


At the moment, schemas are always additive. There's currently not way of disabling other schemas.

aeschli commented 1 month ago

All matching schemas are combined with an allOf. The schema is tested against all schemas. So the order does not matter.

Note that schemas defined in the workspace settings replace the schemas in the user settings. This is how the VS Code settings work.

abgox commented 1 month ago

image

Note that schemas defined in the workspace settings replace the schemas in the user settings.